๐ฎ Live App: https://dungeongpt.xyz/
This is a web application built with React that allows users to create detailed characters for role-playing games, manage them, and use them in an interactive game session powered by an AI dungeon master. The live app currently runs on Cloudflare Workers AI with a curated set of open-weights models (including GPT-OSS, Llama, and Gemma); premium models via OpenRouter are planned for a future paid tier.
This project is based upon the Python version of the same name.
YouTube Videos ๐ฅ:
- Character Creation: Detailed form to define character stats, class, race, background, alignment, and profile picture.
- Character Management: View all created characters, edit existing characters.
- Game Setup: Configure settings for a new game session (description, rules, world seed).
- Hero Selection: Choose created characters to form a party for the game.
- AI-Powered Game: Engage in an interactive text-based adventure where the AI acts as the game master, responding to user actions and summarizing the story.
- World Map: Explore a procedurally generated world map with biomes, towns, and points of interest.
- Encounter System: Dynamic encounters with skill checks, rewards, and AI-narrated outcomes.
- Inventory & Progression: Track party inventory, gold, HP, and XP progression.
- AI Models: Currently runs on Cloudflare Workers AI (GPT-OSS, Llama, Gemma, and other open-weights models). Local development additionally supports OpenAI, Gemini, and Claude. Premium models via OpenRouter are planned.
- User Authentication: Secure sign-in via Octonion hub (centralized auth across games).
- Persistent Sessions: Characters and game sessions saved to Supabase PostgreSQL, accessed through CF Worker with row-level access enforcement.
- Save/Load System: Manual and auto-save functionality with save confirmation modals.
- Frontend: React (Hooks, Context API) - Deployed on Cloudflare Pages
- Routing: React Router DOM
- Styling: Modular CSS (feature-based organization in
src/styles/) - Backend: Cloudflare Workers (TypeScript with Hono framework)
- Database: Supabase PostgreSQL (accessed via CF Worker with row-level access enforcement)
- Authentication: Octonion hub (centralized auth at octonion.io)
- AI Providers: Cloudflare Workers AI in production. Local development also supports OpenAI, Gemini, and Claude (server-side only, no exposed keys). OpenRouter integration planned for premium tier.
src/
โโโ components/ # Reusable UI components (modals, panels, maps)
โโโ contexts/ # React Context providers (Auth, Settings)
โโโ data/ # Static game data (encounters, races, classes)
โโโ game/ # Game logic controllers (movement, encounters, saves)
โโโ hooks/ # Custom React hooks (useGameMap, useGameSession, etc.)
โโโ llm/ # LLM integration (model resolver, constants)
โโโ pages/ # Page components (Game, CharacterCreation, Login, etc.)
โโโ services/ # API client services (auth, heroes, conversations, LLM)
โโโ styles/ # Feature-based CSS files
โโโ utils/ # Utility functions (map generation, health system, etc.)
cf-worker/ # Cloudflare Workers backend (production)
โโโ src/
โ โโโ index.ts # Hono app entry point
โ โโโ routes/ # API routes (DB proxy, AI, images, embeddings)
โ โโโ middleware/ # Auth middleware (Octonion JWT validation)
โ โโโ services/ # Workers AI service layer
โโโ wrangler.toml # Cloudflare Workers config
The following image shows the character creator interface of DungeonGPT:
The following image shows the chat interface of DungeonGPT:
This is a guide for deploying the app locally.
-
Clone the repository:
git clone https://github.com/EdwardAThomson/DungeonGPT-JS.git cd DungeonGPT-JS -
Install dependencies:
npm install
-
Set up Environment Variables:
- Copy
.env.exampleto.envand configure:
cp .env.example .env
- Edit
.envand add your LLM API keys:
OPENAI_API_KEY=your-openai-key GEMINI_API_KEY=your-gemini-key ANTHROPIC_API_KEY=your-claude-key- The default settings in
.env.exampleshould work for local development (port 5000 for backend, port 3000 for frontend). - API keys are handled securely by the backend server โ they are never exposed to the frontend.
- Copy
-
Run the backend server (Required for Database Persistence):
- The backend server (
src/server.js) handles saving and loading characters to/from the SQLite database (src/game.db). - This server must be running in a separate terminal for character saving/loading features to work.
- Open a terminal, navigate to the project root directory, and run:
node src/server.js
- Keep this terminal window open while using the application.
- The backend server (
-
Run the React development server:
- In a new terminal, from the project root:
npm start
- This will open the application at
http://localhost:3000
The app is deployed on:
- Frontend: Cloudflare Pages (https://dungeongpt.xyz)
- Backend: Cloudflare Workers
- Database: Supabase PostgreSQL
For deployment instructions, see the deployment guides in /docs.
- Create a hero using the "Hero Creator" form with detailed stats, class, race, and background
- View and manage your heroes under "All Heroes"
- Start a new game by going to "New Game", configuring settings, and selecting your party
- Explore the world with a procedurally generated map featuring biomes, towns, and encounters
- Play the game by interacting with the AI Dungeon Master through text commands
- Save your progress - characters and game sessions are saved to the local SQLite database
Note: The live production app at https://dungeongpt.xyz/ includes additional features like centralized authentication via Octonion hub and cloud persistence via Supabase.
- โ Production Deployment โ Live on Cloudflare Pages with Workers backend
- โ Supabase Integration โ PostgreSQL database accessed via CF Worker
- โ Octonion Hub Auth โ Centralized authentication across games
- โ Cloudflare Workers AI โ Server-side AI with no exposed API keys
- โ Multi-User Support โ Each user's data isolated by CF Worker access control
- โ Save/Load System โ Manual save with confirmation, auto-save, cloud persistence
- โ Modular Architecture โ Controllers for movement, encounters, saves
- โ Multi-Provider AI โ OpenAI, Gemini, Claude, Cloudflare Workers (cloud and CLI modes) [Local Dev Mode]
- โ Environment-Aware Logging โ Production-safe logging system
- โ Feature-Based CSS โ Modular styling for maintainability
- โ Procedural World Map โ Biomes, towns, mountains with exploration
- โ Dynamic Encounters โ Skill checks, rewards, AI narration
- โ Town Discovery System โ Buildings discovered and remembered across sessions
- โ How to Play Page โ Comprehensive guide for new players
- โ E2E Testing โ Playwright tests for critical user flows
- ๐ณ Billing Integration โ Credit-based system with Lemon Squeezy
- ๐ Usage Tracking โ AI usage analytics and cost monitoring
- ๐ Rate Limiting โ Request throttling and abuse prevention
- ๐ Monitoring โ Error tracking and performance metrics
- ๐ฌ Streaming AI Responses โ Real-time text generation for better UX
- ๐งช Expanded Testing โ Unit and integration tests for core game loops
- ๐บ๏ธ Dungeon Sub-Maps โ Procedurally generated caves and dungeons
- โ๏ธ Combat System โ Turn-based tactical combat encounters
- ๐ญ NPC Interactions โ Persistent NPCs with memory and relationships
This project is licensed under the Apache License 2.0. See the LICENSE file for details.
All character portrait images were generated using ChatGPT's AI image generation (DALL-E) and are owned by the project creator under OpenAI's Terms of Use. See CREDITS.md for full attribution details.
All game content (character descriptions, encounter text, story elements) is original content created for this project. Race and class names use generic fantasy terms or original terminology to avoid trademark conflicts:
- Original race names: Smallfolk, Demonkin, Dragonkin
- Generic race names: Human, Dwarf, Elf, Gnome, Half-Elf, Half-Orc
- Generic class names: Barbarian, Bard, Cleric, Druid, Fighter, Monk, Paladin, Ranger, Rogue, Sorcerer, Warlock, Wizard
This project uses d20-based game mechanics (rolling a 20-sided die for skill checks and attacks), which are not copyrighted and are used across many role-playing games. This project does not use the Open Game License (OGL) and does not claim compatibility with any specific game system.
This project uses various open-source libraries (React, Express, SQLite3, etc.) under their respective licenses. See CREDITS.md for a complete list.
For contribution guidelines, see CONTRIBUTING.md if available.


