┌──────────────────────────────────────────────────┐
│ INTERFACE │
│ ┌─────────────┐ ┌──────────────┐ ┌──────────┐ │
│ │ Discord Bot │ │ Web Chat UI │ │ Email │ │
│ │ (Primary) │ │ (Fallback) │ │ Recaps │ │
│ └──────┬──────┘ └──────┬───────┘ └───┬──────┘ │
└──────────┼────────────────┼─────────────┼─────────┘
│ │ │
▼ ▼ ▼
┌──────────────────────────────────────────────────┐
│ DM AGENT (Deno) │
│ ┌────────────┐ ┌────────────┐ ┌───────────┐ │
│ │ Session │ │ NPC Memory │ │ Combat │ │
│ │ Manager │ │ Engine │ │ Engine │ │
│ └────────────┘ └────────────┘ └───────────┘ │
│ ┌────────────┐ ┌────────────┐ ┌───────────┐ │
│ │ Quest Gen │ │ Recap Gen │ │ Character │ │
│ │ (Ollama) │ │ (MiniMax) │ │ Builder │ │
│ └────────────┘ └────────────┘ └───────────┘ │
└──────────────────────────────────────────────────┘
│ │
▼ ▼
┌─────────────────────┐ ┌────────────────────────┐
│ STATE FILES │ │ AI RUNTIME │
│ campaign/ │ │ ┌──────────────────┐ │
│ ├── session_3.md │ │ │ Ollama (Mac Mini)│ │
│ ├── npcs.json │ │ │ Mistral 7B │ │
│ ├── party.json │ │ │ (DM reasoning) │ │
│ └── world.json │◄────│ └──────────────────┘ │
│ (Git-tracked) │ │ ┌──────────────────┐ │
└─────────────────────┘ │ │ MiniMax API │ │
│ │ (Narrative) │ │
│ └──────────────────┘ │
└────────────────────────┘
🎲 Dice + Combat
Player rolls dice in Discord. Bot parses: "/roll 2d20+5". Ollama Mistral 7B evaluates the outcome: "That's a 17 and a 23, plus 5... you hit! The goblin takes 18 damage." Handles attack rolls, saves, skill checks with appropriate NPC reactions.
🗣️ NPC Dialogue
When player talks to NPC: system prompt loads NPC's personality + relationships + secrets from npcs.json. Ollama generates dialogue in character. MiniMax fallback for complex social encounters.
📜 Quest Hook Generation (pre-session)
Before session, bot analyzes party composition + world state + NPC relationships. Ollama drafts 3 quest options. DM (human) picks one or asks for variations. Selected quest's branch tree is saved.
📰 Session Recap (post-session)
After session, concatenate all session_N.md logs. Send to MiniMax M2.1 for polished recap generation. Format: what happened, key decisions, NPC developments, cliffhanger for next session. Send via Resend to all players.
🔄 NPC Memory Update
After each player interaction, Ollama extracts NPC state changes and updates npcs.json. "Lord Blackwood: now suspects party of theft (was neutral). Added secret: hiding stolen artifact."