Author: Muhammad Shoaib Ahmad GitHub: https://github.com/shoaib1522 University: University (Data Science) - Semester 7 Course: Big Data Analytics Lab Project Type: Capstone Project - Polyglot Persistence Demonstration
A complete full-stack Twitter clone demonstrating modern web application architecture and polyglot persistence concepts. This project showcases how to build a production-like social media platform using industry-standard technologies.
Key Features:
- User authentication and profile management
- Tweet creation, liking, and retweeting
- Follow/unfollow functionality
- Real-time updates and notifications
- Complete database persistence with PostgreSQL
- GraphQL API with proper type definitions
- Responsive React frontend with Next.js
This project demonstrates using the right database for the right job:
- PostgreSQL - Relational database for structured user data, tweets, follows, and likes
- ACID compliance for data integrity
- Efficient SQL queries for analytics
- Proper normalization and relationships
- Frontend Layer: React + Next.js for dynamic user interface
- API Layer: Node.js + Express + GraphQL for flexible queries
- Database Layer: PostgreSQL for persistent, structured data storage
- Containerization: Docker for consistent deployment across environments
- Stateless API design (horizontal scalability)
- Connection pooling for database efficiency
- GraphQL for optimized data fetching
- Separation of concerns between frontend and backend
- Docker and Docker Compose installed
- Node.js v10+ (for local development)
- Git
-
Clone the repository:
git clone https://github.com/shoaib1522/twitter-app.git cd twitter-app -
Start with Docker Compose:
docker-compose up --build
-
Access the application:
Frontend: http://localhost:3000 API: http://localhost:4100 Database: localhost:5432 -
Database credentials:
User: postgres Password: postgres Database: postgres
Environment files are pre-configured. Configuration is managed through Docker.
Start all services with Docker Compose:
docker-compose up --buildThis will:
- Start PostgreSQL database (port 5432)
- Start Node.js API server (port 4100)
- Start React frontend (port 3000)
Access the app at http://localhost:3000
To initialize the database with tables and seed data:
docker-compose exec api sh -c "cd packages/server && yarn reset-db"Sign up for a new account:
- Email: [email protected]
- Password: password123
Features to test:
- Create a tweet
- Like/retweet posts
- Follow other users
- View user profiles
- Browse home feed
Connect to PostgreSQL and query data:
docker-compose exec db psql -U postgres -d postgresSample queries:
-- View all users
SELECT id, name, email, created_at FROM users LIMIT 10;
-- Count total tweets
SELECT COUNT(*) as total_tweets FROM tweets;
-- See latest tweets
SELECT id, user_id, content, created_at FROM tweets
ORDER BY created_at DESC LIMIT 5;
-- User follow relationships
SELECT follower_id, following_id FROM follows LIMIT 10;
-- Count likes per tweet
SELECT tweet_id, COUNT(*) as like_count FROM likes
GROUP BY tweet_id ORDER BY like_count DESC LIMIT 5;
-- Exit
\q- React.js - UI library
- Next.js - React framework with SSR
- Apollo Client - GraphQL client
- styled-jsx - CSS-in-JS styling
- Adorable Avatars - User avatar generation
- Node.js - JavaScript runtime
- Express.js - Web server framework
- Apollo Server - GraphQL server
- Knex.js - SQL query builder and migrations
- PostgreSQL - Relational database
- GraphQL - Query language for APIs
- Docker - Container platform
- Docker Compose - Multi-container orchestration
- PostgreSQL Alpine - Lightweight database image
twitter-app/
βββ packages/
β βββ client/ (React/Next.js Frontend)
β β βββ pages/ (Next.js pages)
β β βββ components/ (React components)
β β βββ queries/ (GraphQL queries)
β β βββ lib/ (Utilities)
β β βββ server/ (Express server for SSR)
β β
β βββ server/ (Node.js/Express Backend)
β βββ src/
β β βββ typedefs/ (GraphQL type definitions)
β β βββ resolvers/ (GraphQL resolvers)
β β βββ db/ (Database configuration)
β β βββ migrations/ (Database migrations)
β β βββ seeds/ (Database seed data)
β βββ package.json
β βββ knexfile.js (Knex.js configuration)
β
βββ docker-compose.yml (Container orchestration)
βββ Dockerfile (Multi-stage build)
βββ README.md (This file)
βββ TWITTER_SETUP_GUIDE.md (Detailed setup guide)
- Full-Stack Development - Frontend + Backend + Database integration
- RESTful/GraphQL APIs - Modern API design patterns
- Database Design - Relational modeling and SQL
- Authentication - User login and session management
- Real-time Features - WebSocket and live updates
- Polyglot Persistence - Using appropriate database technologies
- Scalability - Horizontal and vertical scaling strategies
- Data Integrity - ACID properties in PostgreSQL
- Query Optimization - Efficient data retrieval patterns
- Data Relationships - One-to-Many, Many-to-Many patterns
Show the working application:
# Terminal 1: Start the application
docker-compose up --build
# Terminal 2: Access the database
docker-compose exec db psql -U postgres -d postgres
# In browser: http://localhost:3000
# Interact with the app - signup, create tweets, follow usersTalking points:
- "This demonstrates a production-ready full-stack application"
- "React frontend communicates with GraphQL API"
- "PostgreSQL stores all data persistently"
- "Docker ensures consistency across environments"
- "Real-time updates via WebSocket subscriptions"
- "Polyglot persistence principle: right tool for the job"
All dependencies are managed by Docker. The following are installed automatically:
- Node.js 10.15.0 (Alpine)
- PostgreSQL 11.1 (Alpine)
- npm/yarn package managers
- All npm packages as listed in package.json files
# Find process using port 3000
netstat -ano | findstr :3000
# Kill the process
taskkill /PID <PID> /F# Restart the database
docker-compose restart db
# Or complete reset
docker-compose down -v
docker-compose up --build# Check logs
docker-compose logs api
# Restart API
docker-compose restart api- Next.js Documentation
- Apollo Client Documentation
- PostgreSQL Documentation
- Docker Documentation
- GraphQL Documentation
Muhammad Shoaib Ahmad
- GitHub: https://github.com/shoaib1522
- Email: [email protected]
- University: University (Data Science)
Original project by Rafael Almeida. Modified and enhanced for Big Data Analytics Lab capstone project.
All rights reserved for Twitter by Twitter, Inc.
Last Updated: December 11, 2025 Status: β Production Ready for Demonstration
