# gavinhos60/rpg-de-mesa architecture

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

- Interactive diagram: https://gitdiagram.com/gavinhos60/rpg-de-mesa
- Repository: https://github.com/gavinhos60/rpg-de-mesa

## Overview

This is a tabletop RPG campaign and play platform: users authenticate, build characters, organize campaigns and players, then run shared game sessions. The frontend also exposes campaign tools for shops, notes and Papiros documents. The backend is an Express API with domain services and Prisma persistence, plus a Socket.IO game gateway. The tree and excerpts establish these product areas, but README content is absent and most subsystem implementations were not sampled; uncertain internal wiring is therefore omitted.

Main entry points: [`backend/src/lib/prisma.ts`](https://github.com/gavinhos60/rpg-de-mesa/blob/master/backend/src/lib/prisma.ts) (Application database), [`frontend/src/App.tsx`](https://github.com/gavinhos60/rpg-de-mesa/blob/master/frontend/src/App.tsx) (Application routes), [`frontend/src/services/api.ts`](https://github.com/gavinhos60/rpg-de-mesa/blob/master/frontend/src/services/api.ts) (HTTP client), [`frontend/src/pages/CharacterSheet.tsx`](https://github.com/gavinhos60/rpg-de-mesa/blob/master/frontend/src/pages/CharacterSheet.tsx) (Character pages)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Player interface"]
  node_app["Application routes<br/>[App.tsx]"]
  node_auth_ui["Login UI<br/>[Login.tsx]"]
  node_campaign_ui["Campaign pages<br/>[Campaign.tsx]"]
  node_character_ui["Character pages<br/>[CharacterSheet.tsx]"]
  node_game_ui["Game room<br/>[GameRoom.tsx]"]
  node_game_components["Play controls<br/>[GameBoard.tsx]"]
  node_shop_ui["Shop screens<br/>[ShopBrowser.tsx]"]
end

subgraph group_rules["Character rules"]
  node_character_data["RPG rules data"]
  node_character_api["Character client"]
end

subgraph group_api["Campaign API"]
  node_auth_client["Auth client<br/>[auth.service.ts]"]
  node_http_client["HTTP client<br/>[api.ts]"]
  node_server["HTTP server<br/>[server.ts]"]
  node_character_routes["Character routes"]
  node_character_controller["Character handlers"]
  node_character_service["Character operations"]
  node_auth_service["Identity service<br/>[auth.service.ts]"]
  node_campaign_services["Campaign domains"]
  node_shop_service["Shop operations<br/>[mercado.service.ts]"]
  node_notes_service["Campaign notes<br/>[notes.service.ts]"]
  node_papiros_service["Shared documents<br/>[papiros.service.ts]"]
end

subgraph group_runtime["Game runtime"]
  node_session_service["Session operations"]
  node_session_state["Board state<br/>[gameTypes.ts]"]
  node_socket_gateway["Live game gateway<br/>[game.gateway.ts]"]
end

node_user(("Player or GM"))
node_database[("Application database<br/>[prisma.ts]")]

node_user -->|"uses"| node_app
node_app -->|"routes to"| node_auth_ui
node_app -->|"routes to"| node_campaign_ui
node_app -->|"routes to"| node_character_ui
node_app -->|"routes to"| node_game_ui
node_auth_ui -->|"requests auth"| node_auth_client
node_auth_client -->|"sends requests"| node_http_client
node_character_ui -->|"requests character data"| node_character_api
node_character_ui -->|"uses rules"| node_character_data
node_game_ui -->|"renders"| node_game_components
node_campaign_ui -->|"requests campaign data"| node_http_client
node_shop_ui -->|"requests shop data"| node_http_client
node_http_client -->|"HTTP requests"| node_server
node_server -->|"mounts routes"| node_character_routes
node_character_routes -->|"dispatches"| node_character_controller
node_character_controller -->|"calls"| node_character_service
node_auth_service -->|"reads and writes"| node_database
node_character_service -->|"reads and writes"| node_database
node_campaign_services -->|"reads and writes"| node_database
node_shop_service -->|"reads and writes"| node_database
node_session_service -->|"reads and writes"| node_database
node_session_service -->|"normalizes state"| node_session_state
node_server -->|"attaches socket"| node_socket_gateway
node_game_ui -->|"live game events"| node_socket_gateway
node_notes_service -->|"reads and writes"| node_database
node_papiros_service -->|"reads and writes"| node_database

click node_app "https://github.com/gavinhos60/rpg-de-mesa/blob/master/frontend/src/App.tsx"
click node_auth_ui "https://github.com/gavinhos60/rpg-de-mesa/blob/master/frontend/src/pages/Login.tsx"
click node_campaign_ui "https://github.com/gavinhos60/rpg-de-mesa/blob/master/frontend/src/pages/Campaign.tsx"
click node_character_ui "https://github.com/gavinhos60/rpg-de-mesa/blob/master/frontend/src/pages/CharacterSheet.tsx"
click node_game_ui "https://github.com/gavinhos60/rpg-de-mesa/blob/master/frontend/src/pages/GameRoom.tsx"
click node_game_components "https://github.com/gavinhos60/rpg-de-mesa/blob/master/frontend/src/components/game/GameBoard.tsx"
click node_character_data "https://github.com/gavinhos60/rpg-de-mesa/blob/master/frontend/src/data/dnd/characterCreation.ts"
click node_character_api "https://github.com/gavinhos60/rpg-de-mesa/blob/master/frontend/src/services/character.service.ts"
click node_auth_client "https://github.com/gavinhos60/rpg-de-mesa/blob/master/frontend/src/services/auth.service.ts"
click node_http_client "https://github.com/gavinhos60/rpg-de-mesa/blob/master/frontend/src/services/api.ts"
click node_server "https://github.com/gavinhos60/rpg-de-mesa/blob/master/backend/src/server.ts"
click node_character_routes "https://github.com/gavinhos60/rpg-de-mesa/blob/master/backend/src/routes/characters.routes.ts"
click node_character_controller "https://github.com/gavinhos60/rpg-de-mesa/blob/master/backend/src/controllers/characters.controller.ts"
click node_character_service "https://github.com/gavinhos60/rpg-de-mesa/blob/master/backend/src/services/characters.service.ts"
click node_auth_service "https://github.com/gavinhos60/rpg-de-mesa/blob/master/backend/src/services/auth.service.ts"
click node_campaign_services "https://github.com/gavinhos60/rpg-de-mesa/blob/master/backend/src/services/campaigns.service.ts"
click node_shop_service "https://github.com/gavinhos60/rpg-de-mesa/blob/master/backend/src/services/mercado.service.ts"
click node_session_service "https://github.com/gavinhos60/rpg-de-mesa/blob/master/backend/src/services/sessions.service.ts"
click node_session_state "https://github.com/gavinhos60/rpg-de-mesa/blob/master/backend/src/lib/gameTypes.ts"
click node_socket_gateway "https://github.com/gavinhos60/rpg-de-mesa/blob/master/backend/src/socket/game.gateway.ts"
click node_database "https://github.com/gavinhos60/rpg-de-mesa/blob/master/backend/src/lib/prisma.ts"
click node_notes_service "https://github.com/gavinhos60/rpg-de-mesa/blob/master/backend/src/services/notes.service.ts"
click node_papiros_service "https://github.com/gavinhos60/rpg-de-mesa/blob/master/backend/src/services/papiros.service.ts"
click node_shop_ui "https://github.com/gavinhos60/rpg-de-mesa/blob/master/frontend/src/components/game/ShopBrowser.tsx"

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_auth_ui,node_campaign_ui,node_character_ui,node_game_ui,node_game_components,node_shop_ui toneBlue
class node_character_data,node_character_api,node_database toneAmber
class node_auth_client,node_http_client,node_server,node_character_routes,node_character_controller,node_character_service,node_auth_service,node_campaign_services,node_shop_service,node_notes_service,node_papiros_service toneMint
class node_session_service,node_session_state,node_socket_gateway toneRose
class node_user toneIndigo
```

## Components

### Player interface

- [Application routes](https://github.com/gavinhos60/rpg-de-mesa/blob/master/frontend/src/App.tsx): `frontend/src/App.tsx`
- [Login UI](https://github.com/gavinhos60/rpg-de-mesa/blob/master/frontend/src/pages/Login.tsx): `frontend/src/pages/Login.tsx`
- [Campaign pages](https://github.com/gavinhos60/rpg-de-mesa/blob/master/frontend/src/pages/Campaign.tsx): `frontend/src/pages/Campaign.tsx`
- [Character pages](https://github.com/gavinhos60/rpg-de-mesa/blob/master/frontend/src/pages/CharacterSheet.tsx): `frontend/src/pages/CharacterSheet.tsx`
- [Game room](https://github.com/gavinhos60/rpg-de-mesa/blob/master/frontend/src/pages/GameRoom.tsx): `frontend/src/pages/GameRoom.tsx`
- [Play controls](https://github.com/gavinhos60/rpg-de-mesa/blob/master/frontend/src/components/game/GameBoard.tsx): `frontend/src/components/game/GameBoard.tsx`
- [Shop screens](https://github.com/gavinhos60/rpg-de-mesa/blob/master/frontend/src/components/game/ShopBrowser.tsx): `frontend/src/components/game/ShopBrowser.tsx`

### Character rules

- [RPG rules data](https://github.com/gavinhos60/rpg-de-mesa/blob/master/frontend/src/data/dnd/characterCreation.ts): `frontend/src/data/dnd/characterCreation.ts`
- [Character client](https://github.com/gavinhos60/rpg-de-mesa/blob/master/frontend/src/services/character.service.ts): `frontend/src/services/character.service.ts`

### Campaign API

- [Auth client](https://github.com/gavinhos60/rpg-de-mesa/blob/master/frontend/src/services/auth.service.ts): `frontend/src/services/auth.service.ts`
- [HTTP client](https://github.com/gavinhos60/rpg-de-mesa/blob/master/frontend/src/services/api.ts): `frontend/src/services/api.ts`
- [HTTP server](https://github.com/gavinhos60/rpg-de-mesa/blob/master/backend/src/server.ts): `backend/src/server.ts`
- [Character routes](https://github.com/gavinhos60/rpg-de-mesa/blob/master/backend/src/routes/characters.routes.ts): `backend/src/routes/characters.routes.ts`
- [Character handlers](https://github.com/gavinhos60/rpg-de-mesa/blob/master/backend/src/controllers/characters.controller.ts): `backend/src/controllers/characters.controller.ts`
- [Character operations](https://github.com/gavinhos60/rpg-de-mesa/blob/master/backend/src/services/characters.service.ts): `backend/src/services/characters.service.ts`
- [Identity service](https://github.com/gavinhos60/rpg-de-mesa/blob/master/backend/src/services/auth.service.ts): `backend/src/services/auth.service.ts`
- [Campaign domains](https://github.com/gavinhos60/rpg-de-mesa/blob/master/backend/src/services/campaigns.service.ts): `backend/src/services/campaigns.service.ts`
- [Shop operations](https://github.com/gavinhos60/rpg-de-mesa/blob/master/backend/src/services/mercado.service.ts): `backend/src/services/mercado.service.ts`
- [Campaign notes](https://github.com/gavinhos60/rpg-de-mesa/blob/master/backend/src/services/notes.service.ts): `backend/src/services/notes.service.ts`
- [Shared documents](https://github.com/gavinhos60/rpg-de-mesa/blob/master/backend/src/services/papiros.service.ts): `backend/src/services/papiros.service.ts`

### Game runtime

- [Session operations](https://github.com/gavinhos60/rpg-de-mesa/blob/master/backend/src/services/sessions.service.ts): `backend/src/services/sessions.service.ts`
- [Board state](https://github.com/gavinhos60/rpg-de-mesa/blob/master/backend/src/lib/gameTypes.ts): `backend/src/lib/gameTypes.ts`
- [Live game gateway](https://github.com/gavinhos60/rpg-de-mesa/blob/master/backend/src/socket/game.gateway.ts): `backend/src/socket/game.gateway.ts`

### Other components

- **Player or GM**
- [Application database](https://github.com/gavinhos60/rpg-de-mesa/blob/master/backend/src/lib/prisma.ts): `backend/src/lib/prisma.ts`

## Connections

- Player or GM → Application routes: uses
- Application routes → Login UI: routes to
- Application routes → Campaign pages: routes to
- Application routes → Character pages: routes to
- Application routes → Game room: routes to
- Login UI → Auth client: requests auth
- Auth client → HTTP client: sends requests
- Character pages → Character client: requests character data
- Character pages → RPG rules data: uses rules
- Game room → Play controls: renders
- Campaign pages → HTTP client: requests campaign data
- Shop screens → HTTP client: requests shop data
- HTTP client → HTTP server: HTTP requests
- HTTP server → Character routes: mounts routes
- Character routes → Character handlers: dispatches
- Character handlers → Character operations: calls
- Identity service → Application database: reads and writes
- Character operations → Application database: reads and writes
- Campaign domains → Application database: reads and writes
- Shop operations → Application database: reads and writes
- Session operations → Application database: reads and writes
- Session operations → Board state: normalizes state
- HTTP server → Live game gateway: attaches socket
- Game room → Live game gateway: live game events
- Campaign notes → Application database: reads and writes
- Shared documents → Application database: reads and writes
