Version: 1.0
Date: December 11, 2025
Document Owner: Development Team
Data Science Dungeon is a browser-based, 8-bit style educational game that combines dungeon exploration mechanics with data science knowledge assessment. Players control a hero character navigating through a series of rooms, answering progressively difficult data science questions to advance through levels.
To create an engaging, gamified learning platform that tests and reinforces data science knowledge across multiple domains while providing an entertaining retro gaming experience.
A web-based application featuring:
- 8-bit pixel art game environment
- Question-based progression system
- Multi-room dungeon navigation
- Persistent user progress tracking
- Dynamic question retrieval system
- Movement System
- Player controls hero character using keyboard arrow keys (↑ ↓ ← →)
- Character must be able to traverse freely within room boundaries
- Collision detection with walls, chests, and room boundaries
- Smooth, responsive movement appropriate for 8-bit aesthetics
- Environment Design
- Each room represents one level in the dungeon
- 10 total rooms required to complete the game
- Each room contains exactly 3 treasure chests
- Chests positioned strategically within the room space
- Interaction Mechanism
- Space bar key used to open/close chests
- Interaction only available when hero is within proximity of chest
- Visual indicator when hero is near enough to interact
- Chest state changes visually when opened
- Question Presentation
- Question displayed when chest is opened
- User must answer before continuing
- Three questions per room (one per chest)
- Progressive difficulty: Easy → Medium → Hard within each room
- Per-Room Scaling
- Chest 1: Easy difficulty
- Chest 2: Medium difficulty
- Chest 3: Hard difficulty
- Cross-Room Scaling
- Overall difficulty increases as player progresses through rooms 1-10
- Brightness Reduction
- Screen brightness decreases by 20% for each incorrect answer
- Maximum 5 incorrect answers allowed (100% → 80% → 60% → 40% → 20% → 0%)
- Visual feedback showing brightness reduction effect
- Game ends (Game Over) when brightness reaches 0%
- Advancement Criteria
- Player must answer all 3 questions in a room to proceed
- Upon completing room (3 correct answers), door/portal to next room unlocks
- Progress saved after each completed room
Questions must cover the following data science domains:
- Statistics (descriptive, inferential, probability)
- Machine Learning (ML) (supervised, unsupervised, algorithms)
- Deep Learning (DL) (neural networks, architectures, optimization)
- Reinforcement Learning (RL) (agents, rewards, policies)
- Natural Language Processing (NLP) (tokenization, embeddings, models)
- Large Language Models (LLMs) (transformers, fine-tuning, prompting)
- Generative AI (GenAI) (GANs, diffusion models, applications)
- API Integration
- Questions fetched from external API endpoint
- API must provide questions with difficulty levels
- API must categorize questions by topic
- Fallback mechanism if API unavailable
- Non-Repetition Logic
- Questions should not repeat during gameplay session
- Questions should not repeat across multiple gameplay sessions for same user
- Track answered questions in database
- Intelligent question pool management
- Current room number
- Questions answered correctly
- Questions answered incorrectly
- Current brightness level
- Timestamp of last play
- Completion status per room
- Auto-save after each room completion
- Manual save option
- Load saved game on return
- Multiple save slots (optional enhancement)
- Authentic 8-bit pixel art aesthetic
- Limited color palette consistent with retro games
- Sprite-based character and object rendering
- Tile-based room construction
- Health/brightness indicator
- Room number display
- Question dialog box
- Answer input interface
- Progress indicator
- All game assets stored in
/assetsfolder - Organized subfolders:
/assets/sprites- Character and object sprites/assets/tiles- Room tiles and backgrounds/assets/ui- UI elements and fonts/assets/audio- Sound effects and music (if applicable)
- Framework: Phaser 3 (recommended for 2D game development)
- Alternative: Pixi.JS + React for more control
- Alternative: HTML5 Canvas + Vanilla JavaScript for lightweight approach
- Rendering: HTML5 Canvas
- State Management: Context API (React) or Phaser's built-in state management
- Styling: CSS3 for UI elements outside canvas
Justification: Phaser 3 provides:
- Built-in sprite and tilemap systems
- Easy keyboard input handling
- Collision detection
- Scene management for room transitions
- Active community and documentation
- Framework: FastAPI (Python)
- Server: Uvicorn (ASGI server)
- API Design: RESTful architecture
- Authentication: JWT tokens for user sessions
- Database: SQLite
- ORM: SQLAlchemy (Python)
- Migrations: Alembic
- Client-Server architecture
- Frontend renders game and handles user input
- Backend manages data persistence and question delivery
- Stateless API communication via REST
User Input → Frontend (Phaser) → API Request → Backend (FastAPI)
→ Database (SQLite) → API Response → Frontend Update → Render
POST /api/users/register- Create new user accountPOST /api/users/login- Authenticate userGET /api/users/profile- Get user profilePUT /api/users/profile- Update user profile
GET /api/progress/{user_id}- Retrieve user's game progressPOST /api/progress/{user_id}- Save game progressPUT /api/progress/{user_id}/room- Update current roomPUT /api/progress/{user_id}/brightness- Update brightness level
GET /api/questions/random- Get random question by difficulty and topic- Query params:
difficulty,topic,exclude_ids
- Query params:
GET /api/questions/{question_id}- Get specific questionPOST /api/questions/answered- Record answered questionGET /api/questions/pool- Get available questions count
GET /api/external/questions- Proxy endpoint to external question source- Caching layer for frequently accessed questions
- Error handling and fallback to local question bank
CREATE TABLE users (
id INTEGER PRIMARY KEY AUTOINCREMENT,
username VARCHAR(50) UNIQUE NOT NULL,
email VARCHAR(100) UNIQUE NOT NULL,
password_hash VARCHAR(255) NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
last_login TIMESTAMP
);CREATE TABLE game_progress (
id INTEGER PRIMARY KEY AUTOINCREMENT,
user_id INTEGER NOT NULL,
current_room INTEGER DEFAULT 1,
brightness_level INTEGER DEFAULT 100,
total_correct INTEGER DEFAULT 0,
total_incorrect INTEGER DEFAULT 0,
game_completed BOOLEAN DEFAULT FALSE,
last_saved TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (user_id) REFERENCES users(id)
);CREATE TABLE questions (
id INTEGER PRIMARY KEY AUTOINCREMENT,
external_id VARCHAR(100) UNIQUE,
question_text TEXT NOT NULL,
option_a TEXT NOT NULL,
option_b TEXT NOT NULL,
option_c TEXT NOT NULL,
option_d TEXT NOT NULL,
correct_answer CHAR(1) NOT NULL,
difficulty VARCHAR(20) NOT NULL,
topic VARCHAR(50) NOT NULL,
explanation TEXT,
cached_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);CREATE TABLE answered_questions (
id INTEGER PRIMARY KEY AUTOINCREMENT,
user_id INTEGER NOT NULL,
question_id INTEGER NOT NULL,
answered_correctly BOOLEAN NOT NULL,
answered_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
room_number INTEGER,
FOREIGN KEY (user_id) REFERENCES users(id),
FOREIGN KEY (question_id) REFERENCES questions(id),
UNIQUE(user_id, question_id)
);CREATE TABLE room_completion (
id INTEGER PRIMARY KEY AUTOINCREMENT,
user_id INTEGER NOT NULL,
room_number INTEGER NOT NULL,
completed_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
time_taken INTEGER,
FOREIGN KEY (user_id) REFERENCES users(id),
UNIQUE(user_id, room_number)
);- Game should run at minimum 30 FPS on modern browsers
- API response time < 200ms for 95% of requests
- Database queries optimized with appropriate indexes
- Asset loading time < 3 seconds on standard broadband
- Support for 100+ concurrent users
- Question pool of minimum 500 questions
- Efficient caching of frequently accessed data
- Browsers: Chrome 90+, Firefox 88+, Safari 14+, Edge 90+
- Devices: Desktop (primary), Tablet (secondary)
- Screen Resolutions: 1280x720 minimum
- Password hashing using bcrypt (minimum 12 rounds)
- SQL injection prevention via parameterized queries
- XSS protection on user inputs
- HTTPS required for production
- Rate limiting on API endpoints
- Intuitive keyboard controls
- Clear visual feedback for all interactions
- Accessible UI design
- Responsive game interface
- Auto-save functionality to prevent progress loss
- Graceful error handling and user feedback
- Offline capability for gameplay (questions pre-cached)
- 99% uptime target
- Main Canvas: Game rendering area (primary viewport)
- HUD (Heads-Up Display):
- Top-left: Room number (e.g., "Room 3/10")
- Top-right: Brightness indicator (visual bar or percentage)
- Bottom: Interaction prompt ("Press SPACE to open chest")
- Modal Overlay: Semi-transparent background
- Question Panel:
- Question text (centered, readable font)
- Four answer options (A, B, C, D)
- Submit button
- Close/Cancel option
- Feedback Display:
- Correct: Green highlight + positive message
- Incorrect: Red highlight + brightness reduction animation
- Main Menu:
- New Game
- Continue Game
- Settings
- About
- Settings:
- Volume controls
- Graphics quality
- Key bindings
- Pause Menu:
- Resume
- Save Game
- Exit to Main Menu
[Start] → [Main Menu] → [New Game / Load Game]
↓
[Room 1] → [Chest 1] → [Question Easy] → [Correct?]
↓ ↓
↓ [Yes] → [Chest 2]
↓ [No] → [-20% Brightness]
↓
[Chest 2] → [Question Medium] → [Correct?]
↓
[Chest 3] → [Question Hard] → [Correct?]
↓
[All 3 Correct?] → [Yes] → [Room Complete] → [Next Room]
[No] → [Continue/Game Over]
↓
[Repeat for Rooms 2-10]
↓
[Room 10 Complete] → [Victory Screen] → [End]
[Brightness = 0%] → [Game Over] → [Retry/Main Menu]
- Project initialization and environment setup
- Database schema creation and migration
- Basic game engine implementation (movement, collision)
- Room rendering system
- API development for question retrieval
- External API integration
- Question caching mechanism
- Answer validation logic
- Chest interaction system
- Brightness penalty implementation
- Room transition logic
- Progress saving/loading
- 8-bit asset integration
- HUD implementation
- Question dialog design
- Menu systems
- Unit testing (backend)
- Integration testing
- User acceptance testing
- Deployment to production server
- Backend API endpoints (FastAPI test client)
- Database operations (SQLAlchemy)
- Game logic functions
- Frontend-Backend communication
- External API integration
- Database transactions
- Gameplay mechanics validation
- UI/UX feedback
- Performance testing across browsers
- Accessibility testing
- Local SQLite database
- Development server (localhost)
- Hot-reload enabled
- Frontend Hosting: Netlify, Vercel, or AWS S3 + CloudFront
- Backend Hosting: AWS EC2, DigitalOcean, or Heroku
- Database: SQLite file on server (consider PostgreSQL for scale)
- CI/CD: GitHub Actions or GitLab CI
DATABASE_URL=sqlite:///./dungeon.db
SECRET_KEY=<jwt-secret-key>
EXTERNAL_QUESTION_API_URL=<api-endpoint>
EXTERNAL_QUESTION_API_KEY=<api-key>
CORS_ORIGINS=https://yourdomain.com
- Leaderboard system
- Competitive quiz challenges
- Co-op dungeon exploration
- More room themes
- Power-ups and collectibles
- Achievement system
- Daily challenges
- Sound effects and background music
- Animated sprites
- Boss battles with timed questions
- Story mode with narrative elements
The project will be considered complete when:
- ✅ User can create account and login
- ✅ Hero character moves smoothly with arrow keys
- ✅ All 10 rooms are navigable
- ✅ 3 chests per room with working interactions
- ✅ Questions are fetched from API without repetition
- ✅ Difficulty increases progressively
- ✅ Brightness penalty system works correctly
- ✅ Game ends at 0% brightness
- ✅ Progress is saved and can be resumed
- ✅ All questions cover specified topics
- ✅ Game completion (Room 10) triggers victory state
- ✅ Responsive UI across supported browsers
| Risk | Impact | Mitigation |
|---|---|---|
| External API unavailability | High | Implement local question fallback, cache questions |
| Performance issues on low-end devices | Medium | Optimize sprite rendering, implement quality settings |
| Question pool exhaustion | Medium | Large initial question database, periodic updates |
| User data loss | High | Frequent auto-saves, backup mechanisms |
| Browser compatibility issues | Low | Cross-browser testing, polyfills |
/assets
/sprites
/hero
- hero_idle.png
- hero_walk.png
/chests
- chest_closed.png
- chest_open.png
/tiles
- dungeon_floor.png
- dungeon_wall.png
/ui
- hud_frame.png
- dialog_box.png
/audio (optional)
- chest_open.wav
- correct_answer.wav
- wrong_answer.wav
| Key | Action |
|---|---|
| ↑ | Move Up |
| ↓ | Move Down |
| ← | Move Left |
| → | Move Right |
| SPACE | Interact (Open/Close Chest) |
| ESC | Pause Menu |
| Room | Chest 1 | Chest 2 | Chest 3 |
|---|---|---|---|
| 1-3 | Easy | Medium | Hard |
| 4-6 | Medium | Hard | Very Hard |
| 7-10 | Hard | Very Hard | Expert |
Document End
This specification is subject to revisions based on stakeholder feedback and technical feasibility assessments.