A backend API service for a Twitter-like application, built with Node.js, Express, and MongoDB. This project supports essential features such as user management, tweets, comments, likes, and followers.
- User Management: User registration, login, profile updates, and secure authentication with refresh tokens.
- Tweet Management: Allows users to post tweets with optional image uploads.
- Comments: Users can add comments to tweets.
- Likes: Users can like tweets or comments.
- Followers: Users can follow or unfollow other users.
| Field | Type | Description |
|---|---|---|
username |
String | Unique username |
password |
String | Hashed password |
email |
String | Unique email address |
fullname |
String | Full name of the user |
avatar |
String | URL of the profile picture |
coverimage |
String | URL of the cover image |
refreshtoken |
String | Refresh token for sessions |
about |
String | Bio or about section for user |
social_link |
String | User's external profile link |
| Field | Type | Description |
|---|---|---|
content |
String | Text content of the tweet |
user |
ObjectId | Reference to the user who posted the tweet |
image |
String | URL of an optional image associated with the tweet |
| Field | Type | Description |
|---|---|---|
content |
String | Text content of the comment |
user |
ObjectId | Reference to the user who commented |
tweet |
ObjectId | Reference to the related tweet |
| Field | Type | Description |
|---|---|---|
tweet |
ObjectId | Reference to the liked tweet |
comment |
ObjectId | Reference to the liked comment |
user |
ObjectId | Reference to the user who liked |
| Field | Type | Description |
|---|---|---|
follower |
ObjectId | User ID of the follower |
following |
ObjectId | User ID of the user being followed |
git clone https://github.com/Sourav0010/Twitter-Backend.git
cd Twitter-Backendnpm install- Create a
.envfile based on the provided.env.exampletemplate. - Set your MongoDB URI and other required environment variables.
npm run devhttps://twitter-backend-6jlw.onrender.com
POST /api/v1/users/signup: Register a new user.POST /api/v1/users/login: Login an existing user.POST /api/v1/users/logout: Logout user.POST /api/v1/users/refresh-token: Generate a new access token.PATCH /api/v1/users/profile: Update user profile.
POST /api/v1/tweets/: Create a new tweet.GET /api/v1/tweets/: Get all tweets.GET /api/v1/tweets/:tweetId: Get a specific tweet.DELETE /api/v1/tweets/:tweetId: Delete a tweet.
POST /api/v1/comments/:tweetId: Add a comment to a tweet.GET /api/v1/comments/:tweetId: Retrieve all comments for a tweet.DELETE /api/v1/comments/:commentId: Delete a comment.
POST /api/v1/likes/toggle/tweet/:tweetId: Like or unlike a tweet.POST /api/v1/likes/toggle/comment/:commentId: Like or unlike a comment.
POST /api/v1/followers/follow/:userId: Follow or unfollow a user.GET /api/v1/followers/:userId: Retrieve the followers of a user.GET /api/v1/following/:userId: Retrieve the users followed by a user.
- Backend: Node.js, Express.js
- Database: MongoDB (Mongoose)
- Authentication: JWT
- Other: Cloudinary (for media uploads)
If you’d like to contribute to this project:
- Fork the repository.
- Create a feature branch (
git checkout -b feature-name). - Commit your changes (
git commit -m "Add feature"). - Push to the branch (
git push origin feature-name). - Open a pull request.
Thank you for checking out the Twitter Backend! Feel free to raise any issues or contribute to make this project better.
~ Sourav Mohanty