Skip to content

MKcodes2/PongJam

ย 
ย 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

PongJam Logo

๐Ÿ•น๏ธ A realtime web-based pong game, as our graduation project at 42 ๐ŸŽ“

๐Ÿ‘ฅ Team members & collaboration:

  • ๐Ÿ› ๏ธ Ramy: Team & Project Management, Devops, containerization & overall infrastructure
  • ๐Ÿ” Bori: User Management, authentication (2FA & remote), database & microservices for the backend
  • ๐ŸŽฎ Alex: Game component with 3D graphics & AI opponent
  • ๐ŸŽจ Mary Kate: frontend & overall design of the platform, creation of this README
  • ๐Ÿ’ฌ Timo: live-chat component (tournament & private chat)

๐Ÿ“ Description

The goal of this project is to build a modern web platform for the legendary Pong game ๐Ÿ“ โ€” but with a twist: multiplayer, tournaments, chat, 3D graphics, and even AI opponents." ๐Ÿš€

In simpler words: imagine gathering with friends, entering your nicknames, and playing Pong directly in your browser ๐ŸŽฎ โ€” not only one-on-one on the same keyboard, but also remotely against players online, or even against a computer-controlled opponent (AI) ๐Ÿค–. The platform keeps track of who plays against whom, organizes tournaments ๐Ÿ†, and lets you chat live ๐Ÿ’ฌ while the games unfold.

๐Ÿ’ป Behind the scenes, we combined a frontend in TypeScript + TailwindCSS with a backend of microservices (for authentication, matchmaking, chat, etc.) powered by Fastify and SQLite. For security, we added Google login, 2-Factor Authentication, and JWT tokens, while monitoring is handled through Prometheus & Grafana. The game itself is enhanced with 3D visuals (BabylonJS) that give a fresh look to the classic pong.

โœจ In its final form, this project is not just โ€œPongโ€ โ€” itโ€™s a full multiplayer gaming experience on the web, reimagined with todayโ€™s technologies, AI challenges, and 3D design. โœจ

๐ŸŽฏ Main Components

๐Ÿ‘ค User Management

๐Ÿ” Registration & Log In

Registration demo
User can ๐Ÿ’โ€โ™€๏ธ :
โœ”๏ธ register with email & password
โœ”๏ธ Log in with credentials
โœ”๏ธ Log in with Google
โœ”๏ธ Recover account if password lost
โœ”๏ธ Log out whenever they wish to

โš™๏ธ User Settings

Registration demo
User can ๐Ÿ’โ€โ™€๏ธ :
โœ”๏ธ Update their profile picture
โœ”๏ธ Change username
โœ”๏ธ Change password
โœ”๏ธ Activate 2-Factor Authentication
ย ย ย ย ย โ€ข either with email code, or
ย ย ย ย ย โ€ข authenticator app with QRcode

๐Ÿ‘ค Profile Information & Matches History

Registration demo
User can ๐Ÿ’โ€โ™€๏ธ :
โœ”๏ธ See their history of matches & tournaments, in their profile

๐Ÿค Friends Management & ๐Ÿ”Ž User Search

User Search demo
Users can ๐Ÿ’โ€โ™€๏ธ :
โœ”๏ธ Search for other users
โœ”๏ธ View other users' profile information
โœ”๏ธ Send friend requests
โœ”๏ธ Accept or reject friend requests
โœ”๏ธ Unfriend other users
โœ”๏ธ see if their friends are Online or Offline

๐Ÿ“ THE GAME

๐Ÿ’โ€โ™€๏ธ Can be as simple as:

simple_game_example.mov

๐Ÿคฏ Or, as complicated as:

extreme_game_example.mov

1๏ธโƒฃ Ready-to-Play Games ๐ŸŽฎ

When the user first enters the platform, they are welcomed by the Main Page, where they can choose from the following predefined game modes to play directly:

ready-to-play

  • โŒจ๏ธ 1 vs 1 (same keyboard) โ€“ Two players share the same device: one uses the W A S D keys, the other uses the arrow keys.
  • ๐Ÿค– Against AI โ€“ Play a solo 1 vs 1 match against the AI. The game starts at Level 1, and each victory unlocks the next, more challenging level.
  • ๐Ÿ‘ฅ 2 Players (Online) โ€“ Join the matchmaking queue to play a 1 vs 1 match with another player online.
  • ๐Ÿ‘ฅ๐Ÿ‘ฅ 4 Players (Online) โ€“ Enter the 4-player queue; once three other players join, the game starts automatically.

2๏ธโƒฃ Custom Games ๐Ÿ–Œ๏ธ

Alternatively, they can click the Custom Game button on the Main Page (see above๊œ›) to create a personalized match by adjusting the available game settings:

custom_game_settings

