Skip to content

shoaib1522/twitter-app

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

145 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Twitter Fullstack Clone - Big Data Analytics Lab Project

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


πŸ“‹ Project Overview

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

Preview


🎯 Big Data & Architecture Concepts Demonstrated

Polyglot Persistence

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

Full-Stack Architecture

  • 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

Scalability Patterns

  • Stateless API design (horizontal scalability)
  • Connection pooling for database efficiency
  • GraphQL for optimized data fetching
  • Separation of concerns between frontend and backend

πŸš€ Quick Start

Prerequisites

  • Docker and Docker Compose installed
  • Node.js v10+ (for local development)
  • Git

Installation & Running

  1. Clone the repository:

    git clone https://github.com/shoaib1522/twitter-app.git
    cd twitter-app
  2. Start with Docker Compose:

    docker-compose up --build
  3. Access the application:

    Frontend: http://localhost:3000
    API: http://localhost:4100
    Database: localhost:5432
    
  4. Database credentials:

    User: postgres
    Password: postgres
    Database: postgres
    

πŸ‹ Local Development

First-time Setup

Environment files are pre-configured. Configuration is managed through Docker.

Running the Project

Start all services with Docker Compose:

docker-compose up --build

This 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

Database Setup

To initialize the database with tables and seed data:

docker-compose exec api sh -c "cd packages/server && yarn reset-db"

Testing the Application

Sign up for a new account:

Features to test:

  • Create a tweet
  • Like/retweet posts
  • Follow other users
  • View user profiles
  • Browse home feed

πŸ’Ύ Database Inspection

Connect to PostgreSQL and query data:

docker-compose exec db psql -U postgres -d postgres

Sample 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

πŸ›  Tech Stack

Frontend

  • 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

Backend

  • 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

Infrastructure

  • Docker - Container platform
  • Docker Compose - Multi-container orchestration
  • PostgreSQL Alpine - Lightweight database image

πŸ“Š Project Structure

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)

πŸŽ“ What This Project Teaches

Software Engineering Concepts

  1. Full-Stack Development - Frontend + Backend + Database integration
  2. RESTful/GraphQL APIs - Modern API design patterns
  3. Database Design - Relational modeling and SQL
  4. Authentication - User login and session management
  5. Real-time Features - WebSocket and live updates

Big Data Concepts

  1. Polyglot Persistence - Using appropriate database technologies
  2. Scalability - Horizontal and vertical scaling strategies
  3. Data Integrity - ACID properties in PostgreSQL
  4. Query Optimization - Efficient data retrieval patterns
  5. Data Relationships - One-to-Many, Many-to-Many patterns

πŸ” Demonstration for Professor

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 users

Talking 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"

πŸ“ Requirements & Dependencies

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

πŸ› Troubleshooting

Port already in use

# Find process using port 3000
netstat -ano | findstr :3000
# Kill the process
taskkill /PID <PID> /F

Database connection issues

# Restart the database
docker-compose restart db

# Or complete reset
docker-compose down -v
docker-compose up --build

API not responding

# Check logs
docker-compose logs api

# Restart API
docker-compose restart api

πŸ“š Additional Resources


πŸ‘€ Author

Muhammad Shoaib Ahmad


πŸ“„ License

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

About

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

Topics

Resources

License

Security policy

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages