# jeanneumannmelo/oitobet architecture

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

- Interactive diagram: https://gitdiagram.com/jeanneumannmelo/oitobet
- Repository: https://github.com/jeanneumannmelo/oitobet

## Overview

Oitobet is a browser-based pool game with account, balance, shop, and payment features. The main client workflow initializes the canvas and game, presents sign-in or guest play, accepts shots, and runs local or online matches; authenticated match and balance actions connect to Firebase and server APIs. Online match handling, some UI integrations, and several backend routes are represented from the source index or imports rather than complete excerpts, so uncertain runtime connections are omitted.

Main entry points: [`client/src/main.js`](https://github.com/jeanneumannmelo/oitobet/blob/main/client/src/main.js) (Game entry and loop), [`client/src/firebase.js`](https://github.com/jeanneumannmelo/oitobet/blob/main/client/src/firebase.js) (Client Firebase), [`server/payment/routes.js`](https://github.com/jeanneumannmelo/oitobet/blob/main/server/payment/routes.js) (Payment routes), [`client/src/input/input.js`](https://github.com/jeanneumannmelo/oitobet/blob/main/client/src/input/input.js) (Shot input)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Game client"]
  node_main["Game entry and loop<br/>[main.js]"]
  node_state["Game state<br/>[state.js]"]
  node_input["Shot input<br/>[input.js]"]
  node_physics["Game physics<br/>[physics.js]"]
  node_rules["Turn rules<br/>[logic.js]"]
  node_bot["Bot opponent<br/>[bot.js]"]
  node_socket["Online client<br/>[socket.js]"]
  node_render["Canvas rendering<br/>[table.js]"]
end

subgraph group_accounts["Accounts and economy"]
  node_authui["Sign-in UI<br/>[Auth.js]"]
  node_profile["Profile completion<br/>[CompleteProfile.js]"]
  node_home["Home and lobby<br/>[Home.js]"]
  node_shop["Cue shop<br/>[Shop.js]"]
  node_firebase["Client Firebase<br/>[firebase.js]"]
  node_firestore[("Firebase data")]
end

subgraph group_backend["Backend services"]
  node_server["Server entry<br/>[index.js]"]
  node_room["Game room<br/>[GameRoom.js]"]
  node_sharedphysics["Shared physics<br/>[physics.js]"]
  node_admin["Admin Firebase<br/>[firebase-admin.js]"]
end

subgraph group_payments["Payments"]
  node_payroutes["Payment routes<br/>[routes.js]"]
  node_cartwave["CartWave client<br/>[cartwaveClient.js]"]
  node_medusa["Medusa client<br/>[medusaClient.js]"]
end

node_player(("Player"))
node_paymentservice["Payment provider"]

node_player -->|"starts play"| node_main
node_main -->|"uses state"| node_state
node_main -->|"initializes"| node_input
node_main -->|"steps physics"| node_physics
node_main -->|"processes turns"| node_rules
node_main -->|"runs opponent"| node_bot
node_main -->|"draws game"| node_render
node_input -->|"restarts game"| node_rules
node_input -->|"sends shots"| node_socket
node_main -->|"opens sign-in"| node_authui
node_main -->|"opens profile"| node_profile
node_main -->|"shows home"| node_home
node_authui -->|"authenticates"| node_firebase
node_profile -->|"updates profile"| node_firebase
node_home -->|"loads account"| node_firebase
node_home -->|"starts online play"| node_socket
node_firebase -->|"reads and writes"| node_firestore
node_shop -.->|"uses shop data"| node_firebase
node_server -.->|"dispatches matches"| node_room
node_room -->|"uses physics"| node_sharedphysics
node_payroutes -->|"creates charges"| node_cartwave
node_payroutes -->|"creates PIX"| node_medusa
node_payroutes -->|"updates accounts"| node_admin
node_cartwave -.->|"requests payments"| node_paymentservice
node_medusa -.->|"requests payments"| node_paymentservice

click node_main "https://github.com/jeanneumannmelo/oitobet/blob/main/client/src/main.js"
click node_state "https://github.com/jeanneumannmelo/oitobet/blob/main/client/src/state.js"
click node_input "https://github.com/jeanneumannmelo/oitobet/blob/main/client/src/input/input.js"
click node_physics "https://github.com/jeanneumannmelo/oitobet/blob/main/client/src/engine/physics.js"
click node_rules "https://github.com/jeanneumannmelo/oitobet/blob/main/client/src/engine/logic.js"
click node_bot "https://github.com/jeanneumannmelo/oitobet/blob/main/client/src/engine/bot.js"
click node_socket "https://github.com/jeanneumannmelo/oitobet/blob/main/client/src/net/socket.js"
click node_render "https://github.com/jeanneumannmelo/oitobet/blob/main/client/src/render/table.js"
click node_authui "https://github.com/jeanneumannmelo/oitobet/blob/main/client/src/ui/Auth.js"
click node_profile "https://github.com/jeanneumannmelo/oitobet/blob/main/client/src/ui/CompleteProfile.js"
click node_home "https://github.com/jeanneumannmelo/oitobet/blob/main/client/src/ui/Home.js"
click node_shop "https://github.com/jeanneumannmelo/oitobet/blob/main/client/src/ui/Shop.js"
click node_firebase "https://github.com/jeanneumannmelo/oitobet/blob/main/client/src/firebase.js"
click node_server "https://github.com/jeanneumannmelo/oitobet/blob/main/server/index.js"
click node_room "https://github.com/jeanneumannmelo/oitobet/blob/main/server/GameRoom.js"
click node_sharedphysics "https://github.com/jeanneumannmelo/oitobet/blob/main/shared/physics.js"
click node_admin "https://github.com/jeanneumannmelo/oitobet/blob/main/server/firebase-admin.js"
click node_payroutes "https://github.com/jeanneumannmelo/oitobet/blob/main/server/payment/routes.js"
click node_cartwave "https://github.com/jeanneumannmelo/oitobet/blob/main/server/payment/cartwaveClient.js"
click node_medusa "https://github.com/jeanneumannmelo/oitobet/blob/main/server/payment/medusaClient.js"

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_main,node_state,node_input,node_physics,node_rules,node_bot,node_socket,node_render toneBlue
class node_authui,node_profile,node_home,node_shop,node_firebase,node_firestore toneAmber
class node_server,node_room,node_sharedphysics,node_admin toneMint
class node_payroutes,node_cartwave,node_medusa toneRose
class node_player,node_paymentservice toneIndigo
```

## Components

### Game client

- [Game entry and loop](https://github.com/jeanneumannmelo/oitobet/blob/main/client/src/main.js): `client/src/main.js`
- [Game state](https://github.com/jeanneumannmelo/oitobet/blob/main/client/src/state.js): `client/src/state.js`
- [Shot input](https://github.com/jeanneumannmelo/oitobet/blob/main/client/src/input/input.js): `client/src/input/input.js`
- [Game physics](https://github.com/jeanneumannmelo/oitobet/blob/main/client/src/engine/physics.js): `client/src/engine/physics.js`
- [Turn rules](https://github.com/jeanneumannmelo/oitobet/blob/main/client/src/engine/logic.js): `client/src/engine/logic.js`
- [Bot opponent](https://github.com/jeanneumannmelo/oitobet/blob/main/client/src/engine/bot.js): `client/src/engine/bot.js`
- [Online client](https://github.com/jeanneumannmelo/oitobet/blob/main/client/src/net/socket.js): `client/src/net/socket.js`
- [Canvas rendering](https://github.com/jeanneumannmelo/oitobet/blob/main/client/src/render/table.js): `client/src/render/table.js`

### Accounts and economy

- [Sign-in UI](https://github.com/jeanneumannmelo/oitobet/blob/main/client/src/ui/Auth.js): `client/src/ui/Auth.js`
- [Profile completion](https://github.com/jeanneumannmelo/oitobet/blob/main/client/src/ui/CompleteProfile.js): `client/src/ui/CompleteProfile.js`
- [Home and lobby](https://github.com/jeanneumannmelo/oitobet/blob/main/client/src/ui/Home.js): `client/src/ui/Home.js`
- [Cue shop](https://github.com/jeanneumannmelo/oitobet/blob/main/client/src/ui/Shop.js): `client/src/ui/Shop.js`
- [Client Firebase](https://github.com/jeanneumannmelo/oitobet/blob/main/client/src/firebase.js): `client/src/firebase.js`
- **Firebase data**

### Backend services

- [Server entry](https://github.com/jeanneumannmelo/oitobet/blob/main/server/index.js): `server/index.js`
- [Game room](https://github.com/jeanneumannmelo/oitobet/blob/main/server/GameRoom.js): `server/GameRoom.js`
- [Shared physics](https://github.com/jeanneumannmelo/oitobet/blob/main/shared/physics.js): `shared/physics.js`
- [Admin Firebase](https://github.com/jeanneumannmelo/oitobet/blob/main/server/firebase-admin.js): `server/firebase-admin.js`

### Payments

- [Payment routes](https://github.com/jeanneumannmelo/oitobet/blob/main/server/payment/routes.js): `server/payment/routes.js`
- [CartWave client](https://github.com/jeanneumannmelo/oitobet/blob/main/server/payment/cartwaveClient.js): `server/payment/cartwaveClient.js`
- [Medusa client](https://github.com/jeanneumannmelo/oitobet/blob/main/server/payment/medusaClient.js): `server/payment/medusaClient.js`

### Other components

- **Player**
- **Payment provider**

## Connections

- Player → Game entry and loop: starts play (evidence: `client/src/main.js`)
- Game entry and loop → Game state: uses state (evidence: `client/src/main.js`)
- Game entry and loop → Shot input: initializes (evidence: `client/src/main.js`)
- Game entry and loop → Game physics: steps physics (evidence: `client/src/main.js`)
- Game entry and loop → Turn rules: processes turns (evidence: `client/src/main.js`)
- Game entry and loop → Bot opponent: runs opponent (evidence: `client/src/main.js`)
- Game entry and loop → Canvas rendering: draws game (evidence: `client/src/main.js`)
- Shot input → Turn rules: restarts game (evidence: `client/src/input/input.js`)
- Shot input → Online client: sends shots (evidence: `client/src/input/input.js`)
- Game entry and loop → Sign-in UI: opens sign-in (evidence: `client/src/main.js`)
- Game entry and loop → Profile completion: opens profile (evidence: `client/src/main.js`)
- Game entry and loop → Home and lobby: shows home (evidence: `client/src/main.js`)
- Sign-in UI → Client Firebase: authenticates (evidence: `client/src/ui/Auth.js`)
- Profile completion → Client Firebase: updates profile (evidence: `client/src/ui/CompleteProfile.js`)
- Home and lobby → Client Firebase: loads account (evidence: `client/src/ui/Home.js`)
- Home and lobby → Online client: starts online play (evidence: `client/src/ui/Home.js`)
- Client Firebase → Firebase data: reads and writes (evidence: `client/src/firebase.js`)
- Cue shop → Client Firebase: uses shop data
- Server entry → Game room: dispatches matches
- Game room → Shared physics: uses physics (evidence: `server/GameRoom.js`)
- Payment routes → CartWave client: creates charges (evidence: `server/payment/routes.js`)
- Payment routes → Medusa client: creates PIX (evidence: `server/payment/routes.js`)
- Payment routes → Admin Firebase: updates accounts (evidence: `server/payment/routes.js`)
- CartWave client → Payment provider: requests payments
- Medusa client → Payment provider: requests payments
