Welcome to Twitify, a social media application built on a Monolith architecture! In Twitify, users can post tweets with images, comment on tweets, reply to comments, like tweets or comments, and filter tweets by hashtags.
- Post tweets with images ๐ธ
- Comment on tweets ๐ฌ
- Reply to comments ๐จ๏ธ
- Like tweets and comments โค๏ธ
- Filter tweets by hashtags ๐
- Node.js
- MongoDB
- Cloudinary account for media storage
- Clone the repository:
git clone https://github.com/yourusername/twitify.git cd twitify
- Install dependencies:
npm install
- Environment Variables:
- Create a .env file in the root directory and add the following:
DATABASE_URL=mongodb://127.0.0.1:27017/[your database name] PORT=3000 JWT_SECRET=[Your JWT Secret] CLOUD_NAME=[Your Cloudinary Cloud Name] API_KEY=[Your Cloudinary API Key] API_SECRET=[Your Cloudinary API Secret] MAIL_HOST=[Your Mail Host] MAIL_USER=[Your Mail User] MAIL_PASS=[Your Mail Password]
- Run the Server:
npm start
- POST /api/v1/signup
- Create a new user account.
- Request Body:
{ "email": "[email protected]", "password": "yourpassword", "name": "Your Name" }
- POST /api/v1/login
- Log in with existing credentials.
- Request Body:
{ "email": "[email protected]", "password": "yourpassword" }
- You will get a Bearer Token in response, whose expiry time is 1 hr
- Use this token to authenticate yourself to make tweets, comments.
- POST /api/v1/tweets
- Create a new tweet (requires authentication).
- Request Body:
{ "content": "Your tweet", "image": "image_url" }
- GET /api/v1/tweets
- You have to pass tweetID in params
- Retrieve all tweets.
- POST /api/v1/comments
- Create a new comment on a tweet (requires authentication).
- Request Body:
{ "content": "Your comment", }
- Pass modelId(tweet_or_comment_id) and modelType(Tweet/Comment) in query params
- POST /api/v1/likes/toggle
- Toggle like on a tweet or comment.
- Request Body:
{ "likeableId": "tweet_or_comment_id", "onModel": "Tweet/Comment" }
Field | Type | Description |
---|---|---|
email |
String, required, unique | User's email address. |
password |
String, required | User's password (hashed). |
name |
String, required | User's name. |
timestamps |
Boolean | Automatically managed timestamps. |
Field | Type | Description |
---|---|---|
content |
String, required, max 250 | Content of the tweet. |
user |
ObjectId, ref: 'User', required | User who posted the tweet. |
likes |
Array of ObjectId, ref: 'Like' | Likes received by the tweet. |
comments |
Array of ObjectId, ref: 'Comment' | Comments posted on the tweet. |
image |
String | URL of the image attached to the tweet. |
timestamps |
Boolean | Automatically managed timestamps. |
Field | Type | Description |
---|---|---|
content |
String, required | Content of the comment. |
userId |
ObjectId, ref: 'User', required | User who posted the comment. |
onModel |
String, enum: ['Tweet', 'Comment'], required | Type of parent entity (tweet or comment). |
commentable |
ObjectId, refPath: 'onModel', required | ID of the parent entity (tweet or comment). |
comments |
Array of ObjectId, ref: 'Comment' | Replies to the comment. |
timestamps |
Boolean | Automatically managed timestamps. |
Field | Type | Description |
---|---|---|
onModel |
String, enum: ['Tweet', 'Comment'], required | Type of entity being liked (tweet or comment). |
likeable |
ObjectId, refPath: 'onModel', required | ID of the entity being liked. |
user |
ObjectId, ref: 'User', required | User who liked the entity. |
timestamps |
Boolean | Automatically managed timestamps. |
Feel free to reach out to me at [email protected] or connect with me on LinkedIn.
Thank you for checking out Twitify! If you have any feedback or suggestions, feel free to open an issue or make a pull request.
Happy coding! ๐