Skip to content

Tsunghao-C/ft_Transcendence

Repository files navigation

ft_Transcendence

Project Objectives

Developing a web game Pong from scratch including the following features:

  1. Had basic user management systems for users to register, 2FA validate id, customize user settings.
  2. Utilised Websocket to allow users to do live chat with other users and play games remotely.
  3. Supported different game modes like remote PVP, local PVP, single player vs computer(AI).
  4. Adopted Single page Access (SPA) for better UX in the frontend.
  5. Implemented WAF firewall ahead of Nginx to prevent malicious requests. Used Vault to store sensitive credentials like admin user keys.
  6. Pre-scripted ELK stack deployment in a isolated docker environment, including necessary TLS, SSL settings and logs lifetime management policies.
  7. Added automated unit tests at launch time to check key feature healthiness.

Pong Game Project System Diagram

Alt text

Quick Start

  1. Clone the repo to your local machine
git clone <repository-url>
cd ft_Transcendence
  1. Setup necessary credentials and launch
    1. generate CA and certificates for ELK stack
make certs 
# It will generate CA and SSL signed by CA in pong-game/monitoring/elk/certs
    1. generate .env credentials
make env 
# It will create .env file based on .env.example file, or you can manually create yourself
    1. docker command to launch all services
docker compose up --build # Added -d flag if you want to have all logs in the background

You can also simply use makefile cmd to build run and check automatically

make # It will do step 1 to 3 and then do unit tests in the end
  1. Other usefull make commands
  • To build and run the program without checking
make go
  • To stop and remvoe services and credentials
make clean # It will delete the .env
  • To rebuild and check
make re
  • To go inside a specific container using bash
make in ${service_name} # equals to do "docker exec -it ${service_name} bash"
  • To simply run checks again
make check # In case you only change files that is run by cgi, you don't need to rebuild
  • To deeply clean all the cached images in local host
make kill # It will kill every cached images even in ~/.docker/buildx

Development Access Points

External

Internal access port

  • Backend (django and its services): 8004 (api), 8001 (ws)
  • Postgres DB: 5434
  • redis: 6379
  • Elasticsearch: 9200
  • Logstash: 5044
  • Prometheus: 9090
  • Grafana: 3001
  • node-exporter: 9100

Team Development Guidelines

Backend (Game + User Management) Team

Frontend Team

Monitoring Team

  • Work in monitoring/ directory
  • Configure Prometheus in monitoring/prometheus/
  • Set up Grafana dashboards in monitoring/grafana/
  • Configure ELK stack in monitoring/elk/

Security Team

  • Work in security/ directory

tests

  • Put all the unit test scripts in tests/ directory

Notes

  1. To clear everything in docker docker stop $(docker ps -qa); docker rm $(docker ps -qa); docker rmi -f $(docker images -qa); docker volume rm $(docker volume ls -q); docker network rm $(docker network ls -q) 2>/dev/null

  2. To test XXS and see WAF audit log, do curl -k "https://localhost:8443/test-waf?input=<script>alert(1)</script>"

About

Developing a web game Pong from scratch

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 5