# nidheeshgit/ai-adventure-game architecture

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

- Interactive diagram: https://gitdiagram.com/nidheeshgit/ai-adventure-game
- Repository: https://github.com/nidheeshgit/ai-adventure-game

## Overview

AI Adventure Game is a terminal-based, text fantasy adventure. The player enters an action; the CLI initializes and displays the persistent game world, while LangGraph classifies each turn, dispatches it to a story, combat, inventory, or status handler, and returns a narrated response. Specialist agents use tools to update shared game state; the Game Master narrates the result. The README documents the main routing flow and capabilities; some wiring is supported by excerpts, while internal details of unsampled modules are not independently verified.

Main entry points: [`app/graph/workflow.py`](https://github.com/nidheeshgit/ai-adventure-game/blob/main/app/graph/workflow.py) (Turn Workflow), [`app/tools/game_tools.py`](https://github.com/nidheeshgit/ai-adventure-game/blob/main/app/tools/game_tools.py) (Game Tools), [`app/main.py`](https://github.com/nidheeshgit/ai-adventure-game/blob/main/app/main.py) (Terminal Game Loop), [`app/agents/game_master.py`](https://github.com/nidheeshgit/ai-adventure-game/blob/main/app/agents/game_master.py) (Game Master)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["Player Interface"]
  node_cli["Terminal Game Loop<br/>[main.py]"]
end

subgraph group_orchestration["Turn Orchestration"]
  node_workflow["Turn Workflow<br/>[workflow.py]"]
  node_turnstate["Turn State<br/>[state.py]"]
  node_status["Status Handler<br/>[workflow.py]"]
end

subgraph group_agents["Adventure Agents"]
  node_master["Game Master<br/>[game_master.py]"]
  node_story["Story Agent<br/>[story_agent.py]"]
  node_combat["Combat Agent<br/>[combat_agent.py]"]
  node_inventory["Inventory Agent<br/>[inventory_agent.py]"]
end

subgraph group_world["Game World"]
  node_tools["Game Tools<br/>[game_tools.py]"]
  node_gamestate[("Game State<br/>[game_state.py]")]
end

node_player(("Player"))
node_llm{{"Groq LLM"}}

node_player -->|"enters actions"| node_cli
node_cli -->|"initializes world"| node_tools
node_cli -->|"invokes turn"| node_workflow
node_workflow -->|"uses schema"| node_turnstate
node_workflow -->|"classifies action"| node_master
node_workflow -->|"routes story"| node_story
node_workflow -->|"routes combat"| node_combat
node_workflow -->|"routes inventory"| node_inventory
node_workflow -->|"routes status"| node_status
node_story -->|"calls tools"| node_tools
node_combat -->|"calls tools"| node_tools
node_inventory -->|"calls tools"| node_tools
node_tools -->|"updates world"| node_gamestate
node_master -->|"requests classification"| node_llm
node_master -->|"requests narration"| node_llm
node_story -->|"requests decisions"| node_llm
node_combat -->|"requests decisions"| node_llm
node_inventory -->|"requests decisions"| node_llm
node_workflow -->|"returns for narration"| node_master
node_workflow -->|"returns response"| node_cli
node_cli -->|"reads current state"| node_tools

click node_cli "https://github.com/nidheeshgit/ai-adventure-game/blob/main/app/main.py"
click node_workflow "https://github.com/nidheeshgit/ai-adventure-game/blob/main/app/graph/workflow.py"
click node_turnstate "https://github.com/nidheeshgit/ai-adventure-game/blob/main/app/graph/state.py"
click node_master "https://github.com/nidheeshgit/ai-adventure-game/blob/main/app/agents/game_master.py"
click node_story "https://github.com/nidheeshgit/ai-adventure-game/blob/main/app/agents/story_agent.py"
click node_combat "https://github.com/nidheeshgit/ai-adventure-game/blob/main/app/agents/combat_agent.py"
click node_inventory "https://github.com/nidheeshgit/ai-adventure-game/blob/main/app/agents/inventory_agent.py"
click node_status "https://github.com/nidheeshgit/ai-adventure-game/blob/main/app/graph/workflow.py"
click node_tools "https://github.com/nidheeshgit/ai-adventure-game/blob/main/app/tools/game_tools.py"
click node_gamestate "https://github.com/nidheeshgit/ai-adventure-game/blob/main/app/models/game_state.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_cli toneBlue
class node_workflow,node_turnstate,node_status toneAmber
class node_master,node_story,node_combat,node_inventory toneMint
class node_tools,node_gamestate toneRose
class node_player,node_llm toneIndigo
```

## Components

### Player Interface

- [Terminal Game Loop](https://github.com/nidheeshgit/ai-adventure-game/blob/main/app/main.py): `app/main.py`

### Turn Orchestration

- [Turn Workflow](https://github.com/nidheeshgit/ai-adventure-game/blob/main/app/graph/workflow.py): `app/graph/workflow.py`
- [Turn State](https://github.com/nidheeshgit/ai-adventure-game/blob/main/app/graph/state.py): `app/graph/state.py`
- [Status Handler](https://github.com/nidheeshgit/ai-adventure-game/blob/main/app/graph/workflow.py): `app/graph/workflow.py`

### Adventure Agents

- [Game Master](https://github.com/nidheeshgit/ai-adventure-game/blob/main/app/agents/game_master.py): `app/agents/game_master.py`
- [Story Agent](https://github.com/nidheeshgit/ai-adventure-game/blob/main/app/agents/story_agent.py): `app/agents/story_agent.py`
- [Combat Agent](https://github.com/nidheeshgit/ai-adventure-game/blob/main/app/agents/combat_agent.py): `app/agents/combat_agent.py`
- [Inventory Agent](https://github.com/nidheeshgit/ai-adventure-game/blob/main/app/agents/inventory_agent.py): `app/agents/inventory_agent.py`

### Game World

- [Game Tools](https://github.com/nidheeshgit/ai-adventure-game/blob/main/app/tools/game_tools.py): `app/tools/game_tools.py`
- [Game State](https://github.com/nidheeshgit/ai-adventure-game/blob/main/app/models/game_state.py): `app/models/game_state.py`

### Other components

- **Player**
- **Groq LLM**

## Connections

- Player → Terminal Game Loop: enters actions (evidence: `README.md`)
- Terminal Game Loop → Game Tools: initializes world (evidence: `app/main.py`)
- Terminal Game Loop → Turn Workflow: invokes turn (evidence: `app/main.py`)
- Turn Workflow → Turn State: uses schema (evidence: `app/graph/workflow.py`)
- Turn Workflow → Game Master: classifies action (evidence: `README.md`)
- Turn Workflow → Story Agent: routes story (evidence: `app/graph/workflow.py`)
- Turn Workflow → Combat Agent: routes combat (evidence: `app/graph/workflow.py`)
- Turn Workflow → Inventory Agent: routes inventory (evidence: `app/graph/workflow.py`)
- Turn Workflow → Status Handler: routes status (evidence: `app/graph/workflow.py`)
- Story Agent → Game Tools: calls tools (evidence: `app/agents/story_agent.py`)
- Combat Agent → Game Tools: calls tools (evidence: `app/agents/combat_agent.py`)
- Inventory Agent → Game Tools: calls tools (evidence: `app/agents/inventory_agent.py`)
- Game Tools → Game State: updates world (evidence: `app/tools/game_tools.py`)
- Game Master → Groq LLM: requests classification (evidence: `app/agents/game_master.py`)
- Game Master → Groq LLM: requests narration (evidence: `app/agents/game_master.py`)
- Story Agent → Groq LLM: requests decisions (evidence: `README.md`)
- Combat Agent → Groq LLM: requests decisions (evidence: `app/agents/combat_agent.py`)
- Inventory Agent → Groq LLM: requests decisions (evidence: `app/agents/inventory_agent.py`)
- Turn Workflow → Game Master: returns for narration (evidence: `app/graph/workflow.py`)
- Turn Workflow → Terminal Game Loop: returns response (evidence: `app/main.py`)
- Terminal Game Loop → Game Tools: reads current state (evidence: `README.md`)
