Skip to content

harshalsakhare2305/Twitter_Server

Repository files navigation

🐦 Twitter Clone β€” Backend Server

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.


πŸ“Œ Table of Contents


✨ Features

  • πŸ” 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

πŸ› οΈ Tech Stack

TypeScript Node.js GraphQL Express PostgreSQL Prisma Redis AWS

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

πŸ—οΈ Architecture

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

πŸš€ Getting Started

Prerequisites

  • Node.js v18+
  • PostgreSQL
  • Redis
  • AWS S3 Bucket

Installation

# 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 dev

πŸ”‘ Environment Variables

Create 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_name

πŸ“‘ API Overview

This 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

About

🐦 Twitter/X Clone backend server built with TypeScript, GraphQL, Prisma and PostgreSQL β€” featuring JWT authentication, Redis caching and AWS S3 image uploads.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors