# denkripton/dnd-character_sheet architecture

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

- Interactive diagram: https://gitdiagram.com/denkripton/dnd-character_sheet
- Repository: https://github.com/denkripton/dnd-character_sheet

## Overview

This repository combines a character-generation backend with a Telegram bot and a small Telegram mini-app client. The principal workflow is character creation or editing: the bot guides a user through a draft and generation choices, then backend character services validate and persist the result. The tree also shows authentication, AI-provider/model discovery, character subdomains, health checks, and messaging capabilities. The README is empty and most modules were not sampled, so the graph preserves these subsystems but omits unverified runtime links; cited edges reflect only shown references or calls.

Main entry points: [`backend/src/modules/character/draft/service.py`](https://github.com/denkripton/dnd-character_sheet/blob/main/backend/src/modules/character/draft/service.py) (Draft lifecycle), [`backend/src/modules/character/backstory/service.py`](https://github.com/denkripton/dnd-character_sheet/blob/main/backend/src/modules/character/backstory/service.py) (Backstory generation), [`bot/app/modules/character/router.py`](https://github.com/denkripton/dnd-character_sheet/blob/main/bot/app/modules/character/router.py) (Character interaction), [`bot/app/main.py`](https://github.com/denkripton/dnd-character_sheet/blob/main/bot/app/main.py) (Bot runtime)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_bot["Telegram bot"]
  node_bot_runtime["Bot runtime<br/>[main.py]"]
  node_start_flow["Start and auth<br/>[router.py]"]
  node_character_flow["Character interaction<br/>[router.py]"]
  node_backstory_flow["Backstory interaction<br/>[router.py]"]
  node_bot_creation["Creation service<br/>[service.py]"]
  node_bot_auth["Bot auth service<br/>[service.py]"]
  node_bot_http["Backend HTTP client<br/>[client.py]"]
  node_mini_app["Mini-app client<br/>[main.tsx]"]
end

subgraph group_character["Character domain"]
  node_character_drafts["Draft lifecycle<br/>[service.py]"]
  node_character_base["Character management<br/>[service.py]"]
  node_character_subdomains["Character details"]
  node_backstory_service["Backstory generation<br/>[service.py]"]
end

subgraph group_backend["Backend services"]
  node_auth_service["External authentication"]
  node_auth_data[("User identities")]
  node_ai_catalog["AI model catalog"]
  node_character_data[("Character repositories")]
  node_health["Health checks"]
end

subgraph group_infra["Infrastructure"]
  node_settings["Application settings<br/>[config.py]"]
  node_unit_of_work["Unit of work<br/>[unit_of_work.py]"]
  node_redis_cache[("Redis cache<br/>[cache.py]")]
  node_rate_limit["Rate limiting interface<br/>[rate_limiter.py]"]
  node_rabbit_client["RabbitMQ client<br/>[client.py]"]
  node_message_bus["Backend messaging<br/>[dispatcher.py]"]
end

node_user(("Telegram user"))

node_user -.->|"starts interaction"| node_start_flow
node_bot_runtime -->|"starts polling"| node_start_flow
node_bot_runtime -->|"starts client"| node_rabbit_client
node_bot_runtime -->|"provides service"| node_bot_creation
node_bot_runtime -.->|"registers handlers"| node_character_flow
node_start_flow -->|"routes to"| node_character_flow
node_start_flow -->|"routes to"| node_mini_app
node_character_flow -->|"calls"| node_bot_creation
node_character_flow -->|"uses controls"| node_backstory_flow
node_backstory_flow -->|"uses controls"| node_character_flow
node_bot_auth -->|"uses client"| node_bot_http
node_bot_creation -->|"uses messaging"| node_rabbit_client
node_auth_service -->|"reads and writes"| node_auth_data
node_auth_service -->|"commits changes"| node_unit_of_work
node_character_drafts -->|"reads and writes"| node_character_data
node_character_drafts -->|"commits changes"| node_unit_of_work
node_character_drafts -->|"uses cache"| node_redis_cache
node_character_drafts -->|"checks limits"| node_rate_limit
node_character_drafts -->|"reads limits"| node_settings
node_character_base -->|"reads and writes"| node_character_data
node_character_base -->|"commits changes"| node_unit_of_work
node_character_base -->|"uses cache"| node_redis_cache
node_backstory_service -->|"uses repositories"| node_character_data
node_backstory_service -->|"uses transactions"| node_unit_of_work
node_backstory_service -->|"uses cache"| node_redis_cache
node_backstory_service -->|"checks limits"| node_rate_limit
node_backstory_service -->|"uses AI module"| node_ai_catalog
node_rabbit_client -->|"uses backend bus"| node_message_bus

click node_bot_runtime "https://github.com/denkripton/dnd-character_sheet/blob/main/bot/app/main.py"
click node_start_flow "https://github.com/denkripton/dnd-character_sheet/blob/main/bot/app/modules/start/router.py"
click node_character_flow "https://github.com/denkripton/dnd-character_sheet/blob/main/bot/app/modules/character/router.py"
click node_backstory_flow "https://github.com/denkripton/dnd-character_sheet/blob/main/bot/app/modules/backstory/router.py"
click node_bot_creation "https://github.com/denkripton/dnd-character_sheet/blob/main/bot/app/modules/character/service.py"
click node_bot_auth "https://github.com/denkripton/dnd-character_sheet/blob/main/bot/app/modules/auth/service.py"
click node_bot_http "https://github.com/denkripton/dnd-character_sheet/blob/main/bot/app/infrastructure/http/client.py"
click node_mini_app "https://github.com/denkripton/dnd-character_sheet/blob/main/mini-app/src/main.tsx"
click node_auth_service "https://github.com/denkripton/dnd-character_sheet/blob/main/backend/src/modules/auth/external_service.py"
click node_auth_data "https://github.com/denkripton/dnd-character_sheet/tree/main/backend/src/modules/auth/repository"
click node_character_drafts "https://github.com/denkripton/dnd-character_sheet/blob/main/backend/src/modules/character/draft/service.py"
click node_character_base "https://github.com/denkripton/dnd-character_sheet/blob/main/backend/src/modules/character/base/service.py"
click node_character_subdomains "https://github.com/denkripton/dnd-character_sheet/tree/main/backend/src/modules/character"
click node_backstory_service "https://github.com/denkripton/dnd-character_sheet/blob/main/backend/src/modules/character/backstory/service.py"
click node_ai_catalog "https://github.com/denkripton/dnd-character_sheet/tree/main/backend/src/modules/ai"
click node_character_data "https://github.com/denkripton/dnd-character_sheet/tree/main/backend/src/modules/character/repositories"
click node_settings "https://github.com/denkripton/dnd-character_sheet/blob/main/backend/src/config.py"
click node_unit_of_work "https://github.com/denkripton/dnd-character_sheet/blob/main/backend/src/databases/unit_of_work.py"
click node_redis_cache "https://github.com/denkripton/dnd-character_sheet/blob/main/backend/src/infrastructure/redis/cache.py"
click node_rate_limit "https://github.com/denkripton/dnd-character_sheet/blob/main/backend/src/utils/interfaces/rate_limiter.py"
click node_rabbit_client "https://github.com/denkripton/dnd-character_sheet/blob/main/bot/app/infrastructure/rabbitmq/client.py"
click node_message_bus "https://github.com/denkripton/dnd-character_sheet/blob/main/backend/src/messaging/dispatcher.py"
click node_health "https://github.com/denkripton/dnd-character_sheet/tree/main/backend/src/modules/health"

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_bot_runtime,node_start_flow,node_character_flow,node_backstory_flow,node_bot_creation,node_bot_auth,node_bot_http,node_mini_app,node_user toneBlue
class node_character_drafts,node_character_base,node_character_subdomains,node_backstory_service toneAmber
class node_auth_service,node_auth_data,node_ai_catalog,node_character_data,node_health toneMint
class node_settings,node_unit_of_work,node_redis_cache,node_rate_limit,node_rabbit_client,node_message_bus toneRose
```

## Components

### Telegram bot

- [Bot runtime](https://github.com/denkripton/dnd-character_sheet/blob/main/bot/app/main.py): `bot/app/main.py`
- [Start and auth](https://github.com/denkripton/dnd-character_sheet/blob/main/bot/app/modules/start/router.py): `bot/app/modules/start/router.py`
- [Character interaction](https://github.com/denkripton/dnd-character_sheet/blob/main/bot/app/modules/character/router.py): `bot/app/modules/character/router.py`
- [Backstory interaction](https://github.com/denkripton/dnd-character_sheet/blob/main/bot/app/modules/backstory/router.py): `bot/app/modules/backstory/router.py`
- [Creation service](https://github.com/denkripton/dnd-character_sheet/blob/main/bot/app/modules/character/service.py): `bot/app/modules/character/service.py`
- [Bot auth service](https://github.com/denkripton/dnd-character_sheet/blob/main/bot/app/modules/auth/service.py): `bot/app/modules/auth/service.py`
- [Backend HTTP client](https://github.com/denkripton/dnd-character_sheet/blob/main/bot/app/infrastructure/http/client.py): `bot/app/infrastructure/http/client.py`
- [Mini-app client](https://github.com/denkripton/dnd-character_sheet/blob/main/mini-app/src/main.tsx): `mini-app/src/main.tsx`

### Character domain

- [Draft lifecycle](https://github.com/denkripton/dnd-character_sheet/blob/main/backend/src/modules/character/draft/service.py): `backend/src/modules/character/draft/service.py`
- [Character management](https://github.com/denkripton/dnd-character_sheet/blob/main/backend/src/modules/character/base/service.py): `backend/src/modules/character/base/service.py`
- [Character details](https://github.com/denkripton/dnd-character_sheet/tree/main/backend/src/modules/character): `backend/src/modules/character`
- [Backstory generation](https://github.com/denkripton/dnd-character_sheet/blob/main/backend/src/modules/character/backstory/service.py): `backend/src/modules/character/backstory/service.py`

### Backend services

- [External authentication](https://github.com/denkripton/dnd-character_sheet/blob/main/backend/src/modules/auth/external_service.py): `backend/src/modules/auth/external_service.py`
- [User identities](https://github.com/denkripton/dnd-character_sheet/tree/main/backend/src/modules/auth/repository): `backend/src/modules/auth/repository`
- [AI model catalog](https://github.com/denkripton/dnd-character_sheet/tree/main/backend/src/modules/ai): `backend/src/modules/ai`
- [Character repositories](https://github.com/denkripton/dnd-character_sheet/tree/main/backend/src/modules/character/repositories): `backend/src/modules/character/repositories`
- [Health checks](https://github.com/denkripton/dnd-character_sheet/tree/main/backend/src/modules/health): `backend/src/modules/health`

### Infrastructure

- [Application settings](https://github.com/denkripton/dnd-character_sheet/blob/main/backend/src/config.py): `backend/src/config.py`
- [Unit of work](https://github.com/denkripton/dnd-character_sheet/blob/main/backend/src/databases/unit_of_work.py): `backend/src/databases/unit_of_work.py`
- [Redis cache](https://github.com/denkripton/dnd-character_sheet/blob/main/backend/src/infrastructure/redis/cache.py): `backend/src/infrastructure/redis/cache.py`
- [Rate limiting interface](https://github.com/denkripton/dnd-character_sheet/blob/main/backend/src/utils/interfaces/rate_limiter.py): `backend/src/utils/interfaces/rate_limiter.py`
- [RabbitMQ client](https://github.com/denkripton/dnd-character_sheet/blob/main/bot/app/infrastructure/rabbitmq/client.py): `bot/app/infrastructure/rabbitmq/client.py`
- [Backend messaging](https://github.com/denkripton/dnd-character_sheet/blob/main/backend/src/messaging/dispatcher.py): `backend/src/messaging/dispatcher.py`

### Other components

- **Telegram user**

## Connections

- Telegram user → Start and auth: starts interaction
- Bot runtime → Start and auth: starts polling (evidence: `bot/app/main.py`)
- Bot runtime → RabbitMQ client: starts client (evidence: `bot/app/main.py`)
- Bot runtime → Creation service: provides service (evidence: `bot/app/main.py`)
- Bot runtime → Character interaction: registers handlers
- Start and auth → Character interaction: routes to (evidence: `bot/app/modules/start/router.py`)
- Start and auth → Mini-app client: routes to (evidence: `bot/app/modules/start/router.py`)
- Character interaction → Creation service: calls (evidence: `bot/app/modules/character/router.py`)
- Character interaction → Backstory interaction: uses controls (evidence: `bot/app/modules/character/router.py`)
- Backstory interaction → Character interaction: uses controls (evidence: `bot/app/modules/backstory/router.py`)
- Bot auth service → Backend HTTP client: uses client (evidence: `bot/app/modules/auth/service.py`)
- Creation service → RabbitMQ client: uses messaging (evidence: `bot/app/modules/character/service.py`)
- External authentication → User identities: reads and writes (evidence: `backend/src/modules/auth/external_service.py`)
- External authentication → Unit of work: commits changes (evidence: `backend/src/modules/auth/external_service.py`)
- Draft lifecycle → Character repositories: reads and writes (evidence: `backend/src/modules/character/draft/service.py`)
- Draft lifecycle → Unit of work: commits changes (evidence: `backend/src/modules/character/draft/service.py`)
- Draft lifecycle → Redis cache: uses cache (evidence: `backend/src/modules/character/draft/service.py`)
- Draft lifecycle → Rate limiting interface: checks limits (evidence: `backend/src/modules/character/draft/service.py`)
- Draft lifecycle → Application settings: reads limits (evidence: `backend/src/modules/character/draft/service.py`)
- Character management → Character repositories: reads and writes (evidence: `backend/src/modules/character/base/service.py`)
- Character management → Unit of work: commits changes (evidence: `backend/src/modules/character/base/service.py`)
- Character management → Redis cache: uses cache (evidence: `backend/src/modules/character/base/service.py`)
- Backstory generation → Character repositories: uses repositories (evidence: `backend/src/modules/character/backstory/service.py`)
- Backstory generation → Unit of work: uses transactions (evidence: `backend/src/modules/character/backstory/service.py`)
- Backstory generation → Redis cache: uses cache (evidence: `backend/src/modules/character/backstory/service.py`)
- Backstory generation → Rate limiting interface: checks limits (evidence: `backend/src/modules/character/backstory/service.py`)
- Backstory generation → AI model catalog: uses AI module (evidence: `backend/src/modules/character/backstory/service.py`)
- RabbitMQ client → Backend messaging: uses backend bus (evidence: `bot/app/infrastructure/rabbitmq/client.py`)
