A scalable Twitter/X Clone backend server built with TypeScript, GraphQL, Prisma, PostgreSQL and Redis β featuring JWT authentication, AWS S3 file uploads and a production-ready GraphQL API.
- π JWT Authentication β Secure token-based login and session management
- π Tweet CRUD β Create, read, update and delete tweets
- π₯ Follow / Unfollow β User follow system with feed generation
- πΌοΈ Image Uploads β AWS S3 integration with pre-signed URLs
- β‘ Redis Caching β Session and feed caching for high performance
- π GraphQL API β Flexible and type-safe API with Apollo Server
- ποΈ PostgreSQL + Prisma β Relational database with type-safe ORM
| Layer | Technology |
|---|---|
| Language | TypeScript |
| Runtime | Node.js |
| Framework | Express.js v5 |
| API | GraphQL (Apollo Server) |
| ORM | Prisma v7 |
| Database | PostgreSQL |
| Cache | Redis (ioredis) |
| Auth | JWT (jsonwebtoken) |
| File Storage | AWS S3 (pre-signed URLs) |
| Build Tool | tsc-watch + nodemon |
Twitter_Server/
βββ src/
β βββ app/ # Express + Apollo Server setup
β βββ graphql/ # Type definitions & resolvers
β βββ services/ # Business logic layer
β βββ index.ts # Entry point
βββ prisma/
β βββ schema.prisma # Database schema
βββ tsconfig.json
βββ package.json
- Node.js v18+
- PostgreSQL
- Redis
- AWS S3 Bucket
# Clone the repository
git clone https://github.com/harshalsakhare2305/Twitter_Server.git
cd Twitter_Server
# Install dependencies
yarn install
# Generate Prisma client
npx prisma generate
# Run database migrations
npx prisma migrate dev
# Start development server
yarn devCreate a .env file in the root directory:
DATABASE_URL=postgresql://user:password@localhost:5432/twitter_db
REDIS_URL=redis://localhost:6379
JWT_SECRET=your_jwt_secret
AWS_ACCESS_KEY_ID=your_aws_access_key
AWS_SECRET_ACCESS_KEY=your_aws_secret_key
AWS_REGION=your_aws_region
AWS_S3_BUCKET=your_s3_bucket_nameThis server exposes a GraphQL API at /graphql.
Key Queries & Mutations:
| Operation | Type | Description |
|---|---|---|
getUser |
Query | Fetch user profile |
getTweets |
Query | Fetch tweet feed |
createTweet |
Mutation | Post a new tweet |
followUser |
Mutation | Follow a user |
unfollowUser |
Mutation | Unfollow a user |
getSignedURL |
Query | Get AWS S3 pre-signed URL for image upload |