Skip to content

jainavas/transcendence

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

48 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

ft_transcendence

ft_transcendence Version Docker

TypeScript JavaScript HTML5 CSS3 TailwindCSS NodeJS Fastify SQLite Babylon.js Grafana Prometheus Webpack

Surprise.

This project involves undertaking tasks you have never done before.
Remember the beginning of your journey in computer science.
Look at you now; it's time to shine!

2P Game Mode 4P Game Mode
Dashboard Stats Dashboard Overview

ft_transcendence is the final project of the 42 School Common Core curriculum. It's a comprehensive web application that recreates the classic Pong game with modern web technologies, real-time multiplayer capabilities, and advanced features.

๐ŸŽฏ Project Overview

This project is about creating a single-page application (SPA) for hosting Pong contests with friends. The emphasis is on learning new technologies and adapting to unfamiliar frameworks, simulating real-world development scenarios.

๐ŸŒŸ Core Features

  • ๐Ÿ“ 4 side gamemode - Play against 3 friends
  • ๐Ÿ† Tournament system - Organize and participate in competitive tournaments
  • ๐Ÿ‘ฅ User management with Google Sign-In - Registration, authentication, and user profiles
  • 2-factor authentication - Enhanced security with two-factor verification -๏ฟฝ๐Ÿ•น๏ธ 3D Interactive Gameplay - Communicate with other players
  • ๐Ÿ“Š Statistics & leaderboards - Track your progress and rankings
  • ๐Ÿ”’ Security features - HTTPS, input validation, and secure authentication

๐Ÿ—๏ธ Architecture

Mandatory Requirements

  • Frontend: TypeScript-based single-page application
  • Backend: Pure PHP (without frameworks) or chosen framework module
  • Database: Optional, with specific module requirements if used
  • Browser Support: Latest stable Mozilla Firefox (others supported)
  • Containerization: Docker with single command deployment
  • Security: HTTPS, SQL injection/XSS protection, password hashing

Technology Stack

The project allows for various technology combinations through modules:

  • Backend Options: PHP (default), Fastify with Node.js
  • Frontend Options: TypeScript (default), Tailwind CSS
  • Database Options: SQLite (when database module is selected)
  • Monitoring: Grafana, Prometheus for system monitoring and metrics
  • Security: 2-factor authentication for enhanced user security
  • Advanced Features: Blockchain integration (Avalanche), 3D graphics (Babylon.js)

๐Ÿš€ Quick Start

Prerequisites

  • Docker and Docker Compose
  • Modern web browser (Firefox recommended)
  • Git

Installation

  1. Clone the repository

    git clone https://github.com/jainavas/transcendence.git
    cd transcendence
  2. Set up environment variables

    # Copy and configure environment files
    cp .env.example .env
    # Edit .env with your configurations
  3. Launch with Docker

    # Build and start all services
    docker-compose up --build
    
    # Or use the provided script (if available)
    ./start.sh
  4. Access the application

    • HTTP: http://localhost:8080
    • HTTPS: https://localhost:8443

Environment Configuration

Create a .env file with the following variables:

# Database Configuration
DB_HOST=postgres
DB_PORT=5432
DB_USER=transcendence
DB_PASSWORD=your_secure_password
DB_NAME=transcendence

# Application Settings
APP_HOST=localhost
APP_PORT=3000
APP_ENV=development

# 42 OAuth (if using remote authentication module)
FORTYTWO_APP_ID=your_42_app_id
FORTYTWO_APP_SECRET=your_42_app_secret
CALLBACK_URL=http://localhost:3000/auth/callback

# JWT Configuration (if using JWT module)
JWT_SECRET=your_jwt_secret
JWT_EXPIRATION=3600

# Additional module configurations...

๐ŸŽฎ Game Features

Basic Pong Gameplay

  • Two-player local matches using the same keyboard
  • Tournament system with multiple players
  • Matchmaking system for organizing games
  • Consistent game rules and paddle speeds

Advanced Features (Module-dependent)

  • Remote Players: Play with friends on different computers
  • Multiplayer: Support for more than 2 players simultaneously
  • AI Opponent: Play against artificial intelligence
  • Custom Games: Additional games beyond Pong
  • 3D Graphics: Enhanced visual experience with Babylon.js

๐Ÿ† Module System

The project uses a modular approach where you must implement 7 major modules to achieve 100% completion. Modules are categorized as:

Major Modules (10 points each)
  • Web Framework: Backend framework implementation โœ…
  • User Management: Advanced authentication and user features
  • Multiplayer for more than 2: Local or online multiplayer with +2 player โœ…
  • Remote Auth: Google Sign-In auth โœ…
  • AI Integration: Artificial intelligence opponents โœ…
  • Infrastructure setup for log management: Grafana and Prometheus monitoring โœ…
  • Microservices: Backend architecture as microservices
  • Advanced Graphics: 3D rendering with modern techniques โœ…
  • Internationalization: i18n multi-language support โœ…
