# kim-seokjin/sos architecture

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

- Interactive diagram: https://gitdiagram.com/kim-seokjin/sos
- Repository: https://github.com/kim-seokjin/sos

## Overview

SOS is a timed competitive puzzle web app: a player signs in, loads a puzzle, solves it under a 60-second limit (with a one-use hint), submits a result, and views global rankings or personal history. The React client communicates with FastAPI; the README documents PostgreSQL, Redis ranking, and S3 puzzle assets, while backend endpoint internals beyond sign-in were not sampled. Edges for those capabilities are therefore limited to documented relationships; unsampled implementation details are not inferred.

Main entry points: [`src/pages/Play.tsx`](https://github.com/kim-seokjin/sos/blob/main/src/pages/Play.tsx) (Puzzle play), [`src/routes/AppRoutes.tsx`](https://github.com/kim-seokjin/sos/blob/main/src/routes/AppRoutes.tsx) (App routes), [`backend/app/api/v1/api.py`](https://github.com/kim-seokjin/sos/blob/main/backend/app/api/v1/api.py) (API router), [`src/pages/HallOfFame.tsx`](https://github.com/kim-seokjin/sos/blob/main/src/pages/HallOfFame.tsx) (Global rankings)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Player experience"]
  node_routes["App routes<br/>[AppRoutes.tsx]"]
  node_signin["Sign-in<br/>[SignIn.tsx]"]
  node_play["Puzzle play<br/>[Play.tsx]"]
  node_puzzle_ui["Puzzle interface<br/>[PuzzleGrid.tsx]"]
  node_timer["Game timer<br/>[TimerDisplay.tsx]"]
  node_hint["Hint dialog<br/>[HintDialog.tsx]"]
  node_success["Win and secret message<br/>[SuccessDialog.tsx]"]
  node_hall["Global rankings<br/>[HallOfFame.tsx]"]
  node_records["Personal records<br/>[MyRecords.tsx]"]
end

subgraph group_frontend["Client services"]
  node_auth_store["Auth state<br/>[useAuthStore.ts]"]
  node_auth_api["Sign-in client<br/>[auth.ts]"]
  node_game_client["Game client<br/>[game.ts]"]
  node_ranking_client["Ranking client<br/>[ranking.ts]"]
  node_socket_client["Realtime client<br/>[socket.ts]"]
  node_api_client["HTTP client<br/>[api.ts]"]
end

subgraph group_backend["API and game services"]
  node_api["FastAPI app<br/>[main.py]"]
  node_api_routes["API router<br/>[api.py]"]
  node_auth_endpoint["Authentication<br/>[auth.py]"]
  node_game_endpoint["Game records<br/>[games.py]"]
  node_puzzle_endpoint["Puzzle service<br/>[puzzles.py]"]
  node_rank_endpoint["Ranking service<br/>[ranks.py]"]
  node_socket_server["Socket.IO server<br/>[socket.py]"]
end

subgraph group_data["Persistence and assets"]
  node_database[("SQL database<br/>[session.py]")]
  node_redis[("Redis rankings<br/>[redis.py]")]
  node_s3["Puzzle image assets<br/>[s3.py]"]
end

node_player(("Player"))

node_player -->|"opens app"| node_routes
node_routes -->|"routes to"| node_signin
node_routes -->|"routes to"| node_play
node_routes -->|"routes to"| node_hall
node_routes -->|"routes to"| node_records
node_signin -->|"calls"| node_auth_api
node_auth_api -->|"posts sign-in"| node_api_client
node_signin -->|"sets session"| node_auth_store
node_play -->|"loads and submits"| node_game_client
node_play -->|"renders"| node_puzzle_ui
node_play -->|"renders"| node_timer
node_play -->|"renders"| node_hint
node_play -->|"renders"| node_success
node_play -->|"checks session"| node_auth_store
node_game_client -->|"uses HTTP"| node_api_client
node_hall -->|"loads rankings"| node_ranking_client
node_hall -->|"connects realtime"| node_socket_client
node_records -->|"loads history"| node_game_client
node_api_client -.->|"sends API requests"| node_api
node_api -->|"mounts router"| node_api_routes
node_api -->|"mounts Socket.IO"| node_socket_server
node_api_routes -->|"registers routes"| node_auth_endpoint
node_api_routes -->|"registers routes"| node_game_endpoint
node_api_routes -->|"registers routes"| node_puzzle_endpoint
node_api_routes -->|"registers routes"| node_rank_endpoint
node_auth_endpoint -->|"reads and writes"| node_database
node_auth_endpoint -->|"issues token"| node_player
node_game_endpoint -.->|"stores history"| node_database
node_puzzle_endpoint -.->|"serves puzzle assets"| node_s3
node_rank_endpoint -.->|"updates rankings"| node_redis
node_rank_endpoint -.->|"reads records"| node_database
node_socket_server -.->|"publishes live updates"| node_hall

click node_routes "https://github.com/kim-seokjin/sos/blob/main/src/routes/AppRoutes.tsx"
click node_signin "https://github.com/kim-seokjin/sos/blob/main/src/pages/SignIn.tsx"
click node_play "https://github.com/kim-seokjin/sos/blob/main/src/pages/Play.tsx"
click node_puzzle_ui "https://github.com/kim-seokjin/sos/blob/main/src/components/PuzzleGrid.tsx"
click node_timer "https://github.com/kim-seokjin/sos/blob/main/src/components/TimerDisplay.tsx"
click node_hint "https://github.com/kim-seokjin/sos/blob/main/src/components/HintDialog.tsx"
click node_success "https://github.com/kim-seokjin/sos/blob/main/src/components/SuccessDialog.tsx"
click node_hall "https://github.com/kim-seokjin/sos/blob/main/src/pages/HallOfFame.tsx"
click node_records "https://github.com/kim-seokjin/sos/blob/main/src/pages/MyRecords.tsx"
click node_auth_store "https://github.com/kim-seokjin/sos/blob/main/src/lib/store/useAuthStore.ts"
click node_auth_api "https://github.com/kim-seokjin/sos/blob/main/src/lib/auth.ts"
click node_game_client "https://github.com/kim-seokjin/sos/blob/main/src/lib/game.ts"
click node_ranking_client "https://github.com/kim-seokjin/sos/blob/main/src/lib/ranking.ts"
click node_socket_client "https://github.com/kim-seokjin/sos/blob/main/src/lib/socket.ts"
click node_api_client "https://github.com/kim-seokjin/sos/blob/main/src/lib/api.ts"
click node_api "https://github.com/kim-seokjin/sos/blob/main/backend/app/main.py"
click node_api_routes "https://github.com/kim-seokjin/sos/blob/main/backend/app/api/v1/api.py"
click node_auth_endpoint "https://github.com/kim-seokjin/sos/blob/main/backend/app/api/v1/endpoints/auth.py"
click node_game_endpoint "https://github.com/kim-seokjin/sos/blob/main/backend/app/api/v1/endpoints/games.py"
click node_puzzle_endpoint "https://github.com/kim-seokjin/sos/blob/main/backend/app/api/v1/endpoints/puzzles.py"
click node_rank_endpoint "https://github.com/kim-seokjin/sos/blob/main/backend/app/api/v1/endpoints/ranks.py"
click node_socket_server "https://github.com/kim-seokjin/sos/blob/main/backend/app/core/socket.py"
click node_database "https://github.com/kim-seokjin/sos/blob/main/backend/app/db/session.py"
click node_redis "https://github.com/kim-seokjin/sos/blob/main/backend/app/core/redis.py"
click node_s3 "https://github.com/kim-seokjin/sos/blob/main/backend/app/core/s3.py"

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_routes,node_signin,node_play,node_puzzle_ui,node_timer,node_hint,node_success,node_hall,node_records toneBlue
class node_auth_store,node_auth_api,node_game_client,node_ranking_client,node_socket_client,node_api_client toneAmber
class node_api,node_api_routes,node_auth_endpoint,node_game_endpoint,node_puzzle_endpoint,node_rank_endpoint,node_socket_server toneMint
class node_database,node_redis,node_s3 toneRose
class node_player toneIndigo
```

## Components

### Player experience

- [App routes](https://github.com/kim-seokjin/sos/blob/main/src/routes/AppRoutes.tsx): `src/routes/AppRoutes.tsx`
- [Sign-in](https://github.com/kim-seokjin/sos/blob/main/src/pages/SignIn.tsx): `src/pages/SignIn.tsx`
- [Puzzle play](https://github.com/kim-seokjin/sos/blob/main/src/pages/Play.tsx): `src/pages/Play.tsx`
- [Puzzle interface](https://github.com/kim-seokjin/sos/blob/main/src/components/PuzzleGrid.tsx): `src/components/PuzzleGrid.tsx`
- [Game timer](https://github.com/kim-seokjin/sos/blob/main/src/components/TimerDisplay.tsx): `src/components/TimerDisplay.tsx`
- [Hint dialog](https://github.com/kim-seokjin/sos/blob/main/src/components/HintDialog.tsx): `src/components/HintDialog.tsx`
- [Win and secret message](https://github.com/kim-seokjin/sos/blob/main/src/components/SuccessDialog.tsx): `src/components/SuccessDialog.tsx`
- [Global rankings](https://github.com/kim-seokjin/sos/blob/main/src/pages/HallOfFame.tsx): `src/pages/HallOfFame.tsx`
- [Personal records](https://github.com/kim-seokjin/sos/blob/main/src/pages/MyRecords.tsx): `src/pages/MyRecords.tsx`

### Client services

- [Auth state](https://github.com/kim-seokjin/sos/blob/main/src/lib/store/useAuthStore.ts): `src/lib/store/useAuthStore.ts`
- [Sign-in client](https://github.com/kim-seokjin/sos/blob/main/src/lib/auth.ts): `src/lib/auth.ts`
- [Game client](https://github.com/kim-seokjin/sos/blob/main/src/lib/game.ts): `src/lib/game.ts`
- [Ranking client](https://github.com/kim-seokjin/sos/blob/main/src/lib/ranking.ts): `src/lib/ranking.ts`
- [Realtime client](https://github.com/kim-seokjin/sos/blob/main/src/lib/socket.ts): `src/lib/socket.ts`
- [HTTP client](https://github.com/kim-seokjin/sos/blob/main/src/lib/api.ts): `src/lib/api.ts`

### API and game services

- [FastAPI app](https://github.com/kim-seokjin/sos/blob/main/backend/app/main.py): `backend/app/main.py`
- [API router](https://github.com/kim-seokjin/sos/blob/main/backend/app/api/v1/api.py): `backend/app/api/v1/api.py`
- [Authentication](https://github.com/kim-seokjin/sos/blob/main/backend/app/api/v1/endpoints/auth.py): `backend/app/api/v1/endpoints/auth.py`
- [Game records](https://github.com/kim-seokjin/sos/blob/main/backend/app/api/v1/endpoints/games.py): `backend/app/api/v1/endpoints/games.py`
- [Puzzle service](https://github.com/kim-seokjin/sos/blob/main/backend/app/api/v1/endpoints/puzzles.py): `backend/app/api/v1/endpoints/puzzles.py`
- [Ranking service](https://github.com/kim-seokjin/sos/blob/main/backend/app/api/v1/endpoints/ranks.py): `backend/app/api/v1/endpoints/ranks.py`
- [Socket.IO server](https://github.com/kim-seokjin/sos/blob/main/backend/app/core/socket.py): `backend/app/core/socket.py`

### Persistence and assets

- [SQL database](https://github.com/kim-seokjin/sos/blob/main/backend/app/db/session.py): `backend/app/db/session.py`
- [Redis rankings](https://github.com/kim-seokjin/sos/blob/main/backend/app/core/redis.py): `backend/app/core/redis.py`
- [Puzzle image assets](https://github.com/kim-seokjin/sos/blob/main/backend/app/core/s3.py): `backend/app/core/s3.py`

### Other components

- **Player**

## Connections

- Player → App routes: opens app
- App routes → Sign-in: routes to (evidence: `src/routes/AppRoutes.tsx`)
- App routes → Puzzle play: routes to (evidence: `src/routes/AppRoutes.tsx`)
- App routes → Global rankings: routes to (evidence: `src/routes/AppRoutes.tsx`)
- App routes → Personal records: routes to (evidence: `src/routes/AppRoutes.tsx`)
- Sign-in → Sign-in client: calls (evidence: `src/lib/auth.ts`)
- Sign-in client → HTTP client: posts sign-in (evidence: `src/lib/auth.ts`)
- Sign-in → Auth state: sets session (evidence: `src/lib/store/useAuthStore.ts`)
- Puzzle play → Game client: loads and submits (evidence: `src/pages/Play.tsx`)
- Puzzle play → Puzzle interface: renders (evidence: `src/pages/Play.tsx`)
- Puzzle play → Game timer: renders (evidence: `src/pages/Play.tsx`)
- Puzzle play → Hint dialog: renders (evidence: `src/pages/Play.tsx`)
- Puzzle play → Win and secret message: renders (evidence: `src/pages/Play.tsx`)
- Puzzle play → Auth state: checks session (evidence: `src/pages/Play.tsx`)
- Game client → HTTP client: uses HTTP (evidence: `src/lib/game.ts`)
- Global rankings → Ranking client: loads rankings (evidence: `src/lib/ranking.ts`)
- Global rankings → Realtime client: connects realtime (evidence: `src/pages/HallOfFame.tsx`)
- Personal records → Game client: loads history (evidence: `src/pages/MyRecords.tsx`)
- HTTP client → FastAPI app: sends API requests
- FastAPI app → API router: mounts router (evidence: `backend/app/main.py`)
- FastAPI app → Socket.IO server: mounts Socket.IO (evidence: `backend/app/main.py`)
- API router → Authentication: registers routes (evidence: `backend/app/api/v1/api.py`)
- API router → Game records: registers routes (evidence: `backend/app/api/v1/api.py`)
- API router → Puzzle service: registers routes (evidence: `backend/app/api/v1/api.py`)
- API router → Ranking service: registers routes (evidence: `backend/app/api/v1/api.py`)
- Authentication → SQL database: reads and writes (evidence: `backend/app/api/v1/endpoints/auth.py`)
- Authentication → Player: issues token (evidence: `backend/app/api/v1/endpoints/auth.py`)
- Game records → SQL database: stores history
- Puzzle service → Puzzle image assets: serves puzzle assets
- Ranking service → Redis rankings: updates rankings
- Ranking service → SQL database: reads records
- Socket.IO server → Global rankings: publishes live updates
