Skip to content

fabbbiodc/skypong

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

35 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

SkyPong

TypeScript Babylon.js Next.js Node.js

Demo

Screen Recording 01

Screen Recording 02

Play Now

Description

SkyPong is a production-style multiplayer Pong platform built as a microservices architecture. The core is a real-time 3D Pong game with server-authoritative physics, PBR rendering, and multiple game modes. Around it sits a full product platform with authentication, profiles, social features, and game statistics.

This is a reupload with a fresh frontend UI of a project originally built by a team of 4 developers. The new version features a complete redesign of the Next.js web application with a unified design system while keeping the robust game engine and backend services intact.

Technologies & Concepts

  • Web application โ€” Next.js (React), TypeScript, Tailwind v4, class-variance-authority, i18n (EN/ES/IT)
  • Game client โ€” Babylon.js 8, React 18, Vite 5, Colyseus.js client
  • Game server โ€” Colyseus 0.15, Babylon.js NullEngine (headless physics), Express
  • Backend services โ€” Fastify, SQLite, JWT (Argon2), Sharp (avatar processing)
  • Infrastructure โ€” Docker Compose, NGINX (TLS gateway), Prometheus, Grafana, Alertmanager
  • Real-time sync โ€” WebSocket via Colyseus, Schema-based state diffs, client-side interpolation
  • Physics โ€” Server-authoritative, continuous collision detection, angle-based bounce response
  • Rendering โ€” PBR materials, EXR environment maps, refractive glass, real-time shadows
  • Design system โ€” Unified design tokens, full CVA component library, responsive mobile layout

Frontend Redesign

A complete redesign of the Next.js web application targeting consistency, maintainability, and scalable UI:

  • Design tokens โ€” Single source of truth with TypeScript types for colors, typography, spacing, shadows
  • Component library โ€” Full class-variance-authority patterns (Button, Card, TextField, Chip, Avatar, Badge, StatCard, Tabs)
  • Pattern components โ€” Section, ListRow, EmptyState, LoadingState, PageContainer, FormCard, ProfileLayout
  • Simplified CSS โ€” Reduced globals.css from 1300 to ~250 lines
  • Background & shadow tokens โ€” Unified system replacing hardcoded values
  • Navbar โ€” Auth-aware navigation with scroll behavior, dropdown menu
  • Homepage โ€” Hero section, Footer, LanguageSelector, interactive PBR marble ball CTA
  • Game scene background โ€” Babylon.js rotating EXR skybox integrated into Next.js layout
  • i18n โ€” 477 translation keys verified across English, Spanish, and Italian
  • TypeScript โ€” Strict typing on auth context, translation context, form validation
  • Color system โ€” Updated from purple to slate palette for better contrast

How It Works

Architecture Overview

Client (Browser)                    Gateway (NGINX)                    Services (Docker)
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”          โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”          โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ Next.js app      โ”‚ โ”€HTTPSโ”€โ–บ โ”‚ TLS termination  โ”‚          โ”‚ auth-service     โ”‚
โ”‚ (port 3000)     โ”‚          โ”‚ Route mapping    โ”‚โ—„โ”€โ”€RESTโ”€โ”€โ–บโ”‚ profile-service  โ”‚
โ”‚                 โ”‚          โ”‚ WebSocket proxy โ”‚          โ”‚ stats-service   โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค          โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜          โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ Game client      โ”‚ โ”€WSโ”€โ”€โ”€โ–บ โ”‚                โ”‚โ—„โ”€โ”€WSโ”€โ”€โ”€โ”€โ–บโ”‚ game-service    โ”‚
โ”‚ (iframe/port 5173)          โ”‚          โ”‚               โ”‚          โ”‚ (Colyseus)      โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜          โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜          โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                                              โ”‚
                                         โ”Œโ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”
                                         โ”‚ Observabilityโ”‚
                                         โ”‚ (Prometheus โ”‚
                                         โ”‚ Grafana)    โ”‚
                                         โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

All external traffic enters via NGINX over HTTPS. Services communicate internally over Docker bridge networks with shared service tokens.

Game State Flow

  1. Player sends input (keyboard/touch) via WebSocket message
  2. Server aggregates input, runs physics at 60 Hz (Babylon.js NullEngine)
  3. Server detects collisions (CCD), updates scores, broadcasts state diffs
  4. Client receives diffs, interpolates ball position toward extrapolated target
  5. Client renders at browser refresh rate (60-144 Hz)