Using this Custom Game panel, users can fine-tune nearly every gameplay aspect:

  • โš™๏ธ Players: Choose the number of physical and AI players.
  • ๐Ÿง  AI Difficulty: Adjust from easy to hard for progressive challenge.
  • ๐Ÿ•’ Game Rules: Set a time or score limit to end the match.
  • ๐Ÿงฑ Environment: Enable obstacle mode for extra dynamics.
  • โšก Gameplay Options: Decide whether players can lose points, get replaced by AI if disconnected, or be removed at zero score.
  • ๐ŸŒ Physics: Activate Kicker Mode to apply gravity-based movement to the ball.

๐Ÿ’ก With all these combinations, users can create hundreds of unique matchesโ€”from quick duels to chaotic multi-ball battles.

3๏ธโƒฃ TOURNAMENTS ๐Ÿ†

tournaments

The Tournaments module enables users to create, configure, and manage competitive matches:

  • ๐Ÿ—๏ธ Creation: Define the tournament name and choose the victory condition (time-based or score-based).
  • ๐Ÿ‘‘ Administration: The creator acts as the admin, managing invitations and controlling the tournamentโ€™s start.
  • โš”๏ธ Gameplay: Each player faces all other participants in one-on-one matches. The player with the highest cumulative score across all matches wins.
  • ๐Ÿ“‹ Overview: The Tournaments page provides filters to view:
    • all existing tournaments,
    • those the user participates in, or
    • those managed by the user.

๐ŸŽฎ 3D Gameplay with BabylonJS

The Pong arena comes alive through BabylonJS, a powerful 3D engine that transforms the classic game into a modern, immersive experience.
Beyond the dynamic paddles, ball, and light effects, players find themselves in a 360ยฐ interactive space ๐ŸŒŒ โ€” they can freely rotate the camera, explore different angles, and play from any perspective they like; as shown in the following video:

rotation.mov

๐Ÿ’ฌ Live Chat

live_chat

Our platform features a dynamic chat system supporting both private conversations ๐Ÿค and tournament-wide discussions ๐Ÿ†.

  • Private Chats ๐Ÿ’Œ
    • Send direct messages between users.
    • View the recipientโ€™s profile directly from the chat window ๐Ÿ‘ค.
    • Block or unblock other users ๐Ÿšซ.
    • Invite directly to a 1v1 game ๐ŸŽฎ โ€” challenge your friend instantly without leaving the chat!
  • Tournament Chats ๐Ÿ—จ๏ธ
    • All tournament participants can communicate in a shared chat room.
    • Navigate directly to the tournament page from within the chat ๐Ÿ“.
    • View the profiles of other participants easily ๐Ÿ‘ฅ.

Each chat box can be minimized to the bottom-right corner ๐Ÿ”ฝ or expanded again anytime โ†ฉ๏ธ, allowing you to stay connected while continuing your game.

๐Ÿ› ๏ธ Backend & Monitoring system

๐Ÿ”ฉ Our backend follows a microservices architecture, separating the main application logic into smaller, independent services โ€” Auth, Match, and Chat.
This design allows each service to be developed, tested, deployed, and scaled independently, improving maintainability and fault isolation. Using SQLite for each microservice provides lightweight persistence with minimal setup overhead, making it ideal for containerized environments and local development.

๐Ÿ“Š ๐Ÿง For monitoring and observability, we integrated a complete stack with Prometheus, Grafana, Node Exporter, and Nginx Exporter.

  • Prometheus collects real-time metrics from all services,
  • Grafana visualizes them through interactive dashboards, and
  • the exporters ensure both system-level and Nginx-specific performance data are continuously available.

This setup gives us a clear view of system health, traffic, and resource usage โ€” helping detect issues early and ensure smooth operation.

๐Ÿ‘ˆ Expand here to see detailed information about the configuration of the core application services & infrastructure ๐Ÿ”

๐ŸŽฏ Core Application Services

  1. Auth Service
  • Location: ./backend/auth
  • Port: 8081
  • Protocol: HTTP
  • Database: SQLite at /app/db/auth.db
  1. Match Service
  • Location: ./backend/match
  • Port: 8082
  • Protocol: HTTP
  • Database: SQLite at /app/db/match.db
  • ๐Ÿ” API docs at: https://localhost/match/docs
  1. Chat Service
  • Location: ./backend/chat
  • Port: 8083
  • Protocol: HTTP
  • Database: SQLite at /app/db/chat.db
  • ๐Ÿ” API docs at: https://localhost/chat/docs
  1. Frontend Service
  • Location: ./frontend
  • Port: 3000
  • Protocol: HTTP