Minor Modules (5 points each)
  • Web Framework: Frontend framework implementation โœ…
  • Database Integration: Data persistence layer โœ…
  • Game Customization: Enhanced gameplay options โœ…
  • User Stats and Charts: User-friendly dashboard with stats of previous matches โœ…
  • Monitoring: System health and performance tracking โœ…
  • Accessibility: Support for disabled users
  • Multi-language: Internationalization support โœ…
  • Multi-browser compatibility: Multiple browser support โœ…

Note: Two minor modules count as one major module

๐Ÿ”’ Security Implementation

Security is a core requirement with the following mandatory features:

  • โœ… Password Hashing: Secure password storage
  • โœ… SQL Injection Protection: Parameterized queries and input validation
  • โœ… XSS Prevention: Output encoding and content security policies
  • โœ… HTTPS Enforcement: Encrypted connections (WSS for WebSockets)
  • โœ… Input Validation: Both client and server-side validation
  • โœ… Environment Security: Secrets in .env files, excluded from git

๐Ÿ“ Project Structure

transcendence/
โ”œโ”€โ”€ backend
โ”‚ย ย  โ”œโ”€โ”€ app
โ”‚ย ย  โ”œโ”€โ”€ Dockerfile
โ”‚ย ย  โ””โ”€โ”€ package.json
โ”œโ”€โ”€ data
โ”‚ย ย  โ””โ”€โ”€ database.sqlite
โ”œโ”€โ”€ docker-compose.yml
โ”œโ”€โ”€ frontend
โ”‚ย ย  โ”œโ”€โ”€ dashboard.html
โ”‚ย ย  โ”œโ”€โ”€ dashboard.ts
โ”‚ย ย  โ”œโ”€โ”€ dist
โ”‚ย ย  โ”œโ”€โ”€ Dockerfile
โ”‚ย ย  โ”œโ”€โ”€ env-config.js
โ”‚ย ย  โ”œโ”€โ”€ env-types.js
โ”‚ย ย  โ”œโ”€โ”€ env-types.ts
โ”‚ย ย  โ”œโ”€โ”€ index.html
โ”‚ย ย  โ”œโ”€โ”€ index.ts
โ”‚ย ย  โ”œโ”€โ”€ main.ts
โ”‚ย ย  โ”œโ”€โ”€ package.json
โ”‚ย ย  โ”œโ”€โ”€ pong
โ”‚ย ย  โ”œโ”€โ”€ pong.html
โ”‚ย ย  โ”œโ”€โ”€ postcss.config.js
โ”‚ย ย  โ”œโ”€โ”€ redirect.html
โ”‚ย ย  โ”œโ”€โ”€ styles.css
โ”‚ย ย  โ”œโ”€โ”€ tailwind.config.js
โ”‚ย ย  โ”œโ”€โ”€ textures
โ”‚ย ย  โ”œโ”€โ”€ tsconfig.json
โ”‚ย ย  โ””โ”€โ”€ webpack.config.js
โ”œโ”€โ”€ Makefile
โ”œโ”€โ”€ package.json
โ”œโ”€โ”€ package-lock.json
โ””โ”€โ”€ README.md

๐Ÿ› ๏ธ Development

Available Scripts

# Start the application
make up

# Clean up containers and volumes
make clean

# View logs
docker-compose logs -f [service_name]

๐Ÿค Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Code Style

  • Follow TypeScript/JavaScript best practices
  • Use consistent indentation (2 spaces)
  • Write meaningful commit messages
  • Document complex functions and modules

๐Ÿ“‹ Project Requirements Checklist

Mandatory Part โœ…

  • Single-page application with browser navigation
  • Real-time multiplayer Pong game
  • Tournament system with matchmaking
  • User registration and authentication
  • Security implementations (HTTPS, validation, hashing)
  • Docker containerization

Module Implementation

  • 7 Major modules selected and implemented
  • Module interdependencies resolved
  • All chosen modules fully functional

๐Ÿ› Troubleshooting

Common Issues

Docker container won't start

# Check Docker daemon
sudo systemctl status docker

# Check port conflicts
sudo netstat -tulpn | grep :8080

# Reset containers
docker-compose down -v
docker-compose up --build

Database connection issues

# Verify database container
docker-compose ps

# Check database logs
docker-compose logs postgres

# Reset database
docker-compose down -v

Frontend not loading

  • Verify HTTPS certificates
  • Check browser console for errors
  • Ensure all environment variables are set

๐Ÿ“– Resources

๐Ÿ“„ License

This project is part of the 42 School curriculum. Please respect the academic integrity policies of your institution.

๐Ÿ‘ฅ Authors

๐Ÿ™ Acknowledgments

  • 42 School for the project specifications
  • The amazing Pong game that started it all
  • The open-source community for the tools and frameworks

Note: This project is designed to challenge you with unfamiliar technologies. The goal is not to create a portfolio piece, but to demonstrate your ability to adapt and learn new technologies quickly - a skill essential in your programming career.

Version 16.1 - Subject specifications may evolve over time

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •