A comprehensive AI-powered Dungeons & Dragons game application built with modern web technologies. This application provides a complete tabletop RPG experience with AI-driven storytelling, character management, and campaign organization.
- AI Dungeon Master: Intelligent AI that responds to player actions with rich, contextual storytelling
- Character Management: Create, edit, and manage D&D characters with full stat tracking
- Campaign Organization: Organize multiple campaigns with different themes and settings
- Session Management: Track game sessions with message history and continuity
- Location Discovery: AI automatically discovers and creates new locations during gameplay
- Story Arc System: Plan and manage narrative arcs with AI-powered validation
- Character Discovery: AI creates and manages NPCs during gameplay
- Game Commands: Built-in commands for dice rolling, status checking, and inventory management
- Multi-Character Support: Support for multiple characters per campaign
- Real-time Chat: Interactive chat interface with the AI Dungeon Master
- Responsive Design: Works on desktop, tablet, and mobile devices
- Real-time Updates: Live session updates and character synchronization
- Data Persistence: All game data is saved and persists between sessions
- Performance Optimized: Efficient resource usage and fast response times
- Framework: Next.js 14 with TypeScript
- UI Library: Tailwind CSS with shadcn/ui components
- State Management: React hooks and context
- API Integration: RESTful API with Next.js API routes
- Runtime: Node.js with Express.js
- Database: MongoDB for data persistence
- Caching: Redis for session management and performance
- AI Integration: Google Gemini API for intelligent responses
- Authentication: JWT-based authentication system
- Containerization: Docker and Docker Compose
- Database: MongoDB with Redis caching
- Environment: Configurable via environment variables
- Deployment: Railway-ready with production optimizations
AI-Powered-DnD-Game/
โโโ frontend/ # Next.js frontend application
โ โโโ app/ # Next.js app router
โ โโโ components/ # React components
โ โโโ lib/ # Utility functions and types
โ โโโ public/ # Static assets
โโโ backend/ # Node.js backend application
โ โโโ src/
โ โ โโโ routes/ # API route handlers
โ โ โโโ services/ # Business logic services
โ โ โโโ models/ # Database models
โ โ โโโ middleware/ # Express middleware
โ โโโ tests/ # Backend test suite
โโโ mock-llm-service/ # Mock AI service for testing
โโโ config/ # Configuration files
โโโ docs/ # Documentation
โโโ plans/ # Development plans and testing
โโโ docker-compose.yml # Docker orchestration
- Docker and Docker Compose
- Node.js 18+ (for local development)
- MongoDB (or use Docker)
- Redis (or use Docker)
-
Copy the environment template:
cp config/env.example .env
-
Configure your environment variables in
.env:# Database MONGODB_URI=mongodb://localhost:27017/dnd-game REDIS_URL=redis://localhost:6379 # AI Integration GEMINI_API_KEY=your_gemini_api_key # Application BACKEND_URL=http://localhost:5001 NEXT_PUBLIC_API_URL=http://localhost:3000
-
Start all services:
docker-compose up --build
-
Access the application:
- Frontend: http://localhost:3000
- Backend API: http://localhost:5001
- MongoDB: localhost:27017
- Redis: localhost:6379
# Backend tests
cd backend && npm test
# Frontend tests
cd frontend && npm test
# E2E tests with Playwright
cd frontend && npm run test:e2e- Backend: Comprehensive unit and integration tests
- Frontend: Component tests and user interaction tests
- E2E: Full application workflow testing
- API: Complete API endpoint testing
GET /api/campaigns- List all campaignsPOST /api/campaigns- Create new campaignGET /api/characters- List charactersPOST /api/characters- Create new characterGET /api/sessions/active- Get active sessionsPOST /api/gameplay/story-response- AI story response
- JWT-based authentication
- Session management with Redis
- Role-based access control
-
Install dependencies:
npm install cd frontend && npm install cd ../backend && npm install
-
Start development servers:
# Backend cd backend && npm run dev # Frontend cd frontend && npm run dev
- Linting: ESLint with TypeScript support
- Formatting: Prettier for consistent code style
- Type Safety: Full TypeScript coverage
- Testing: Jest and Playwright for comprehensive testing
The application is configured for Railway deployment with:
- Automatic builds from Git
- Environment variable management
- Database and Redis provisioning
- SSL termination and custom domains
Key environment variables for production:
MONGODB_URI- MongoDB connection stringREDIS_URL- Redis connection stringGEMINI_API_KEY- Google Gemini API keyJWT_SECRET- JWT signing secretNODE_ENV- Environment (production/development)
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Ensure all tests pass
- Submit a pull request
- Follow TypeScript best practices
- Write comprehensive tests
- Document new features
- Use conventional commit messages
This project is licensed under the MIT License - see the LICENSE file for details.
- Google Gemini: AI language model for intelligent storytelling
- Next.js: React framework for the frontend
- MongoDB: Database for data persistence
- Redis: Caching and session management
- Tailwind CSS: Utility-first CSS framework
- shadcn/ui: Modern UI component library
For support, questions, or contributions:
- Create an issue in the GitHub repository
- Check the documentation in the
docs/folder - Review the testing plans in the
plans/folder
Built with โค๏ธ for the D&D community