โš™๏ธ Infrastructure Services

  1. Nginx
  • Location: ./infra/nginx
  • Ports:
  • 80 (HTTP)
  • 443 (HTTPS)
  • Protocol: HTTP/HTTPS
  1. Nginx Exporter
  • Image: nginx/nginx-prometheus-exporter
  • Port: 9113
  • Protocol: HTTP
  • ๐Ÿ” Access: http://localhost:9113/metrics
  1. Node Exporter
  • Image: prom/node-exporter
  • Port: 9100
  • Protocol: HTTP
  • ๐Ÿ” Access: http://localhost:9100/metrics
  1. Prometheus
  • Image: prom/prometheus
  • Port: 9090
  • Protocol: HTTP
  • ๐Ÿ” Access: http://localhost:9090
  1. Grafana
  • Image: grafana/grafana
  • Port: 3001
  • Protocol: HTTP
  • ๐Ÿ” Access: http://localhost:3001

๐Ÿ›œ Network Configuration

All services are connected through a bridge network named app-network

๐Ÿ’พ Volume Mounts

Common volumes shared across services:

  • ./certs (SSL certificates)
  • ./uploads (file storage)
  • ./db (database files)

Each service has its own source code mounted from its respective directory

โš™๏ธ Installation

  1. Clone the repository:
git clone https://github.com/MKcodes2/PongJam
  1. Navigate to the project's directory:
cd PongJam

[โ• Make sure you have Docker Docker installed, so that you can move on to...]

  1. Boot everything up with the help of our magic Makefile:
make up

๐Ÿ And if everything boots correctly the output should finish as follows: makeup_succesful_output

๐Ÿš€ Usage

Now you can go to any broswer and access the website by simply typing:

broswer_image

which should serve you the following main page:

main_page_video

โ—๏ธ At this point though, you would only be able to see the main pages (Welcome, Log In & Sign Up pages) without being able to actually sign up & access the game.

๐Ÿ’โ€โ™€๏ธ Let's clarify now WHY's that and what you can do to fully browse the website... ๐Ÿ’ช

๐Ÿ”‘ The importance of the missing SECRETS in the .env file

When you first do make up this generates some certificates (server.crt, server.csr, server.key) and the following .env file:

env_file

This .env file is considered "enough" for the containers to boot up and the frontend to be accessed at https://localhost. โ—๏ธ However, it uses placeholder values (the ones in the purple boxes above) like your-secret-key-here, which means the core functionality (registration, login, SMS, Google OAuth, etc) will not work until they are replaced with real credentials. โ—๏ธโ—๏ธ

๐Ÿ”Ž Explanation of the necessary Secrets & How they can be obtained:

Secrets Functionality How to Obtain
SECRET,
COOKIE_SECRET,
REFRESH_SECRET
Are used to generate and verify JWTs or session cookies. Without real values, authentication tokens will either fail to generate or wonโ€™t validate. You can generate your own with openssl rand -hex 32.
GOOGLE_PASS,
GOOGLE_ID,
GOOGLE_SECRET
Are required if the platform supports Google OAuth. Without them, Google login wonโ€™t work at all. GOOGLE_ID, GOOGLE_SECRET: Obtain from Google Cloud Console.
GOOGLE_PASS: Generate from your Google Account โ†’ Security โ†’ App Passwords.
INFOBIP_ID,
INFOBIP_TOKEN,
INFOBIP_SENDER
Are for SMS verification (or similar). Without them, phone-based 2FA or notifications wonโ€™t work. You can obtain from your Infobip Dashboard.

โœจ Once you get those 9 values, you can add them in the .env (replacing the current placeholder values), then you do make up again, and now you have the fully working website, where you can sign up and log in to play the game and access all features ๐Ÿฅณ ๐ŸŽ‰, as shown in the Main Components above.

๐Ÿ“˜ Subject Modules

This project contains the following modules from the New Subject:

  • Major module: Use a framework to build the backend. (fastify)
  • Minor module: Use a framework or toolkit to build the front-end. (TailwindCSS)
  • Minor module: Use a database for the backend -and more. (SQLite)
  • Major module: Standard user management, authentication and users across tournaments. (Auth)
  • Major module: Implement remote authentication. (Google Auth)
  • Major module: Remote players (socket.io)
  • Major module: Multiple players (socket.io, multiple clients)
  • Major module: Live Chat. (socket.io)
  • Major module: Implement Two-Factor Authentication (2FA) and JWT. (Auth + SQLite + fastify-jwt)
  • Minor module: Monitoring system. (Prometheus, Grafana, Node Exporter, Nginx Exporter)
  • Major module: Designing the Backend as Microservices. (Auth, Match, Chat)
  • Major module: Implementing Advanced 3D Techniques. (BabylonJS)

Count of Major modules: 9
Count of Minor modules: 3
Total: 10.5

๐Ÿ“œ License

This project is released under the MIT License. Contributions are welcome!

๐Ÿซถ Acknowledgments

Weโ€™d like to give a special thanks to Ramy for his incredible project management and coordination of the team. Without his guidance, this project wouldnโ€™t have been nearly as fun or as smooth!

About

A realtime web-based pong game

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 96.7%
  • Makefile 1.1%
  • Dockerfile 0.5%
  • CSS 0.5%
  • JavaScript 0.5%
  • HTML 0.4%
  • Shell 0.3%