# churchtao/daoyou architecture

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

- Interactive diagram: https://gitdiagram.com/churchtao/daoyou
- Repository: https://github.com/churchtao/daoyou

## Overview

万界道友 is an AI-assisted, text-first cultivation game. A player uses the React client to create and play a cultivator; the NestJS API handles game actions, while domain/rules packages provide cultivation and combat logic. Major documented play areas include alchemy, forging, exploration, markets, and social play. README and the source index establish the broad architecture; sampled excerpts confirm combat-engine and selected sect-task relationships, but do not expose most feature-controller wiring.

Main entry points: [`apps/api/src/main.ts`](https://github.com/churchtao/daoyou/blob/master/apps/api/src/main.ts) (NestJS API), [`packages/combat-core/src/pipeline.ts`](https://github.com/churchtao/daoyou/blob/master/packages/combat-core/src/pipeline.ts) (Turn-based combat core), [`packages/game-rules/src/cultivation/CultivationEngine.ts`](https://github.com/churchtao/daoyou/blob/master/packages/game-rules/src/cultivation/CultivationEngine.ts) (Game rules), [`apps/web/src`](https://github.com/churchtao/daoyou/tree/master/apps/web/src) (React game UI)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Game client"]
  node_web["React game UI"]
end

subgraph group_api["Game API"]
  node_api_entry["NestJS API<br/>[main.ts]"]
end

subgraph group_gameplay["Cultivation gameplay"]
  node_genesis["Character creation"]
  node_cultivator["Cultivator progression"]
  node_alchemy["Alchemy and crafting"]
  node_forging["Forging"]
  node_dungeon["Dungeon runs"]
  node_hunts["Hunts"]
  node_inventory["Inventory"]
  node_economy["Player economy"]
  node_auction["Auction house"]
  node_sect["Sects and tasks"]
  node_black_market["Black market"]
  node_rules["Game rules"]
  node_domain["Game domain models"]
end

subgraph group_combat["Combat engine"]
  node_combat_service["Combat sessions"]
  node_combat_core["Turn-based combat core<br/>[pipeline.ts]"]
end

subgraph group_platform["Shared platform"]
  node_database[("PostgreSQL data<br/>[db.ts]")]
  node_redis[("Redis coordination")]
  node_messaging["NATS messaging"]
  node_ai["DeepSeek AI"]
end

node_player(("Player"))

node_player -->|"plays through"| node_web
node_web -->|"sends game requests"| node_api_entry
node_api_entry -.->|"serves game features"| node_genesis
node_api_entry -.->|"serves game features"| node_cultivator
node_api_entry -.->|"serves game features"| node_alchemy
node_api_entry -.->|"serves game features"| node_forging
node_api_entry -.->|"serves game features"| node_dungeon
node_api_entry -.->|"serves game features"| node_hunts
node_api_entry -.->|"serves game features"| node_inventory
node_api_entry -.->|"serves game features"| node_economy
node_api_entry -.->|"serves game features"| node_auction
node_api_entry -.->|"serves game features"| node_sect
node_api_entry -.->|"serves game features"| node_black_market
node_combat_service -->|"uses engine"| node_combat_core
node_combat_core -.->|"provides combat logic"| node_combat_service
node_combat_core -.->|"uses game rules"| node_rules
node_cultivator -.->|"applies cultivation rules"| node_rules
node_rules -->|"uses domain models"| node_domain
node_api_entry -->|"persists game data"| node_database
node_api_entry -->|"uses coordination cache"| node_redis
node_api_entry -->|"uses messaging and broadcasts"| node_messaging
node_api_entry -->|"generates game content"| node_ai

click node_web "https://github.com/churchtao/daoyou/tree/master/apps/web/src"
click node_api_entry "https://github.com/churchtao/daoyou/blob/master/apps/api/src/main.ts"
click node_genesis "https://github.com/churchtao/daoyou/tree/master/apps/api/src/genesis"
click node_cultivator "https://github.com/churchtao/daoyou/tree/master/apps/api/src/cultivator"
click node_alchemy "https://github.com/churchtao/daoyou/tree/master/apps/api/src/alchemy"
click node_forging "https://github.com/churchtao/daoyou/tree/master/apps/api/src/forging"
click node_dungeon "https://github.com/churchtao/daoyou/tree/master/apps/api/src/dungeon"
click node_hunts "https://github.com/churchtao/daoyou/tree/master/apps/api/src/hunts"
click node_inventory "https://github.com/churchtao/daoyou/tree/master/apps/api/src/inventory"
click node_economy "https://github.com/churchtao/daoyou/tree/master/apps/api/src/market"
click node_auction "https://github.com/churchtao/daoyou/tree/master/apps/api/src/auction"
click node_sect "https://github.com/churchtao/daoyou/tree/master/apps/api/src/sects"
click node_black_market "https://github.com/churchtao/daoyou/tree/master/apps/api/src/black-market"
click node_combat_service "https://github.com/churchtao/daoyou/blob/master/apps/api/src/combat/application/CombatV6WildSessionService.ts"
click node_combat_core "https://github.com/churchtao/daoyou/blob/master/packages/combat-core/src/pipeline.ts"
click node_rules "https://github.com/churchtao/daoyou/blob/master/packages/game-rules/src/cultivation/CultivationEngine.ts"
click node_domain "https://github.com/churchtao/daoyou/tree/master/packages/game-domain"
click node_database "https://github.com/churchtao/daoyou/blob/master/apps/api/src/lib/drizzle/db.ts"
click node_redis "https://github.com/churchtao/daoyou/tree/master/apps/api/src/lib/redis"
click node_messaging "https://github.com/churchtao/daoyou/tree/master/apps/api/src/lib/mq"

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_web toneBlue
class node_api_entry toneAmber
class node_genesis,node_cultivator,node_alchemy,node_forging,node_dungeon,node_hunts,node_inventory,node_economy,node_auction,node_sect,node_black_market,node_rules,node_domain toneMint
class node_combat_service,node_combat_core toneRose
class node_database,node_redis,node_messaging,node_ai,node_player toneIndigo
```

## Components

### Game client

- [React game UI](https://github.com/churchtao/daoyou/tree/master/apps/web/src): `apps/web/src`

### Game API

- [NestJS API](https://github.com/churchtao/daoyou/blob/master/apps/api/src/main.ts): `apps/api/src/main.ts`

### Cultivation gameplay

- [Character creation](https://github.com/churchtao/daoyou/tree/master/apps/api/src/genesis): `apps/api/src/genesis`
- [Cultivator progression](https://github.com/churchtao/daoyou/tree/master/apps/api/src/cultivator): `apps/api/src/cultivator`
- [Alchemy and crafting](https://github.com/churchtao/daoyou/tree/master/apps/api/src/alchemy): `apps/api/src/alchemy`
- [Forging](https://github.com/churchtao/daoyou/tree/master/apps/api/src/forging): `apps/api/src/forging`
- [Dungeon runs](https://github.com/churchtao/daoyou/tree/master/apps/api/src/dungeon): `apps/api/src/dungeon`
- [Hunts](https://github.com/churchtao/daoyou/tree/master/apps/api/src/hunts): `apps/api/src/hunts`
- [Inventory](https://github.com/churchtao/daoyou/tree/master/apps/api/src/inventory): `apps/api/src/inventory`
- [Player economy](https://github.com/churchtao/daoyou/tree/master/apps/api/src/market): `apps/api/src/market`
- [Auction house](https://github.com/churchtao/daoyou/tree/master/apps/api/src/auction): `apps/api/src/auction`
- [Sects and tasks](https://github.com/churchtao/daoyou/tree/master/apps/api/src/sects): `apps/api/src/sects`
- [Black market](https://github.com/churchtao/daoyou/tree/master/apps/api/src/black-market): `apps/api/src/black-market`
- [Game rules](https://github.com/churchtao/daoyou/blob/master/packages/game-rules/src/cultivation/CultivationEngine.ts): `packages/game-rules/src/cultivation/CultivationEngine.ts`
- [Game domain models](https://github.com/churchtao/daoyou/tree/master/packages/game-domain): `packages/game-domain`

### Combat engine

- [Combat sessions](https://github.com/churchtao/daoyou/blob/master/apps/api/src/combat/application/CombatV6WildSessionService.ts): `apps/api/src/combat/application/CombatV6WildSessionService.ts`
- [Turn-based combat core](https://github.com/churchtao/daoyou/blob/master/packages/combat-core/src/pipeline.ts): `packages/combat-core/src/pipeline.ts`

### Shared platform

- [PostgreSQL data](https://github.com/churchtao/daoyou/blob/master/apps/api/src/lib/drizzle/db.ts): `apps/api/src/lib/drizzle/db.ts`
- [Redis coordination](https://github.com/churchtao/daoyou/tree/master/apps/api/src/lib/redis): `apps/api/src/lib/redis`
- [NATS messaging](https://github.com/churchtao/daoyou/tree/master/apps/api/src/lib/mq): `apps/api/src/lib/mq`
- **DeepSeek AI**

### Other components

- **Player**

## Connections

- Player → React game UI: plays through (evidence: `README.md`)
- React game UI → NestJS API: sends game requests (evidence: `README.md`)
- NestJS API → Character creation: serves game features
- NestJS API → Cultivator progression: serves game features
- NestJS API → Alchemy and crafting: serves game features
- NestJS API → Forging: serves game features
- NestJS API → Dungeon runs: serves game features
- NestJS API → Hunts: serves game features
- NestJS API → Inventory: serves game features
- NestJS API → Player economy: serves game features
- NestJS API → Auction house: serves game features
- NestJS API → Sects and tasks: serves game features
- NestJS API → Black market: serves game features
- Combat sessions → Turn-based combat core: uses engine (evidence: `apps/api/src/combat/application/CombatV6WildSessionService.ts`)
- Turn-based combat core → Combat sessions: provides combat logic
- Turn-based combat core → Game rules: uses game rules
- Cultivator progression → Game rules: applies cultivation rules
- Game rules → Game domain models: uses domain models (evidence: `packages/game-rules/src/cultivation/CultivationEngine.ts`)
- NestJS API → PostgreSQL data: persists game data (evidence: `README.md`)
- NestJS API → Redis coordination: uses coordination cache (evidence: `README.md`)
- NestJS API → NATS messaging: uses messaging and broadcasts (evidence: `README.md`)
- NestJS API → DeepSeek AI: generates game content (evidence: `README.md`)
