# seokpan/seokpan-app architecture

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

- Interactive diagram: https://gitdiagram.com/seokpan/seokpan-app
- Repository: https://github.com/seokpan/seokpan-app

## Overview

Seokpan is a browser-based, real-time, vote-driven Gomoku service. A player enters through the React session flow, reaches the lobby and a room, then uses HTTP commands to change state while WebSockets deliver snapshots and events; game turns resolve from votes to moves or passes and results. The backend exposes these boundaries and separates durable MariaDB data from Redis runtime state. The README documents major capabilities and storage responsibilities; where source wiring was not excerpted, links are limited to those documented relationships.

Main entry points: [`frontend/src/api/client.ts`](https://github.com/seokpan/seokpan-app/blob/main/frontend/src/api/client.ts) (API client), [`frontend/src/App.tsx`](https://github.com/seokpan/seokpan-app/blob/main/frontend/src/App.tsx) (App routing), [`backend/src/seokpan/app.py`](https://github.com/seokpan/seokpan-app/blob/main/backend/src/seokpan/app.py) (FastAPI assembly), [`frontend/src/realtime/stream.ts`](https://github.com/seokpan/seokpan-app/blob/main/frontend/src/realtime/stream.ts) (Realtime stream)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Browser application"]
  node_app["App routing<br/>[App.tsx]"]
  node_sessionui["Session recovery<br/>[context.tsx]"]
  node_api_client["API client<br/>[client.ts]"]
  node_lobbyui["Lobby<br/>[LobbyPage.tsx]"]
  node_roomui["Room state<br/>[context.tsx]"]
  node_stream["Realtime stream<br/>[stream.ts]"]
  node_gameui["Game board<br/>[GamePanel.tsx]"]
  node_chatui["Chat<br/>[ChatPanel.tsx]"]
  node_presenceui["Online presence<br/>[stream.ts]"]
  node_statsui["Rankings<br/>[useRankings.ts]"]
end

subgraph group_api["HTTP and realtime API"]
  node_backend_app["FastAPI assembly<br/>[app.py]"]
  node_identity_api["Identity API<br/>[identity.py]"]
  node_room_api["Room API<br/>[room.py]"]
  node_game_api["Game API<br/>[game.py]"]
  node_realtime_api["WebSocket API<br/>[realtime.py]"]
end

subgraph group_domain["Game services"]
  node_room_service["Room lifecycle<br/>[lobby.py]"]
  node_game_service["Game and turns<br/>[service.py]"]
  node_session_domain["Session contract<br/>[session.py]"]
end

subgraph group_storage["Persistence"]
  node_maria[("MariaDB")]
  node_redis[("Redis runtime")]
end

node_player(("Player"))

node_player -->|"opens"| node_app
node_app -->|"routes through"| node_sessionui
node_sessionui -->|"sends commands"| node_api_client
node_lobbyui -->|"loads and changes"| node_api_client
node_roomui -->|"reads snapshot"| node_api_client
node_roomui -->|"starts stream"| node_stream
node_stream -->|"refreshes state"| node_api_client
node_gameui -->|"submits votes"| node_api_client
node_lobbyui -->|"renders"| node_chatui
node_app -->|"renders"| node_presenceui
node_app -->|"routes to"| node_statsui
node_api_client -->|"HTTP requests"| node_backend_app
node_stream -->|"WebSocket events"| node_realtime_api
node_backend_app -->|"registers"| node_identity_api
node_backend_app -->|"registers"| node_room_api
node_backend_app -->|"registers"| node_game_api
node_identity_api -->|"uses session rules"| node_session_domain
node_room_api -->|"delegates"| node_room_service
node_game_api -->|"delegates"| node_game_service
node_realtime_api -->|"serves room streams"| node_room_service
node_game_service -.->|"persists game"| node_maria
node_game_service -->|"uses vote runtime"| node_redis
node_session_domain -->|"stores sessions"| node_redis
node_room_service -->|"stores room runtime"| node_redis

click node_app "https://github.com/seokpan/seokpan-app/blob/main/frontend/src/App.tsx"
click node_sessionui "https://github.com/seokpan/seokpan-app/blob/main/frontend/src/session/context.tsx"
click node_api_client "https://github.com/seokpan/seokpan-app/blob/main/frontend/src/api/client.ts"
click node_lobbyui "https://github.com/seokpan/seokpan-app/blob/main/frontend/src/lobby/LobbyPage.tsx"
click node_roomui "https://github.com/seokpan/seokpan-app/blob/main/frontend/src/room/context.tsx"
click node_stream "https://github.com/seokpan/seokpan-app/blob/main/frontend/src/realtime/stream.ts"
click node_gameui "https://github.com/seokpan/seokpan-app/blob/main/frontend/src/game/GamePanel.tsx"
click node_chatui "https://github.com/seokpan/seokpan-app/blob/main/frontend/src/chat/ChatPanel.tsx"
click node_presenceui "https://github.com/seokpan/seokpan-app/blob/main/frontend/src/presence/stream.ts"
click node_statsui "https://github.com/seokpan/seokpan-app/blob/main/frontend/src/statistics/useRankings.ts"
click node_backend_app "https://github.com/seokpan/seokpan-app/blob/main/backend/src/seokpan/app.py"
click node_identity_api "https://github.com/seokpan/seokpan-app/blob/main/backend/src/seokpan/api/identity.py"
click node_room_api "https://github.com/seokpan/seokpan-app/blob/main/backend/src/seokpan/api/room.py"
click node_game_api "https://github.com/seokpan/seokpan-app/blob/main/backend/src/seokpan/api/game.py"
click node_realtime_api "https://github.com/seokpan/seokpan-app/blob/main/backend/src/seokpan/api/realtime.py"
click node_room_service "https://github.com/seokpan/seokpan-app/blob/main/backend/src/seokpan/room/application/lobby.py"
click node_game_service "https://github.com/seokpan/seokpan-app/blob/main/backend/src/seokpan/game/application/service.py"
click node_session_domain "https://github.com/seokpan/seokpan-app/blob/main/backend/src/seokpan/identity/application/session.py"
click node_maria "https://github.com/seokpan/seokpan-app/tree/main/backend/src/seokpan/persistence/mariadb"
click node_redis "https://github.com/seokpan/seokpan-app/tree/main/backend/src/seokpan/persistence/redis"

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_app,node_sessionui,node_api_client,node_lobbyui,node_roomui,node_stream,node_gameui,node_chatui,node_presenceui,node_statsui toneBlue
class node_backend_app,node_identity_api,node_room_api,node_game_api,node_realtime_api toneAmber
class node_room_service,node_game_service,node_session_domain toneMint
class node_maria,node_redis toneRose
class node_player toneIndigo
```

## Components

### Browser application

- [App routing](https://github.com/seokpan/seokpan-app/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [Session recovery](https://github.com/seokpan/seokpan-app/blob/main/frontend/src/session/context.tsx): `frontend/src/session/context.tsx`
- [API client](https://github.com/seokpan/seokpan-app/blob/main/frontend/src/api/client.ts): `frontend/src/api/client.ts`
- [Lobby](https://github.com/seokpan/seokpan-app/blob/main/frontend/src/lobby/LobbyPage.tsx): `frontend/src/lobby/LobbyPage.tsx`
- [Room state](https://github.com/seokpan/seokpan-app/blob/main/frontend/src/room/context.tsx): `frontend/src/room/context.tsx`
- [Realtime stream](https://github.com/seokpan/seokpan-app/blob/main/frontend/src/realtime/stream.ts): `frontend/src/realtime/stream.ts`
- [Game board](https://github.com/seokpan/seokpan-app/blob/main/frontend/src/game/GamePanel.tsx): `frontend/src/game/GamePanel.tsx`
- [Chat](https://github.com/seokpan/seokpan-app/blob/main/frontend/src/chat/ChatPanel.tsx): `frontend/src/chat/ChatPanel.tsx`
- [Online presence](https://github.com/seokpan/seokpan-app/blob/main/frontend/src/presence/stream.ts): `frontend/src/presence/stream.ts`
- [Rankings](https://github.com/seokpan/seokpan-app/blob/main/frontend/src/statistics/useRankings.ts): `frontend/src/statistics/useRankings.ts`

### HTTP and realtime API

- [FastAPI assembly](https://github.com/seokpan/seokpan-app/blob/main/backend/src/seokpan/app.py): `backend/src/seokpan/app.py`
- [Identity API](https://github.com/seokpan/seokpan-app/blob/main/backend/src/seokpan/api/identity.py): `backend/src/seokpan/api/identity.py`
- [Room API](https://github.com/seokpan/seokpan-app/blob/main/backend/src/seokpan/api/room.py): `backend/src/seokpan/api/room.py`
- [Game API](https://github.com/seokpan/seokpan-app/blob/main/backend/src/seokpan/api/game.py): `backend/src/seokpan/api/game.py`
- [WebSocket API](https://github.com/seokpan/seokpan-app/blob/main/backend/src/seokpan/api/realtime.py): `backend/src/seokpan/api/realtime.py`

### Game services

- [Room lifecycle](https://github.com/seokpan/seokpan-app/blob/main/backend/src/seokpan/room/application/lobby.py): `backend/src/seokpan/room/application/lobby.py`
- [Game and turns](https://github.com/seokpan/seokpan-app/blob/main/backend/src/seokpan/game/application/service.py): `backend/src/seokpan/game/application/service.py`
- [Session contract](https://github.com/seokpan/seokpan-app/blob/main/backend/src/seokpan/identity/application/session.py): `backend/src/seokpan/identity/application/session.py`

### Persistence

- [MariaDB](https://github.com/seokpan/seokpan-app/tree/main/backend/src/seokpan/persistence/mariadb): `backend/src/seokpan/persistence/mariadb`
- [Redis runtime](https://github.com/seokpan/seokpan-app/tree/main/backend/src/seokpan/persistence/redis): `backend/src/seokpan/persistence/redis`

### Other components

- **Player**

## Connections

- Player → App routing: opens (evidence: `README.md`)
- App routing → Session recovery: routes through (evidence: `frontend/src/App.tsx`)
- Session recovery → API client: sends commands (evidence: `frontend/src/session/context.tsx`)
- Lobby → API client: loads and changes (evidence: `frontend/src/lobby/LobbyPage.tsx`)
- Room state → API client: reads snapshot (evidence: `frontend/src/room/context.tsx`)
- Room state → Realtime stream: starts stream (evidence: `frontend/src/room/context.tsx`)
- Realtime stream → API client: refreshes state (evidence: `frontend/src/realtime/stream.ts`)
- Game board → API client: submits votes (evidence: `frontend/src/game/GamePanel.tsx`)
- Lobby → Chat: renders (evidence: `frontend/src/lobby/LobbyPage.tsx`)
- App routing → Online presence: renders (evidence: `frontend/src/App.tsx`)
- App routing → Rankings: routes to (evidence: `frontend/src/App.tsx`)
- API client → FastAPI assembly: HTTP requests (evidence: `README.md`)
- Realtime stream → WebSocket API: WebSocket events (evidence: `README.md`)
- FastAPI assembly → Identity API: registers (evidence: `backend/src/seokpan/app.py`)
- FastAPI assembly → Room API: registers (evidence: `backend/src/seokpan/app.py`)
- FastAPI assembly → Game API: registers (evidence: `backend/src/seokpan/app.py`)
- Identity API → Session contract: uses session rules (evidence: `backend/src/seokpan/api/identity.py`)
- Room API → Room lifecycle: delegates (evidence: `backend/src/seokpan/api/room.py`)
- Game API → Game and turns: delegates (evidence: `backend/src/seokpan/api/game.py`)
- WebSocket API → Room lifecycle: serves room streams (evidence: `backend/src/seokpan/api/realtime.py`)
- Game and turns → MariaDB: persists game (evidence: `README.md`)
- Game and turns → Redis runtime: uses vote runtime (evidence: `backend/src/seokpan/game/application/service.py`)
- Session contract → Redis runtime: stores sessions (evidence: `README.md`)
- Room lifecycle → Redis runtime: stores room runtime (evidence: `README.md`)
