How egamijun/code-world works
BANG BANG is a browser-based Three.js open-world FPS, with account, profile, and leaderboard services alongside local gameplay and real-time PvP synchronization. A player selects a mode and map in the web client, then enters the Three.js world; authenticated users can also use API-backed accounts and review stats. The README documents the game’s modes, vehicles, weapons, enemy AI, mobile controls, and WebSocket features, but the gameplay implementation is a very large unsampled file, so those internals are represented as one world component. Arrows cite visible calls or documented relationships; the exact real-time wiring is not shown in the excerpts.
Main entry points: client.ts Database client · index.ts API service · lib/auth.ts Session and password auth · routes/auth.ts Authentication routes
Components 22
Game client
- Web app shell
apps/web/src/app/layout.tsx - Mode and map selection
apps/web/src/app/world/WorldClient.tsx - FPS world
apps/web/src/app/world/ThreeWorld.tsx - Login and signup
apps/web/src/app/login/page.tsx - Signup page
apps/web/src/app/signup/page.tsx - Player profile
apps/web/src/app/profile/page.tsx - Leaderboard view
apps/web/src/app/leaderboard/page.tsx - Localization
apps/web/src/i18n/index.tsx - Auth client
apps/web/src/lib/auth-client.ts
Account and services
- API service
apps/api/src/index.ts - Authentication routes
apps/api/src/routes/auth.ts - Session and password auth
apps/api/src/lib/auth.ts - Profile and match stats
apps/api/src/routes/profile.ts - Leaderboard API
apps/api/src/routes/leaderboard.ts - Health route
apps/api/src/routes/health.ts
Persistence
- Database client
packages/db/src/client.ts - Users and matches
packages/db/src/schema/users.ts - Sessions
packages/db/src/schema/sessions.ts
Shared and worker runtime
- User validation types
packages/types/src/schemas/user.ts - Execution worker
apps/executor/src/workers/codeExecution.ts - Execution queue
apps/executor/src/queues/index.ts
Other components
- Player
Connections 25
- Player → Web app shell: opens
README.md - Web app shell → Mode and map selection: routes to
- Mode and map selection → FPS world: loads
apps/web/src/app/world/WorldClient.tsx - Player → Login and signup: authenticates
- Login and signup → Auth client: submits credentials
apps/web/src/app/login/page.tsx - Signup page → Auth client: submits credentials
apps/web/src/app/signup/page.tsx - Auth client → Authentication routes: requests auth API
apps/web/src/lib/auth-client.ts - API service → Authentication routes: mounts
apps/api/src/index.ts - API service → Profile and match stats: mounts
apps/api/src/index.ts - API service → Leaderboard API: mounts
apps/api/src/index.ts - API service → Health route: mounts
apps/api/src/index.ts - Authentication routes → Session and password auth: uses auth helpers
apps/api/src/routes/auth.ts - Session and password auth → Database client: queries
apps/api/src/lib/auth.ts - Authentication routes → Database client: queries users
apps/api/src/routes/auth.ts - Profile and match stats → Database client: reads and writes
apps/api/src/routes/profile.ts - Leaderboard API → Database client: queries rankings
apps/api/src/routes/leaderboard.ts - Database client → Users and matches: loads schema
packages/db/src/client.ts - Session and password auth → Sessions: stores sessions
- Session and password auth → Users and matches: looks up users
- Player profile → Profile and match stats: loads profile
- Leaderboard view → Leaderboard API: loads rankings
- Web app shell → Localization: provides translations
apps/web/src/app/layout.tsx - Mode and map selection → Localization: uses translations
apps/web/src/app/world/WorldClient.tsx - Player profile → Auth client: logs out
apps/web/src/app/profile/page.tsx - Execution worker → Execution queue: uses queue name
apps/executor/src/workers/codeExecution.ts