Skip to content

This project is centered around the design, development, and organization of a full-stack web application.

Notifications You must be signed in to change notification settings

Justhiro55/ft_transcendence

Repository files navigation

ft_transcendence

A full-stack real-time multiplayer Pong game with AI opponents, tournaments, live chat, and user management system.

About

ft_transcendence is the final project of the 42 School Common Core curriculum. This project requires building a comprehensive web application using unfamiliar technologies, focusing on adaptability and problem-solving.

This implementation features:

  • Server-side Pong game with authoritative game logic
  • Microservices architecture (user-service, pingpong-service, livechat-service)
  • Real-time multiplayer via WebSockets
  • AI opponent with prediction algorithms
  • Tournament system with bracket management
  • Live chat with game invitations
  • OAuth 2.0 authentication (Google)
  • Two-Factor Authentication (2FA)
  • ELK Stack for logging (Elasticsearch, Logstash, Kibana)

Tech Stack

Frontend: TypeScript, Tailwind CSS, Vite

Backend: Node.js, Fastify, Prisma, SQLite

Infrastructure: Docker, Nginx, WebSocket, JWT

Getting Started

Prerequisites

  • Docker (20.10+)
  • Docker Compose (v2.0+)
  • Make

Setup

  1. Clone the repository

    git clone https://github.com/your-username/fttranscendence.git
    cd fttranscendence
  2. Create .env file

    A .env file is required in the project root. This file contains environment variables including:

    • Application ports
    • JWT secrets
    • Google OAuth credentials (required for OAuth login)
    • Database paths
    • ELK Stack passwords

    Note: The .env file is not included in the repository for security reasons. You must create it manually.

  3. Start the application

    make up

    This will:

    • Generate SSL certificates
    • Build Docker containers
    • Start all microservices
    • Initialize databases
  4. Access the application

Commands

make up      # Start all services
make down    # Stop all services
make re      # Restart all services
make clean   # Remove all Docker resources

Architecture

Nginx (Reverse Proxy)
  │
  ├── Frontend (SPA)
  │
  └── API Gateway
        ├── User Service (Authentication, Profiles, Friends)
        ├── PingPong Service (Game Engine, Tournaments, AI)
        └── LiveChat Service (Messaging, Invitations)

Each service has its own SQLite database. All services communicate via HTTPS and are monitored by the ELK Stack.

Features

User Management

  • User registration and login
  • Google OAuth 2.0 authentication
  • Two-Factor Authentication (2FA) with TOTP
  • User profiles with avatars
  • Friend system with online status
  • Match history and statistics

Game

  • Real-time multiplayer Pong via WebSocket
  • Server-side game logic (anti-cheat)
  • AI opponent with adjustable difficulty
  • Local multiplayer (same keyboard)

Tournaments

  • Create tournaments with 4, 8, or 16 players
  • Automatic bracket generation
  • Real-time match notifications
  • Tournament statistics

Chat

  • Direct messaging between users
  • Game invitations via chat
  • Block/unblock users
  • Online status indicators

Implemented Modules

This project implements 11 major module equivalents (7 required for completion):

Major Modules (10):

  1. Backend Framework (Fastify + Node.js)
  2. Standard User Management
  3. Remote Authentication (OAuth 2.0)
  4. Remote Players (WebSocket)
  5. Live Chat
  6. Two-Factor Authentication + JWT
  7. ELK Stack Integration
  8. Microservices Architecture
  9. Server-Side Pong with API
  10. AI Opponent

Minor Modules (2 = 1 Major):

  • Frontend Framework (Tailwind CSS)
  • Database (SQLite + Prisma)

Project Structure

ft_transcendence/
├── frontend/              # TypeScript SPA with Tailwind CSS
├── user-service/          # User management microservice
├── pingpong-service/      # Game engine microservice
├── livechat-service/      # Chat microservice
├── gateway/               # API Gateway
├── reverse-proxy/         # Nginx configuration
├── elk/                   # ELK Stack setup
│   ├── elasticsearch/
│   ├── kibana/
│   └── logstash/
├── docker-compose.yml
├── Makefile
└── .env                   # Required (not in repository)

Security

  • HTTPS with TLS encryption
  • Password hashing with bcrypt
  • JWT authentication (RS256)
  • Two-Factor Authentication (2FA)
  • SQL injection prevention
  • XSS protection
  • Rate limiting
  • CORS configuration

License

This project is part of the 42 School curriculum.

About

This project is centered around the design, development, and organization of a full-stack web application.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 5