# satyamsk05/3334game architecture

> Architecture diagram of the GitHub repository satyamsk05/3334game, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-25). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/satyamsk05/3334game
- Repository: https://github.com/satyamsk05/3334game
- Video tour (about a minute): https://gitdiagram.com/satyamsk05/3334game/video

## Overview

334Game is a real-money wheel game with player authentication, wallets, deposits and withdrawals, live round updates, and administrative management. The principal flow is player login, funding a wallet, placing bets, receiving a round result and payout, then optionally requesting a withdrawal. The tree also shows a separate Next.js admin panel. The README describes documentation rather than product behavior, and sampled backend excerpts are incomplete, so links for unsampled implementations are limited to relationships explicitly visible in the app wiring or documented by module names.

Main entry points: [`backend/src/app.ts`](https://github.com/satyamsk05/3334game/blob/main/backend/src/app.ts) (HTTP app), [`admin-panel/src/app/page.tsx`](https://github.com/satyamsk05/3334game/blob/main/admin-panel/src/app/page.tsx) (Admin panel), [`backend/src/game/RingOfFutureEngine.ts`](https://github.com/satyamsk05/3334game/blob/main/backend/src/game/RingOfFutureEngine.ts) (Round engine), [`backend/src/modules/payments/payment.routes.ts`](https://github.com/satyamsk05/3334game/blob/main/backend/src/modules/payments/payment.routes.ts) (Payment routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_player["Player experience"]
  node_game_ui["Game page<br/>[gamePage.ts]"]
  node_deposit_ui["Deposit page<br/>[depositPage.ts]"]
  node_auth_routes["Auth routes<br/>[auth.routes.ts]"]
  node_auth_controller["Auth controller<br/>[auth.controller.ts]"]
  node_auth_service["Auth service<br/>[auth.service.ts]"]
end

subgraph group_game["Game runtime"]
  node_ring["Round engine"]
  node_game_client["Game client<br/>[pixi-wheel.js]"]
  node_game_ws["Game WebSocket"]
  node_socket["Socket server<br/>[socket.server.ts]"]
end

subgraph group_money["Wallet and payments"]
  node_wallet_routes["Wallet routes<br/>[wallet.routes.ts]"]
  node_wallet_controller["Wallet controller"]
  node_wallet_service["Wallet service<br/>[wallet.service.ts]"]
  node_ledger[("Wallet ledger<br/>[WalletLedger.ts]")]
  node_payment_routes["Payment routes<br/>[payment.routes.ts]"]
  node_deposit_controller["Deposit controller"]
  node_withdraw_controller["Withdrawal controller"]
  node_payment_service["Payment service<br/>[payment.service.ts]"]
end

subgraph group_admin["Administration"]
  node_admin_ui["Admin panel<br/>[page.tsx]"]
  node_admin_auth["Admin guard<br/>[AdminGuard.tsx]"]
  node_admin_api["Admin API client<br/>[api.ts]"]
  node_admin_payments["Payment views<br/>[page.tsx]"]
  node_admin_users["User management<br/>[page.tsx]"]
  node_admin_reports["Reports<br/>[page.tsx]"]
  node_admin_payment_service["Payment service<br/>[paymentService.ts]"]
  node_admin_user_service["User service<br/>[userService.ts]"]
  node_user_routes["User routes<br/>[user.routes.ts]"]
  node_user_controller["User controller<br/>[user.controller.ts]"]
  node_user_service["User service<br/>[user.service.ts]"]
end

subgraph group_platform["Backend platform"]
  node_app["HTTP app<br/>[app.ts]"]
  node_server["Server bootstrap<br/>[server.ts]"]
  node_database[("Database config<br/>[db.config.ts]")]
end

node_player(("Player"))
node_upi(("UPI payment"))
node_admin_user(("Administrator"))

node_player -->|"opens game"| node_game_ui
node_player -->|"opens deposits"| node_deposit_ui
node_player -->|"requests login"| node_auth_routes
node_app -->|"mounts"| node_auth_routes
node_app -->|"mounts"| node_wallet_routes
node_app -->|"mounts"| node_payment_routes
node_app -->|"mounts"| node_user_routes
node_app -->|"checks health"| node_database
node_auth_routes -->|"dispatches"| node_auth_controller
node_auth_controller -->|"calls"| node_auth_service
node_auth_service -->|"persists users"| node_database
node_game_ui -->|"connects live"| node_game_ws
node_server -->|"starts engine"| node_ring
node_server -->|"initializes"| node_socket
node_ring -->|"broadcasts state"| node_socket
node_ring -->|"records bets and payouts"| node_ledger
node_wallet_routes -->|"dispatches"| node_wallet_controller
node_wallet_controller -->|"calls"| node_wallet_service
node_payment_routes -->|"dispatches"| node_deposit_controller
node_payment_routes -->|"dispatches"| node_withdraw_controller
node_deposit_controller -->|"calls"| node_payment_service
node_withdraw_controller -->|"calls"| node_payment_service
node_deposit_ui -->|"initiates payment"| node_upi
node_admin_user -->|"uses"| node_admin_ui
node_admin_ui -->|"guards access"| node_admin_auth
node_admin_ui -->|"uses"| node_admin_payment_service
node_admin_ui -->|"uses"| node_admin_user_service
node_admin_payment_service -->|"requests data"| node_admin_api
node_admin_user_service -->|"requests data"| node_admin_api
node_admin_api -->|"calls backend"| node_app
node_admin_payment_service -->|"serves views"| node_admin_payments
node_admin_user_service -->|"serves views"| node_admin_users
node_admin_ui -->|"provides reports"| node_admin_reports
node_user_routes -->|"dispatches"| node_user_controller
node_user_controller -->|"calls"| node_user_service

click node_game_ui "https://github.com/satyamsk05/3334game/blob/main/backend/src/routes/gamePage.ts"
click node_deposit_ui "https://github.com/satyamsk05/3334game/blob/main/backend/src/routes/depositPage.ts"
click node_auth_routes "https://github.com/satyamsk05/3334game/blob/main/backend/src/modules/auth/auth.routes.ts"
click node_auth_controller "https://github.com/satyamsk05/3334game/blob/main/backend/src/modules/auth/auth.controller.ts"
click node_auth_service "https://github.com/satyamsk05/3334game/blob/main/backend/src/modules/auth/auth.service.ts"
click node_ring "https://github.com/satyamsk05/3334game/blob/main/backend/src/game/RingOfFutureEngine.ts"
click node_game_client "https://github.com/satyamsk05/3334game/blob/main/backend/public/game/pixi-wheel.js"
click node_game_ws "https://github.com/satyamsk05/3334game/blob/main/backend/src/websocket/GameWebSocketServer.ts"
click node_socket "https://github.com/satyamsk05/3334game/blob/main/backend/src/sockets/socket.server.ts"
click node_wallet_routes "https://github.com/satyamsk05/3334game/blob/main/backend/src/modules/wallet/wallet.routes.ts"
click node_wallet_controller "https://github.com/satyamsk05/3334game/blob/main/backend/src/modules/wallet/wallet.controller.ts"
click node_wallet_service "https://github.com/satyamsk05/3334game/blob/main/backend/src/modules/wallet/wallet.service.ts"
click node_ledger "https://github.com/satyamsk05/3334game/blob/main/backend/src/services/WalletLedger.ts"
click node_payment_routes "https://github.com/satyamsk05/3334game/blob/main/backend/src/modules/payments/payment.routes.ts"
click node_deposit_controller "https://github.com/satyamsk05/3334game/blob/main/backend/src/modules/payments/deposit.controller.ts"
click node_withdraw_controller "https://github.com/satyamsk05/3334game/blob/main/backend/src/modules/payments/withdraw.controller.ts"
click node_payment_service "https://github.com/satyamsk05/3334game/blob/main/backend/src/modules/payments/payment.service.ts"
click node_admin_ui "https://github.com/satyamsk05/3334game/blob/main/admin-panel/src/app/page.tsx"
click node_admin_auth "https://github.com/satyamsk05/3334game/blob/main/admin-panel/src/components/layout/AdminGuard.tsx"
click node_admin_api "https://github.com/satyamsk05/3334game/blob/main/admin-panel/src/services/api.ts"
click node_admin_payments "https://github.com/satyamsk05/3334game/blob/main/admin-panel/src/app/payments/deposits/page.tsx"
click node_admin_users "https://github.com/satyamsk05/3334game/blob/main/admin-panel/src/app/users/page.tsx"
click node_admin_reports "https://github.com/satyamsk05/3334game/blob/main/admin-panel/src/app/reports/page.tsx"
click node_admin_payment_service "https://github.com/satyamsk05/3334game/blob/main/admin-panel/src/services/paymentService.ts"
click node_admin_user_service "https://github.com/satyamsk05/3334game/blob/main/admin-panel/src/services/userService.ts"
click node_user_routes "https://github.com/satyamsk05/3334game/blob/main/backend/src/modules/users/user.routes.ts"
click node_user_controller "https://github.com/satyamsk05/3334game/blob/main/backend/src/modules/users/user.controller.ts"
click node_user_service "https://github.com/satyamsk05/3334game/blob/main/backend/src/modules/users/user.service.ts"
click node_app "https://github.com/satyamsk05/3334game/blob/main/backend/src/app.ts"
click node_server "https://github.com/satyamsk05/3334game/blob/main/backend/src/server.ts"
click node_database "https://github.com/satyamsk05/3334game/blob/main/backend/src/config/db.config.ts"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_game_ui,node_deposit_ui,node_auth_routes,node_auth_controller,node_auth_service toneBlue
class node_ring,node_game_client,node_game_ws,node_socket toneAmber
class node_wallet_routes,node_wallet_controller,node_wallet_service,node_ledger,node_payment_routes,node_deposit_controller,node_withdraw_controller,node_payment_service toneMint
class node_admin_ui,node_admin_auth,node_admin_api,node_admin_payments,node_admin_users,node_admin_reports,node_admin_payment_service,node_admin_user_service,node_user_routes,node_user_controller,node_user_service toneRose
class node_app,node_server,node_database,node_player,node_upi,node_admin_user toneIndigo
```

## Components

### Player experience

- [Game page](https://github.com/satyamsk05/3334game/blob/main/backend/src/routes/gamePage.ts): `backend/src/routes/gamePage.ts`
- [Deposit page](https://github.com/satyamsk05/3334game/blob/main/backend/src/routes/depositPage.ts): `backend/src/routes/depositPage.ts`
- [Auth routes](https://github.com/satyamsk05/3334game/blob/main/backend/src/modules/auth/auth.routes.ts): `backend/src/modules/auth/auth.routes.ts`
- [Auth controller](https://github.com/satyamsk05/3334game/blob/main/backend/src/modules/auth/auth.controller.ts): `backend/src/modules/auth/auth.controller.ts`
- [Auth service](https://github.com/satyamsk05/3334game/blob/main/backend/src/modules/auth/auth.service.ts): `backend/src/modules/auth/auth.service.ts`

### Game runtime

- [Round engine](https://github.com/satyamsk05/3334game/blob/main/backend/src/game/RingOfFutureEngine.ts): `backend/src/game/RingOfFutureEngine.ts`
- [Game client](https://github.com/satyamsk05/3334game/blob/main/backend/public/game/pixi-wheel.js): `backend/public/game/pixi-wheel.js`
- [Game WebSocket](https://github.com/satyamsk05/3334game/blob/main/backend/src/websocket/GameWebSocketServer.ts): `backend/src/websocket/GameWebSocketServer.ts`
- [Socket server](https://github.com/satyamsk05/3334game/blob/main/backend/src/sockets/socket.server.ts): `backend/src/sockets/socket.server.ts`

### Wallet and payments

- [Wallet routes](https://github.com/satyamsk05/3334game/blob/main/backend/src/modules/wallet/wallet.routes.ts): `backend/src/modules/wallet/wallet.routes.ts`
- [Wallet controller](https://github.com/satyamsk05/3334game/blob/main/backend/src/modules/wallet/wallet.controller.ts): `backend/src/modules/wallet/wallet.controller.ts`
- [Wallet service](https://github.com/satyamsk05/3334game/blob/main/backend/src/modules/wallet/wallet.service.ts): `backend/src/modules/wallet/wallet.service.ts`
- [Wallet ledger](https://github.com/satyamsk05/3334game/blob/main/backend/src/services/WalletLedger.ts): `backend/src/services/WalletLedger.ts`
- [Payment routes](https://github.com/satyamsk05/3334game/blob/main/backend/src/modules/payments/payment.routes.ts): `backend/src/modules/payments/payment.routes.ts`
- [Deposit controller](https://github.com/satyamsk05/3334game/blob/main/backend/src/modules/payments/deposit.controller.ts): `backend/src/modules/payments/deposit.controller.ts`
- [Withdrawal controller](https://github.com/satyamsk05/3334game/blob/main/backend/src/modules/payments/withdraw.controller.ts): `backend/src/modules/payments/withdraw.controller.ts`
- [Payment service](https://github.com/satyamsk05/3334game/blob/main/backend/src/modules/payments/payment.service.ts): `backend/src/modules/payments/payment.service.ts`

### Administration

- [Admin panel](https://github.com/satyamsk05/3334game/blob/main/admin-panel/src/app/page.tsx): `admin-panel/src/app/page.tsx`
- [Admin guard](https://github.com/satyamsk05/3334game/blob/main/admin-panel/src/components/layout/AdminGuard.tsx): `admin-panel/src/components/layout/AdminGuard.tsx`
- [Admin API client](https://github.com/satyamsk05/3334game/blob/main/admin-panel/src/services/api.ts): `admin-panel/src/services/api.ts`
- [Payment views](https://github.com/satyamsk05/3334game/blob/main/admin-panel/src/app/payments/deposits/page.tsx): `admin-panel/src/app/payments/deposits/page.tsx`
- [User management](https://github.com/satyamsk05/3334game/blob/main/admin-panel/src/app/users/page.tsx): `admin-panel/src/app/users/page.tsx`
- [Reports](https://github.com/satyamsk05/3334game/blob/main/admin-panel/src/app/reports/page.tsx): `admin-panel/src/app/reports/page.tsx`
- [Payment service](https://github.com/satyamsk05/3334game/blob/main/admin-panel/src/services/paymentService.ts): `admin-panel/src/services/paymentService.ts`
- [User service](https://github.com/satyamsk05/3334game/blob/main/admin-panel/src/services/userService.ts): `admin-panel/src/services/userService.ts`
- [User routes](https://github.com/satyamsk05/3334game/blob/main/backend/src/modules/users/user.routes.ts): `backend/src/modules/users/user.routes.ts`
- [User controller](https://github.com/satyamsk05/3334game/blob/main/backend/src/modules/users/user.controller.ts): `backend/src/modules/users/user.controller.ts`
- [User service](https://github.com/satyamsk05/3334game/blob/main/backend/src/modules/users/user.service.ts): `backend/src/modules/users/user.service.ts`

### Backend platform

- [HTTP app](https://github.com/satyamsk05/3334game/blob/main/backend/src/app.ts): `backend/src/app.ts`
- [Server bootstrap](https://github.com/satyamsk05/3334game/blob/main/backend/src/server.ts): `backend/src/server.ts`
- [Database config](https://github.com/satyamsk05/3334game/blob/main/backend/src/config/db.config.ts): `backend/src/config/db.config.ts`

### Other components

- **Player**
- **UPI payment**
- **Administrator**

## Connections

- Player → Game page: opens game
- Player → Deposit page: opens deposits
- Player → Auth routes: requests login
- HTTP app → Auth routes: mounts
- HTTP app → Wallet routes: mounts
- HTTP app → Payment routes: mounts
- HTTP app → User routes: mounts
- HTTP app → Database config: checks health
- Auth routes → Auth controller: dispatches
- Auth controller → Auth service: calls
- Auth service → Database config: persists users
- Game page → Game WebSocket: connects live
- Server bootstrap → Round engine: starts engine
- Server bootstrap → Socket server: initializes
- Round engine → Socket server: broadcasts state
- Round engine → Wallet ledger: records bets and payouts
- Wallet routes → Wallet controller: dispatches
- Wallet controller → Wallet service: calls
- Payment routes → Deposit controller: dispatches
- Payment routes → Withdrawal controller: dispatches
- Deposit controller → Payment service: calls
- Withdrawal controller → Payment service: calls
- Deposit page → UPI payment: initiates payment
- Administrator → Admin panel: uses
- Admin panel → Admin guard: guards access
- Admin panel → Payment service: uses
- Admin panel → User service: uses
- Payment service → Admin API client: requests data
- User service → Admin API client: requests data
- Admin API client → HTTP app: calls backend
- Payment service → Payment views: serves views
- User service → User management: serves views
- Admin panel → Reports: provides reports
- User routes → User controller: dispatches
- User controller → User service: calls