Key Features

  • Game modes โ€” AI (3 difficulties), local 2-player, online PvP with room matchmaking
  • PBR rendering โ€” Environment-based lighting, refractive glass paddles, marble materials, EXR skybox
  • Server-authoritative โ€” Physics runs server-side (NullEngine), preventing cheating
  • Real-time multiplayer โ€” WebSocket via Colyseus with 60 Hz server tick
  • Client interpolation โ€” Exponential smoothing, wall reflection extrapolation, adaptive distance
  • Design system โ€” TypeScript tokens, CVA components, unified shadows and backgrounds
  • i18n โ€” Full UI in English, Spanish, and Italian with type-safe translation context
  • Authentication โ€” JWT with access/refresh tokens, optional 2FA
  • Social โ€” Friendship graph (send/accept/reject/block), global chat
  • Statistics โ€” Game result ingestion, leaderboard aggregation
  • Monitoring โ€” Prometheus metrics, Grafana dashboards, Alertmanager alerts
  • Responsive โ€” Mobile touch controls, adaptive HUD sizing

Project Structure

skypong/
โ”œโ”€โ”€ front/                      # Next.js web application (redesigned)
โ”‚   โ””โ”€โ”€ app/
โ”‚       โ”œโ”€โ”€ lib/design-tokens.ts   # Single source of truth for design values
โ”‚       โ”œโ”€โ”€ ui/base/             # CVA component library
โ”‚       โ”œโ”€โ”€ ui/patterns/         # Reusable page patterns
โ”‚       โ”œโ”€โ”€ ui/GameSceneBackground.tsx  # Babylon.js skybox
โ”‚       โ””โ”€โ”€ ui/base/InteractiveMarbleBall.tsx  # PBR marble CTA
โ”‚
โ”œโ”€โ”€ game/                      # SkyPong game engine
โ”‚   โ”œโ”€โ”€ client/src_cli/
โ”‚   โ”‚   โ”œโ”€โ”€ game/GameLoop.ts     # Interpolation + extrapolation
โ”‚   โ”‚   โ”œโ”€โ”€ ui/GameHUD.ts       # Real-time overlay
โ”‚   โ”‚   โ””โ”€โ”€ entities/           # Client-side ball/paddle/table
โ”‚   โ”œโ”€โ”€ server/src_serv/
โ”‚   โ”‚   โ”œโ”€โ”€ physics/PhysicsEngine.ts  # Server-side physics (CCD, collision response)
โ”‚   โ”‚   โ”œโ”€โ”€ rooms/             # Colyseus rooms (Game, AI, PvP)
โ”‚   โ”‚   โ””โ”€โ”€ entities/           # Server-side ball/paddle/table
โ”‚   โ””โ”€โ”€ common/                # Shared Schema, constants
โ”‚
โ”œโ”€โ”€ auth-service/            # Identity, tokens, 2FA
โ”œโ”€โ”€ profile-service/         # Profiles, avatars, friendships
โ”œโ”€โ”€ statistics-service/     # Stats, leaderboard
โ”œโ”€โ”€ nginx-gateway/          # TLS termination + routing
โ”œโ”€โ”€ prometheus/              # Metrics + alert rules
โ”œโ”€โ”€ grafana/                # Dashboards
โ””โ”€โ”€ docker-compose.yml      # Orchestrates all services

Additional Documentation

More detailed documentation is available in the repository:

Tech Stack

Layer Technologies
Web App Next.js, React 18, TypeScript, Tailwind v4, CVA
Game Client Babylon.js 8, React 18, Vite 5, Colyseus.js
Game Server Colyseus 0.15, Babylon.js NullEngine, Express, Node.js
Backend Services Fastify, SQLite, JWT, Argon2, Sharp
Infrastructure Docker, NGINX, Prometheus, Grafana
Languages TypeScript (full-stack), CSS, GLSL

Installation

Prerequisites

  • Docker + Docker Compose plugin
  • GNU Make
  • Git

Setup

git clone https://github.com/fabbbiodc/skypong
cd skypong
make config
make all

This will:

  • Create .env from .env.example if missing
  • Sync missing environment variables
  • Generate docker-compose.yml from the template
  • Replace host path placeholders with local ./volumes/* paths
  • Build and start all containers

Running

make up      # Start all services
make down    # Stop all services
make logs    # View logs
make ps      # Show container status

Access

  • Main app: https://localhost:8443
  • Grafana: https://localhost:3001

Repository

Collaborators

About

Full-stack real-time multiplayer Pong game with Next.js, NestJS, WebSockets, and Babylon.js.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors