Return to Portfolio

Dungeon Archivist

Turn D&D rule lookups from immersion-breaking pauses into instant, source-cited answers — powered by a hybrid RAG system with a 3D fantasy interface.

Try the Prototype

The Problem It Solves

Dungeons & Dragons transforms gameplay into epic storytelling — until the rules break immersion. A climactic battle grinds to a halt while the DM flips through 500 pages trying to remember how grappling works.

The Dungeon Archivist fixes this. Ask "What happens when you're blinded?" and get accurate, source-cited responses in under 3 seconds — through a 3D dungeon room interface with a fantasy book that absorbs your queries and returns grounded answers with confidence scores.

<3s Response Time Target
100% Source Citation Accuracy
1M Token Context Window
87ms Vector Retrieval Speed

The Challenge

D&D 5th Edition: 500+ pages of unstructured rules, context-dependent mechanics, and zero tolerance for errors.

Pain Points

  • Immersion Killers — 2–5 minute pauses while looking up rules destroy narrative flow
  • 500+ Pages of Rules — Dense prose mixed with semi-structured lists, tables, and edge cases
  • Context-Dependent Mechanics — "Advantage" works differently in combat vs. skill checks
  • Zero Error Tolerance — A wrong ruling can ruin game balance for the whole session

Archivist's Answer

  • Instant Retrieval — Sub-3-second responses keep the story flowing
  • Hybrid RAG — Two parallel retrieval paths: semantic for narrative, structured for stats
  • Confidence Gating — Threshold filtering rejects out-of-domain queries explicitly
  • Source Citations — Every answer traceable back to official SRD content

Why Traditional Solutions Fail

Approach Strengths Critical Failures
Keyword Search Fast, precise for known terms Can't understand intent ("How does grappling work?")
Generic LLMs Natural language understanding Hallucinate plausible-sounding but wrong rules
Pure Vector Search Good semantic similarity Returns lore instead of stats for structured queries
Hybrid RAG Intent + precision combined Grounded, cited, confidence-gated

Hybrid RAG System

Queries route through two parallel retrieval pathways, combining semantic understanding with structured precision.

A

Vector Search Path

ChromaDB embedding-based similarity search for narrative rules. Captures user intent and semantic meaning — "How does grappling work?" or "Explain advantage."

B

Structured Filtering Path

Direct entity lookups in structured metadata for 100% factual accuracy on stats — "What's a Goblin's HP?" or "Fireball damage."

Confidence Gating

Threshold-based filtering (score < 1.1) validates relevance. Out-of-domain queries rejected with "No relevant D&D content found."

📎

Source Citations

Every answer includes source file references. Users trace any ruling back to official SRD content for full transparency.

Key Insight: By treating rules and stats as separate data types with different retrieval strategies, the system achieves both contextual understanding and factual precision — something neither approach could do alone.

3D Fantasy Interface

The Dungeon Room

The frontend is a fully 3D React/Three.js experience. Users interact with a dungeon room environment featuring a fantasy book that absorbs chat queries, a crystal ball, dice, and atmospheric lighting — making the rules lookup feel like part of the game itself.

  • 3D dungeon room with interactive objects (book, crystal ball, dice)
  • Fantasy book interface absorbs queries and renders answers in-world
  • Loading indicators and themed error messages within the 3D scene
  • Desktop sidebar for DM toolkit; mobile bottom drawer with swipe gestures
  • Full 3D view on mobile with touch-optimized targets
3D dungeon room with fantasy book interface and query results.

Dual Creativity System

Your DM, Your Way

Two independent controls shape every response. The AI Creativity slider adjusts how inventive the generation is, while the DM Personality selector chooses from three distinct Dungeon Master voices — each with its own tone, flavor text, and playful language patterns.

  • AI creativity slider for controlling generation inventiveness
  • 3 distinct DM personalities with unique voice and tone
  • Playful, in-world language throughout the UI
  • Documented in DUAL_CREATIVITY_SYSTEM.md and PLAYFUL_LANGUAGE_EXAMPLES.md
  • Controls are mobile-optimized with larger touch targets
DM toolkit with dual sliders and personality selector.

Mobile-First Redesign

Play Anywhere, Ask Anything

The entire experience was redesigned mobile-first. The 3D scene fills the screen, the DM toolkit moves into a swipeable bottom drawer, and every interaction is touch-optimized — because D&D happens at tables, not desks.

  • Full-screen 3D view replaces cluttered fixed sidebar on mobile
  • Bottom drawer with swipe gestures for DM toolkit access
  • Bigger touch targets, mobile-friendly labels ("Tap" vs "Click")
  • Accessibility improvements across all interactive elements
  • Documented in MOBILE_CHANGES_SUMMARY.md
Mobile view with full 3D scene and bottom drawer open.

Technical Implementation

LLM Provider
Gemini 1.5 Flash
1M token context window, $0.075/1M tokens, sub-2s latency
Vector Database
ChromaDB
Python-native, sub-100ms retrieval, normalized embeddings, persistent local storage
Embeddings
text-embedding-004
768-dimensional vectors, batch processing with exponential backoff
Backend
FastAPI + Python 3.11+
RAG pipeline, background ingestion, PDF validation, confidence gating
Frontend
React + Three.js
3D dungeon room, fantasy book UI, mobile bottom drawer, DM toolkit
Deployment
Docker
Clean chroma_db builds, health-check optimization, language_system.py packaging
<2s Gemini Latency
$0.075 Cost per 1M Tokens
768 Embedding Dimensions
1000 Chunk Size (chars)

ETL & Data Engineering

Automated ingestion pipeline transforms dense SRD prose into retrievable, cited chunks.

1

Extract

Load D&D SRD text files and Basic Rules PDF from local storage. Background ingestion validates PDFs and supports additional sources via env/data/.

2

Transform

RecursiveCharacterTextSplitter: 1000-char chunks, 100-char overlap. Splits on paragraph → sentence → word boundaries to keep mechanics and examples together.

3

Embed

768-dimensional vectors via text-embedding-004. Batch processing with exponential backoff. Normalized embeddings for more consistent retrieval scores.

4

Load

Persist vectors + metadata (source file, chunk ID, character positions) in ChromaDB. Background ingestion runs at startup; avoids bundling chroma_db in Docker.

System Capabilities

Full Monster Statistics
Full Spell Information
Full Equipment & Items
Full Magic Items
Full All 15 Conditions
Partial Combat Rules
Planned Classes & Subclasses
Planned Races / Species
Planned Feats & Backgrounds

Validation & Testing

Systematic testing across 50+ queries established retrieval thresholds and validated system behavior.

In-Domain Validation

"What happens if I can't see?" — Similarity score 0.9839 (below 1.1 threshold). Successfully retrieved 'blinded' condition rules with accurate generation.

Out-of-Domain Rejection

"How do I bake a chocolate cake?" — Score 1.2975 (above threshold). Correctly rejected with "No relevant D&D content found."

Threshold Calibration

50+ queries established 1.1 as optimal separation. Valid D&D queries consistently below 1.0; out-of-domain above 1.2.

Retrieval Performance

"How does grappling work?" — 3 relevant chunks retrieved covering rules, escapes, and edge cases. Total retrieval time: 87ms.

Note: All metrics from systematic validation documented in RETRIEVAL_LOG.md. Confidence gating improvements from recent RAG updates further reduce false-positive risk in production queries.

Query Experience Flow

From question to cited answer — seven steps through the archive.

I

Natural Query

User asks a D&D question through the 3D fantasy book interface.

II

DM Personality

Dual sliders shape creativity and DM voice before generation.

III

Hybrid Retrieval

Parallel vector + structured search with normalized embeddings.

IV

Confidence Gating

Threshold filtering rejects out-of-domain queries.

V

Grounded Answer

Gemini generates a response grounded in retrieved SRD chunks with citations.

VI

3D Scene Response

Answer renders inside the fantasy book within the dungeon room.

VII

Mobile Drawer

Full 3D on mobile; DM toolkit in a swipeable bottom drawer.

Implementation Roadmap

Phases 1–5

Completed
  • System architecture & Gemini API integration
  • ETL pipeline with recursive chunking & ChromaDB
  • End-to-end RAG pipeline with threshold filtering
  • 50+ query validation & RETRIEVAL_LOG.md documentation
  • 3D React/Three.js frontend with FastAPI backend

Recent Updates

Shipped
  • Dual creativity system (AI + DM personality sliders)
  • Mobile-first redesign with bottom drawer
  • New 3D dungeon room environment
  • Background ingestion & PDF validation
  • Normalized embeddings for consistent retrieval
  • Deployment fixes (Docker, health-checks)

Data Expansion

Planned
  • Classes & subclasses with spell progression
  • Races/species with racial traits and ability scores
  • Feats & backgrounds for character creation
  • Structured lookup router (Path B) for JSON filtering

Enhanced UX

Planned
  • Session memory for multi-turn conversations
  • Related topic suggestions alongside answers
  • Query history UI for revisiting past lookups
  • Pre-computed common queries for zero-latency

Skills Demonstrated

🤖

AI/ML Engineering

Hybrid RAG design, semantic search, empirical threshold calibration (50+ queries), confidence gating, hallucination risk reduction.

🔧

Data Engineering

ETL pipeline, recursive text chunking, vector embedding optimization, background ingestion, PDF validation, API cost optimization.

🎨

3D Frontend Development

React + Three.js 3D scene, mobile-first responsive design, bottom drawer navigation, touch optimization, DM personality UI.

🏗

Software Architecture

Modular architecture, FastAPI backend, Docker deployment, error handling, graceful degradation, multi-interface design.

Conclusion

The Dungeon Archivist demonstrates end-to-end AI engineering: from hybrid RAG architecture to a 3D fantasy interface, built across 5 phases and continuously improved with mobile-first redesigns, dual creativity controls, and deployment reliability updates. The system transforms 2–5 minute rule disruptions into sub-3-second experiences with source-cited, confidence-gated responses.

From security-first development to user-centered 3D design, the project showcases advanced competencies in AI/ML engineering, data engineering, 3D frontend development, and software architecture — representing what modern, full-stack AI engineering looks like.

Hybrid RAG Architecture
3D Fantasy Interface
Source Citations
Mobile-First Design
Dual Creativity System
MVP Complete
⚠ MVP Disclaimer: This is a Minimum Viable Product and proof of concept running on Google Gemini's free API tier with rate limits. Due to copyright restrictions, the system references free D&D resources (primarily the SRD) and covers a subset of official content. Production deployment would require a paid API tier and expanded content licensing.