# jtomaspm/forgotten-realms architecture

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

- Interactive diagram: https://gitdiagram.com/jtomaspm/forgotten-realms
- Repository: https://github.com/jtomaspm/forgotten-realms

## Overview

This workspace implements a multiplayer realm game: authentication and realm servers, a browser client, a shared API SDK, and a CLI-backed database migration library. The realm server coordinates HTTP APIs, an event hub, and a simulation; the client includes map retrieval and rendering. The README is empty, and several important modules were not excerpted, so the graph preserves documented-by-source-index capabilities but omits uncertain runtime connections. Edges reflect only shown calls or source-index references.

Main entry points: [`realm_server/src/server.rs`](https://github.com/jtomaspm/forgotten-realms/blob/main/realm_server/src/server.rs) (Realm Server), [`auth_server/src/server.rs`](https://github.com/jtomaspm/forgotten-realms/blob/main/auth_server/src/server.rs) (Auth Server), [`web_client/client/src/pages/map/page.ts`](https://github.com/jtomaspm/forgotten-realms/blob/main/web_client/client/src/pages/map/page.ts) (Map Page), [`web_client/client/src/pages/map/render.ts`](https://github.com/jtomaspm/forgotten-realms/blob/main/web_client/client/src/pages/map/render.ts) (Map Renderer)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_realm["Realm Server"]
  node_player["Player API<br/>[player.rs]"]
  node_realm_api["Realm API<br/>[api.rs]"]
  node_realm_server["Realm Server<br/>[server.rs]"]
  node_realm_config["Realm Configuration<br/>[configuration.rs]"]
  node_realm_db["Realm Database Pool<br/>[database.rs]"]
  node_event_hub["Event Hub<br/>[event_hub.rs]"]
  node_event_types["Game Events<br/>[event.rs]"]
  node_simulation_io["Simulation I/O<br/>[simulation.rs]"]
  node_simulation["Game Simulation<br/>[simulation.rs]"]
  node_ecs["Entity Components<br/>[ecs.rs]"]
  node_sim_handlers["Simulation Handlers<br/>[event_handlers.rs]"]
  node_sim_tick["Simulation Tick<br/>[tick.rs]"]
end

subgraph group_auth["Authentication"]
  node_auth_api["Auth API<br/>[api.rs]"]
  node_auth_server["Auth Server<br/>[server.rs]"]
  node_auth_config["Auth Configuration<br/>[configuration.rs]"]
  node_auth_db["Auth Database Pool<br/>[database.rs]"]
  node_login_routes["Login Routes<br/>[login.rs]"]
  node_local_login["Local Login<br/>[local.rs]"]
  node_github_login["GitHub Login<br/>[github.rs]"]
  node_token_refresh["Token Refresh<br/>[refresh_token.rs]"]
  node_authenticate["Authentication<br/>[authenticate.rs]"]
  node_profile["User Profile<br/>[profile.rs]"]
end

subgraph group_client["Web Client"]
  node_frontend_router["Page Router<br/>[router.ts]"]
  node_framework_router["Component Router<br/>[router.ts]"]
  node_component["UI Components<br/>[component.ts]"]
  node_map_page["Map Page<br/>[page.ts]"]
  node_map_render["Map Renderer<br/>[render.ts]"]
  node_virtual_map["Virtual Map<br/>[virtual_map.ts]"]
  node_map_gateway["Map API Gateway<br/>[map.ts]"]
  node_game_types["Game API Types<br/>[types.ts]"]
  node_overview["Overview Page<br/>[page.ts]"]
end

subgraph group_shared["Shared API SDK"]
  node_sdk_config["Server Configurations<br/>[auth_server.rs]"]
  node_realm_sdk_config["Realm Configuration Types<br/>[realm_server.rs]"]
  node_sdk_requests["API Requests<br/>[requests.rs]"]
end

subgraph group_operations["Database Operations"]
end

node_realm_server -->|"loads config"| node_realm_config
node_realm_server -->|"creates pool"| node_realm_db
node_realm_server -->|"spawns"| node_event_hub
node_realm_server -->|"spawns"| node_simulation
node_realm_server -->|"serves"| node_realm_api
node_realm_server -->|"channels events"| node_event_types
node_realm_server -->|"sets up I/O"| node_simulation_io
node_realm_api -->|"mounts controller"| node_player
node_auth_server -->|"loads config"| node_auth_config
node_auth_server -->|"creates pool"| node_auth_db
node_auth_server -->|"serves"| node_auth_api
node_auth_api -->|"mounts routes"| node_login_routes
node_login_routes -->|"mounts"| node_local_login
node_frontend_router -->|"uses"| node_framework_router
node_frontend_router -->|"routes to"| node_map_page
node_framework_router -->|"renders"| node_component
node_map_page -->|"implements"| node_component
node_map_page -->|"uses"| node_map_render
node_map_render -->|"uses"| node_virtual_map
node_virtual_map -->|"reads map"| node_map_gateway
node_map_render -->|"uses types"| node_game_types
node_virtual_map -->|"uses types"| node_game_types
node_map_gateway -->|"uses types"| node_game_types

click node_player "https://github.com/jtomaspm/forgotten-realms/blob/main/realm_server/src/api/controller/player.rs"
click node_realm_api "https://github.com/jtomaspm/forgotten-realms/blob/main/realm_server/src/api.rs"
click node_realm_server "https://github.com/jtomaspm/forgotten-realms/blob/main/realm_server/src/server.rs"
click node_realm_config "https://github.com/jtomaspm/forgotten-realms/blob/main/realm_server/src/server/configuration.rs"
click node_realm_db "https://github.com/jtomaspm/forgotten-realms/blob/main/realm_server/src/server/database.rs"
click node_event_hub "https://github.com/jtomaspm/forgotten-realms/blob/main/realm_server/src/event_hub.rs"
click node_event_types "https://github.com/jtomaspm/forgotten-realms/blob/main/realm_server/src/event_hub/event.rs"
click node_simulation_io "https://github.com/jtomaspm/forgotten-realms/blob/main/realm_server/src/event_hub/simulation.rs"
click node_simulation "https://github.com/jtomaspm/forgotten-realms/blob/main/realm_server/src/simulation.rs"
click node_ecs "https://github.com/jtomaspm/forgotten-realms/blob/main/realm_server/src/simulation/ecs.rs"
click node_sim_handlers "https://github.com/jtomaspm/forgotten-realms/blob/main/realm_server/src/simulation/event_handlers.rs"
click node_sim_tick "https://github.com/jtomaspm/forgotten-realms/blob/main/realm_server/src/simulation/tick.rs"
click node_auth_api "https://github.com/jtomaspm/forgotten-realms/blob/main/auth_server/src/api.rs"
click node_auth_server "https://github.com/jtomaspm/forgotten-realms/blob/main/auth_server/src/server.rs"
click node_auth_config "https://github.com/jtomaspm/forgotten-realms/blob/main/auth_server/src/server/configuration.rs"
click node_auth_db "https://github.com/jtomaspm/forgotten-realms/blob/main/auth_server/src/server/database.rs"
click node_login_routes "https://github.com/jtomaspm/forgotten-realms/blob/main/auth_server/src/api/controller/login.rs"
click node_local_login "https://github.com/jtomaspm/forgotten-realms/blob/main/auth_server/src/api/controller/login/local.rs"
click node_github_login "https://github.com/jtomaspm/forgotten-realms/blob/main/auth_server/src/api/controller/login/github.rs"
click node_token_refresh "https://github.com/jtomaspm/forgotten-realms/blob/main/auth_server/src/api/controller/refresh_token.rs"
click node_authenticate "https://github.com/jtomaspm/forgotten-realms/blob/main/auth_server/src/api/controller/authenticate.rs"
click node_profile "https://github.com/jtomaspm/forgotten-realms/blob/main/auth_server/src/api/controller/profile.rs"
click node_frontend_router "https://github.com/jtomaspm/forgotten-realms/blob/main/web_client/client/src/pages/router.ts"
click node_framework_router "https://github.com/jtomaspm/forgotten-realms/blob/main/web_client/client/src/framework/router.ts"
click node_component "https://github.com/jtomaspm/forgotten-realms/blob/main/web_client/client/src/framework/component.ts"
click node_map_page "https://github.com/jtomaspm/forgotten-realms/blob/main/web_client/client/src/pages/map/page.ts"
click node_map_render "https://github.com/jtomaspm/forgotten-realms/blob/main/web_client/client/src/pages/map/render.ts"
click node_virtual_map "https://github.com/jtomaspm/forgotten-realms/blob/main/web_client/client/src/pages/map/virtual_map.ts"
click node_map_gateway "https://github.com/jtomaspm/forgotten-realms/blob/main/web_client/client/src/gateway/game_api/map.ts"
click node_game_types "https://github.com/jtomaspm/forgotten-realms/blob/main/web_client/client/src/gateway/game_api/types.ts"
click node_overview "https://github.com/jtomaspm/forgotten-realms/blob/main/web_client/client/src/pages/overview/page.ts"
click node_sdk_config "https://github.com/jtomaspm/forgotten-realms/blob/main/api_sdk/src/configuration/auth_server.rs"
click node_realm_sdk_config "https://github.com/jtomaspm/forgotten-realms/blob/main/api_sdk/src/configuration/realm_server.rs"
click node_sdk_requests "https://github.com/jtomaspm/forgotten-realms/blob/main/api_sdk/src/requests.rs"

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_player,node_realm_api,node_realm_server,node_realm_config,node_realm_db,node_event_hub,node_event_types,node_simulation_io,node_simulation,node_ecs,node_sim_handlers,node_sim_tick toneBlue
class node_auth_api,node_auth_server,node_auth_config,node_auth_db,node_login_routes,node_local_login,node_github_login,node_token_refresh,node_authenticate,node_profile toneAmber
class node_frontend_router,node_framework_router,node_component,node_map_page,node_map_render,node_virtual_map,node_map_gateway,node_game_types,node_overview toneMint
class node_sdk_config,node_realm_sdk_config,node_sdk_requests toneRose
```

## Components

### Realm Server

- [Player API](https://github.com/jtomaspm/forgotten-realms/blob/main/realm_server/src/api/controller/player.rs): `realm_server/src/api/controller/player.rs`
- [Realm API](https://github.com/jtomaspm/forgotten-realms/blob/main/realm_server/src/api.rs): `realm_server/src/api.rs`
- [Realm Server](https://github.com/jtomaspm/forgotten-realms/blob/main/realm_server/src/server.rs): `realm_server/src/server.rs`
- [Realm Configuration](https://github.com/jtomaspm/forgotten-realms/blob/main/realm_server/src/server/configuration.rs): `realm_server/src/server/configuration.rs`
- [Realm Database Pool](https://github.com/jtomaspm/forgotten-realms/blob/main/realm_server/src/server/database.rs): `realm_server/src/server/database.rs`
- [Event Hub](https://github.com/jtomaspm/forgotten-realms/blob/main/realm_server/src/event_hub.rs): `realm_server/src/event_hub.rs`
- [Game Events](https://github.com/jtomaspm/forgotten-realms/blob/main/realm_server/src/event_hub/event.rs): `realm_server/src/event_hub/event.rs`
- [Simulation I/O](https://github.com/jtomaspm/forgotten-realms/blob/main/realm_server/src/event_hub/simulation.rs): `realm_server/src/event_hub/simulation.rs`
- [Game Simulation](https://github.com/jtomaspm/forgotten-realms/blob/main/realm_server/src/simulation.rs): `realm_server/src/simulation.rs`
- [Entity Components](https://github.com/jtomaspm/forgotten-realms/blob/main/realm_server/src/simulation/ecs.rs): `realm_server/src/simulation/ecs.rs`
- [Simulation Handlers](https://github.com/jtomaspm/forgotten-realms/blob/main/realm_server/src/simulation/event_handlers.rs): `realm_server/src/simulation/event_handlers.rs`
- [Simulation Tick](https://github.com/jtomaspm/forgotten-realms/blob/main/realm_server/src/simulation/tick.rs): `realm_server/src/simulation/tick.rs`

### Authentication

- [Auth API](https://github.com/jtomaspm/forgotten-realms/blob/main/auth_server/src/api.rs): `auth_server/src/api.rs`
- [Auth Server](https://github.com/jtomaspm/forgotten-realms/blob/main/auth_server/src/server.rs): `auth_server/src/server.rs`
- [Auth Configuration](https://github.com/jtomaspm/forgotten-realms/blob/main/auth_server/src/server/configuration.rs): `auth_server/src/server/configuration.rs`
- [Auth Database Pool](https://github.com/jtomaspm/forgotten-realms/blob/main/auth_server/src/server/database.rs): `auth_server/src/server/database.rs`
- [Login Routes](https://github.com/jtomaspm/forgotten-realms/blob/main/auth_server/src/api/controller/login.rs): `auth_server/src/api/controller/login.rs`
- [Local Login](https://github.com/jtomaspm/forgotten-realms/blob/main/auth_server/src/api/controller/login/local.rs): `auth_server/src/api/controller/login/local.rs`
- [GitHub Login](https://github.com/jtomaspm/forgotten-realms/blob/main/auth_server/src/api/controller/login/github.rs): `auth_server/src/api/controller/login/github.rs`
- [Token Refresh](https://github.com/jtomaspm/forgotten-realms/blob/main/auth_server/src/api/controller/refresh_token.rs): `auth_server/src/api/controller/refresh_token.rs`
- [Authentication](https://github.com/jtomaspm/forgotten-realms/blob/main/auth_server/src/api/controller/authenticate.rs): `auth_server/src/api/controller/authenticate.rs`
- [User Profile](https://github.com/jtomaspm/forgotten-realms/blob/main/auth_server/src/api/controller/profile.rs): `auth_server/src/api/controller/profile.rs`

### Web Client

- [Page Router](https://github.com/jtomaspm/forgotten-realms/blob/main/web_client/client/src/pages/router.ts): `web_client/client/src/pages/router.ts`
- [Component Router](https://github.com/jtomaspm/forgotten-realms/blob/main/web_client/client/src/framework/router.ts): `web_client/client/src/framework/router.ts`
- [UI Components](https://github.com/jtomaspm/forgotten-realms/blob/main/web_client/client/src/framework/component.ts): `web_client/client/src/framework/component.ts`
- [Map Page](https://github.com/jtomaspm/forgotten-realms/blob/main/web_client/client/src/pages/map/page.ts): `web_client/client/src/pages/map/page.ts`
- [Map Renderer](https://github.com/jtomaspm/forgotten-realms/blob/main/web_client/client/src/pages/map/render.ts): `web_client/client/src/pages/map/render.ts`
- [Virtual Map](https://github.com/jtomaspm/forgotten-realms/blob/main/web_client/client/src/pages/map/virtual_map.ts): `web_client/client/src/pages/map/virtual_map.ts`
- [Map API Gateway](https://github.com/jtomaspm/forgotten-realms/blob/main/web_client/client/src/gateway/game_api/map.ts): `web_client/client/src/gateway/game_api/map.ts`
- [Game API Types](https://github.com/jtomaspm/forgotten-realms/blob/main/web_client/client/src/gateway/game_api/types.ts): `web_client/client/src/gateway/game_api/types.ts`
- [Overview Page](https://github.com/jtomaspm/forgotten-realms/blob/main/web_client/client/src/pages/overview/page.ts): `web_client/client/src/pages/overview/page.ts`

### Shared API SDK

- [Server Configurations](https://github.com/jtomaspm/forgotten-realms/blob/main/api_sdk/src/configuration/auth_server.rs): `api_sdk/src/configuration/auth_server.rs`
- [Realm Configuration Types](https://github.com/jtomaspm/forgotten-realms/blob/main/api_sdk/src/configuration/realm_server.rs): `api_sdk/src/configuration/realm_server.rs`
- [API Requests](https://github.com/jtomaspm/forgotten-realms/blob/main/api_sdk/src/requests.rs): `api_sdk/src/requests.rs`

## Connections

- Realm Server → Realm Configuration: loads config (evidence: `realm_server/src/server.rs`)
- Realm Server → Realm Database Pool: creates pool (evidence: `realm_server/src/server.rs`)
- Realm Server → Event Hub: spawns (evidence: `realm_server/src/server.rs`)
- Realm Server → Game Simulation: spawns (evidence: `realm_server/src/server.rs`)
- Realm Server → Realm API: serves (evidence: `realm_server/src/server.rs`)
- Realm Server → Game Events: channels events (evidence: `realm_server/src/server.rs`)
- Realm Server → Simulation I/O: sets up I/O (evidence: `realm_server/src/server.rs`)
- Realm API → Player API: mounts controller
- Auth Server → Auth Configuration: loads config (evidence: `auth_server/src/server.rs`)
- Auth Server → Auth Database Pool: creates pool (evidence: `auth_server/src/server.rs`)
- Auth Server → Auth API: serves (evidence: `auth_server/src/server.rs`)
- Auth API → Login Routes: mounts routes
- Login Routes → Local Login: mounts (evidence: `auth_server/src/api/controller/login.rs`)
- Page Router → Component Router: uses (evidence: `web_client/client/src/pages/router.ts`)
- Page Router → Map Page: routes to (evidence: `web_client/client/src/pages/router.ts`)
- Component Router → UI Components: renders (evidence: `web_client/client/src/framework/router.ts`)
- Map Page → UI Components: implements (evidence: `web_client/client/src/pages/map/page.ts`)
- Map Page → Map Renderer: uses (evidence: `web_client/client/src/pages/map/page.ts`)
- Map Renderer → Virtual Map: uses (evidence: `web_client/client/src/pages/map/render.ts`)
- Virtual Map → Map API Gateway: reads map (evidence: `web_client/client/src/pages/map/virtual_map.ts`)
- Map Renderer → Game API Types: uses types (evidence: `web_client/client/src/pages/map/render.ts`)
- Virtual Map → Game API Types: uses types (evidence: `web_client/client/src/pages/map/virtual_map.ts`)
- Map API Gateway → Game API Types: uses types (evidence: `web_client/client/src/gateway/game_api/map.ts`)
