Skip to content

AlexMercer00/TwitMaster-API

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TwitMaster API (Twitter-like advance Backend)

This project is a Twitter-like backend API built with Node.js, Express, MongoDB, and Mongoose.
It supports JWT authentication, image uploads to AWS S3, and basic Twitter features such as likes, comments, and hashtags.


Features

  • User authentication (Signup & Login with JWT)
  • Create tweets (max 250 characters + optional image upload to S3)
  • View all tweets (with pagination)
  • Like/unlike tweets and comments
  • Comment on tweets
  • Nested comments (comment on a comment)
  • Hashtag extraction and storage
  • AWS S3 integration for image uploads

Folder Structure

src/ ├── config/ │ ├── database.js │ ├── file-upload-s3-config.js │ └── jwt-middleware.js ├── controllers/ │ ├── auth-controller.js │ ├── tweet-controller.js │ ├── like-controller.js │ └── comment-controller.js ├── middlewares/ ├── models/ │ ├── comment.js │ ├── hashtag.js │ ├── like.js │ ├── tweet.js │ └── user.js ├── repository/ │ ├── crud-repository.js │ ├── tweet-repository.js │ ├── comment-repository.js │ ├── like-repository.js │ ├── hashtag-repository.js │ └── user-repository.js ├── routes/ │ ├── v1/ │ │ └── index.js │ └── index.js ├── services/ │ ├── tweet-service.js │ ├── like-service.js │ ├── comment-service.js │ └── user-service.js ├── utils/ │ └── error-codes.js └── index.js


Run Locally

Prerequisites

  • Node.js (>=16.x)
  • MongoDB (local or Atlas cloud)
  • AWS S3 bucket & IAM credentials (for image uploads)
  • Git (optional)

Steps

  1. Clone the repository git clone https://github.com/tejash023/twitter-backend-api.git cd twitter-backend-api

  2. Install dependencies npm install

  3. Configure environment variables Create a .env file in the project root with the following:

    PORT=3000 MONGODB_URI= JWT_SECRET= AWS_REGION= AWS_SECRET_ACCESS_KEY= ACCESS_KEY_ID= BUCKET_NAME=

  4. Start the server npm start

  5. Access the app Open http://localhost:3000 in your browser


API Endpoints (Sample)

Method Endpoint Description Auth Required


POST /api/v1/signup Create a new user No POST /api/v1/login Login and get JWT No POST /api/v1/tweets Create a new tweet Yes GET /api/v1/tweets Get all tweets (supports pagination)Yes POST /api/v1/tweet/destroy Delete a tweet by ID Yes POST /api/v1/likes/toggle Like/unlike a tweet or comment Yes POST /api/v1/comment Create a comment on tweet or comment Yes

Note: All authenticated routes require the Authorization: Bearer header.


Technologies Used

  • Node.js & Express.js
  • MongoDB & Mongoose
  • AWS S3 for image storage
  • JWT for authentication
  • Multer & Multer-S3 for file uploads

About

Twitter-like advance Backend

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published