A real-time multiplayer D&D (Dungeons & Dragons 5e) web application with an AI-powered Dungeon Master. Players can create characters, join sessions, and play together with an AI narrating the story.
- AI Dungeon Master - Uses OpenAI-compatible APIs (OpenAI, DeepSeek, OpenRouter, etc.)
- Split AI Roles - Independently assign models for narration, POV prose, and backend rules/bookkeeping work
- Real-time Multiplayer - Socket.IO powered live updates
- AI-Guided Character Creation - Chat-based Level 1 character creation
- Turn-Based Gameplay - All players submit actions, then AI narrates the outcome
- Automatic Dice Rolling - AI rolls dice and calculates results using character stats
- Tactical Combat - Defers narration while a server-authoritative encounter resolves initiative, movement, attacks, spells, class abilities, defense, ownership, and animated real-time enemy turns; the narrator then writes the aftermath from the submitted actions and battle result
- YouTube DJ - Optional shared, scene-matched music that changes with every narrated turn
- Illustrated POV Stage - Players can generate avatar-referenced scene art for their own POV, shared live across devices
- XP Tracking - Automatic XP parsing from AI responses with D&D 5e leveling
- Gold & Inventory System - Track gold and items automatically from gameplay
- AI-Assisted Level Up - Guided stat increases, new abilities, and spell selection
- Auto-Compact History - Summarizes old messages to save tokens while preserving full chat for players
- Dark/Light Theme - Toggle between themes
- Mobile Responsive - Works on desktop and mobile devices
- Backend: Node.js, Express.js, Socket.IO
- Database: SQLite (better-sqlite3)
- Frontend: Vanilla HTML/CSS/JavaScript
- AI Integration: OpenAI-compatible API
- Auth: bcrypt for password hashing
- Deployment: Docker
- Node.js 18+
- npm
git clone https://github.com/jeromehbonaparte-star/dnd-multiplayer.git
cd dnd-multiplayer
npm installSet environment variables (required for predictable production auth):
export GAME_PASSWORD=yourpassword
export ADMIN_PASSWORD=youradminpassword
export PORT=3000If GAME_PASSWORD or ADMIN_PASSWORD is missing, the server will generate a random password on first run and print it to logs.
npm startVisit http://localhost:3000 in your browser.
docker build -t dnd-multiplayer .
docker run -p 3000:3000 -v ./data:/app/data -e GAME_PASSWORD=secret -e ADMIN_PASSWORD=admin dnd-multiplayer- Login with the game password
- Go to Settings (requires admin password)
- Add and test the API configurations you want to use
- Select a Narrator Model, POV Model, and Agent Model under Model Roles
- Leaving any role on the active-configuration fallback preserves the previous single-model behavior
- Optional: add a YouTube Data API v3 key in Settings and enable YouTube DJ
- Optional: configure an OpenAI Images, NanoGPT, or compatible chat image API and enable POV Scene Images
Note: if EasyPanel/Traefik basic auth is enabled, users will authenticate twice (proxy layer + in-app game password).
- API endpoint validation blocks localhost/private IP targets by default.
https://endpoints are required by default.- Override only when intentionally needed:
export ALLOW_PRIVATE_AI_ENDPOINTS=false
export ALLOW_INSECURE_AI_ENDPOINTS=false- Go to Characters tab
- Click "Start Character Creation"
- Chat with the AI to create your Level 1 character
- Go to Game tab
- Create a new session or select existing one
- Select your character and describe your action
- Wait for all players to submit, or use "Force Process Turn"
- AI narrates the outcome!
The AI DM automatically tracks the following when it uses these formats:
| Type | Format | Example |
|---|---|---|
| XP | [XP: Name +amount] |
[XP: Thorin +50, Elara +50] |
| Gold | [GOLD: Name +/-amount] |
[GOLD: Thorin +100, Elara -25] |
| Items | [ITEM: Name +/-item] |
[ITEM: Thorin +Sword of Fire] |
Use "Recalculate XP" or "Recalculate Loot" buttons to scan existing chat history.
POST /api/auth- Verify game passwordPOST /api/admin-auth- Verify admin password
GET /api/characters- List all charactersPOST /api/characters/ai-create- AI-guided creationPOST /api/characters/:id/levelup- Level up characterPOST /api/characters/:id/edit- AI-assisted editingPOST /api/characters/:id/gold- Update goldPOST /api/characters/:id/inventory- Manage inventory
GET /api/sessions- List sessionsPOST /api/sessions- Create sessionPOST /api/sessions/:id/action- Submit actionPOST /api/sessions/:id/process- Force process turnPOST /api/sessions/:id/recalculate-xp- Scan for XPPOST /api/sessions/:id/recalculate-loot- Scan for gold/items
dnd-multiplayer/
├── server/
│ └── index.js # Backend server
├── public/
│ ├── index.html # Single-page app
│ ├── css/style.css # Styling
│ └── js/app.js # Frontend logic
├── data/
│ └── dnd.db # SQLite database (created at runtime)
├── Dockerfile
├── package.json
├── DOCUMENTATION.md # Detailed documentation
└── README.md
See DOCUMENTATION.md for detailed technical documentation including:
- Database schema
- Socket.IO events
- Frontend state management
- Security features
- Troubleshooting
MIT
Created by Jerome for playing D&D with friends remotely.
GitHub: @jeromehbonaparte-star