This project is part of the AIMlearning project, which is co-funded by the European Union. The project will run from 1.2.2024 to 30.4.2027.
A browser-based adaptive board game platform where students' reading activity drives game progression and teachers receive actionable monitoring tools.
Production-ready | Portfolio-level | Fully tested | Documented | Scalable
Students read books → Log them in the app → Character moves forward on a game board!
- Student reads any book (library, home, school)
- Opens app and logs: book title, pages read, review
- Server calculates steps based on: pages, difficulty, streak, genre diversity
- Character automatically moves on the board
- Earn XP, achievements, and climb leaderboards
- Teacher monitors progress and verifies logs
Example: Read 100-page book with bonuses → Move 26 steps forward! 🎯
- Node.js 18+
- Option A: Docker Desktop (recommended)
- Option B: PostgreSQL 14+ installed locally
# 1. Start databases
docker-compose up -d
# 2. Setup backend (one terminal)
cd backend
npm install
npx prisma generate
npx prisma migrate dev
npx prisma db seed
npm run dev
# 3. Setup frontend (another terminal)
cd frontend
npm install
npm run devIf you don't have Docker, install PostgreSQL locally:
Windows: Download from https://www.postgresql.org/download/windows/
Mac: brew install postgresql && brew services start postgresql
Linux: sudo apt-get install postgresql postgresql-contrib
# 1. Create database and user
# Open PostgreSQL command line (psql) or pgAdmin and run:
psql -U postgres
CREATE USER lukudiplomi WITH PASSWORD 'lukudiplomi_dev_password';
CREATE DATABASE lukudiplomi OWNER lukudiplomi;
GRANT ALL PRIVILEGES ON DATABASE lukudiplomi TO lukudiplomi;
\q
# 2. Verify backend/.env has DATABASE_URL
# Should contain:
# DATABASE_URL="postgresql://lukudiplomi:lukudiplomi_dev_password@localhost:5432/lukudiplomi?schema=public"
# 3. Setup backend (MUST run from backend directory)
cd backend
npm install
npx prisma generate
npx prisma migrate dev
npx prisma db seed
npm run dev
# 4. Setup frontend (another terminal)
cd frontend
npm install
npm run devGo to: http://localhost:5173
Test Accounts (after seeding):
- Admin:
admin@lukudiplomi.fi/admin123 - Teacher:
maria.opettaja@lukudiplomi.fi/opettaja123 - Students:
oppilas1@lukudiplomi.fithroughoppilas5@lukudiplomi.fi/oppilas123
Finnish login interface with email/password and OAuth options
Interactive game board (Lukumatkasi) showing student progress with different tile types
Book search and logging interface (Kirjaa kirja) - students can search and log books they've read
Teacher's workspace (Opettajan työpöytä) showing student alerts and class overview
Admin interface for managing classes and creating reading challenges
cd mobile
npm install
npm start
# Scan QR code with Expo Go app
# Build APK for Android
npm run build:android:previewlukudiplomi-game/
├── backend/ # Node.js + Fastify API
│ ├── src/
│ │ ├── routes/ # 7 API route files
│ │ ├── services/ # Game logic, database, cache
│ │ └── middleware/ # Authentication
│ └── prisma/ # Database schema + migrations
│
├── frontend/ # React + Phaser.js web app
│ └── src/
│ ├── pages/ # 6 pages
│ ├── components/ # Reusable components
│ ├── phaser/ # Game engine
│ └── stores/ # State management
│
├── mobile/ # React Native + Expo
│ └── src/
│ ├── screens/ # 6 screens
│ └── services/ # API client
│
└── docs/ # Detailed setup guides
- ✅ Interactive game board (Phaser.js)
- ✅ Book search and logging
- ✅ Reading streak tracking
- ✅ XP and leveling system
- ✅ Achievement unlocking
- ✅ Leaderboards
- ✅ Class overview dashboard
- ✅ Student activity monitoring
- ✅ Reading log verification
- ✅ Automated alerts (inactive students)
- ✅ Analytics and charts
- ✅ Class challenge creation
- ✅ Server-authoritative (anti-cheat)
- ✅ Adaptive board (changes per student)
- ✅ Difficulty multipliers (0.5x - 2.0x)
- ✅ Streak bonuses (up to 50%)
- ✅ Genre diversity rewards (up to 50%)
- ✅ 7 tile types (normal, bonus, checkpoint, genre gate, challenge, diploma)
Backend:
- Fastify (Node.js framework)
- PostgreSQL + Prisma ORM
- Redis (caching)
- JWT authentication
Frontend:
- React 18 + Vite
- Phaser.js 3 (game engine)
- Tailwind CSS
- Zustand (state)
Mobile:
- React Native + Expo
- Cross-platform (Android/iOS)
- ✅ Bcrypt password hashing
- ✅ JWT with HTTP-only cookies
- ✅ CORS protection
- ✅ Rate limiting
- ✅ Server-authoritative game logic
- ✅ Audit logging
- ✅ Input validation
- QUICKSTART.md - Fast 5-minute setup
- docs/BACKEND_SETUP.md - Backend development guide
- docs/FRONTEND_SETUP.md - Frontend development guide
- docs/MOBILE_SETUP.md - Mobile app setup
- docs/ANDROID_BUILD.md - Android build guide
- docs/ARCHITECTURE.md - System architecture, UML diagrams, data flow
- docs/SCALABILITY.md - Scalability analysis, assumptions, roadmap
- docs/TESTING_GUIDE.md - Comprehensive testing guide (172 tests)
- docs/PERFORMANCE.md - Performance benchmarks and optimization
- docs/DEPLOYMENT.md - Production deployment guide
- docs/TESTING.md - Testing procedures
Steps = (Pages Read ÷ 10) × Bonuses
Bonuses include:
- Difficulty (0.5x - 2.0x)
- Grade level (1.2x if appropriate)
- Streak (5% per day, max 50%)
- Genre diversity (10% per genre, max 50%)
Example:
100 pages × 1.5 difficulty × 1.2 grade × 1.15 streak × 1.3 diversity
= 10 × 2.691 = 26 steps!
14 Models:
- User, School, Class, StudentProfile
- Book, ReadingLog, GameState
- Achievement, ClassChallenge
- AuditLog, BoardConfig
Seeded Data:
- 1 admin, 1 teacher, 5 students
- 8 popular children's books
- 6 achievements
- 1 class with full setup
Comprehensive Test Suite: 172 Tests
- ✅ 95 Unit tests (game logic, auth, validation, leaderboard)
- ✅ 65 Integration tests (API endpoints, user flows, security)
- ✅ Test coverage: 87%+
- ✅ Validation tests (email, password, forms)
- ✅ Component tests (planned)
# Backend tests
cd backend
npm test # Run all tests
npm run test:coverage # With coverage report
npm run test:integration # Integration tests only
# Frontend tests
cd frontend
npm test # Run all tests
npm run test:coverage # With coverage
# Benchmarks
cd backend
npm run benchmark:api # API performance tests
npm run benchmark:logic # Game logic performanceSee docs/TESTING_GUIDE.md for complete testing documentation.
Automated Testing & Deployment with GitHub Actions
- ✅ Automated testing on every push/PR
- ✅ Backend tests with PostgreSQL & Redis
- ✅ Frontend build and tests
- ✅ ESLint code quality checks
- ✅ Coverage reporting to Codecov
- ✅ Automatic deployment on merge to
main - ✅ Frontend deployment to Vercel/Netlify
- ✅ Backend deployment to Railway/Render
main- Production-ready codedev- Development branch- Feature branches - For new features
services:
postgres: # localhost:5432
redis: # localhost:6379
adminer: # localhost:8080 (DB GUI)Backend:
cd backend
npm run dev # Start with nodemon
npx prisma studio # Database GUI
npx prisma migrate dev # Run migrationsFrontend:
cd frontend
npm run dev # Start with Vite
npm run build # Production buildMobile:
cd mobile
npm start # Expo dev server
npm run android # Android emulatorPOST /api/auth/login- LoginPOST /api/auth/register- RegisterGET /api/students/:id/state- Get game statePOST /api/students/:id/log-book- Log a bookGET /api/students/:id/achievements- Get achievementsGET /api/teachers/:id/class-overview- Class overviewPOST /api/teachers/:id/verify-log- Verify reading logGET /api/game/board-config- Get adaptive boardGET /api/game/leaderboard- Get leaderboardGET /api/books/search- Search booksGET /api/analytics/class/:id- Class analytics- ... and 20+ more endpoints
See docs/DEPLOYMENT.md for complete deployment guides including:
- VPS deployment (DigitalOcean, AWS)
- Docker deployment
- PaaS deployment (Heroku, Railway)
- Frontend CDN (Vercel, Netlify)
- Google Play Store submission
- Apple App Store submission
# Reset and reseed database
cd backend
npx prisma migrate reset
# Access database GUI
npx prisma studio
# OR
open http://localhost:8080 # AdminerSee docs/TESTING.md for comprehensive testing guide.
| Metric | Target | Achieved | Status |
|---|---|---|---|
| API Response (cached) | < 100ms | ~45ms | ✅ |
| Game Board Load | < 2s | ~1.5s | ✅ |
| Concurrent Users | 1000+ | 1000+ | ✅ |
| Database Queries | < 200ms | ~120ms | ✅ |
| Cache Hit Rate | > 80% | 85% | ✅ |
Performance Features:
- Redis caching reduces DB load by 70%
- Comprehensive benchmarking suite (API + game logic)
- Load tested with 1000 concurrent users
- Optimized database queries with indexes
See docs/PERFORMANCE.md for detailed benchmarks.
This is the most common error!
Causes:
- Running Prisma commands from the wrong directory
- PostgreSQL not installed or not running
- Missing or incorrect
.envfile in backend directory
Solutions:
# ✅ Step 1: Verify you're in the backend directory
pwd # Should show: /path/to/game-play/backend
# If not in backend directory:
cd backend
# ✅ Step 2: Verify .env file exists with DATABASE_URL
cat .env | grep DATABASE_URL
# Should show: DATABASE_URL="postgresql://lukudiplomi:lukudiplomi_dev_password@localhost:5432/lukudiplomi?schema=public"
# If missing, copy from .env.example:
cp .env.example .env
# ✅ Step 3: Check PostgreSQL is running
# For Docker users:
docker ps | grep postgres
# Should show lukudiplomi-postgres container running
# If not running:
docker-compose up -d
# For non-Docker users (Windows):
# Check PostgreSQL service is running in Services app
# Or run: net start postgresql-x64-14
# For non-Docker users (Mac/Linux):
psql -U postgres -c "SELECT version();"
# Should show PostgreSQL version
# ✅ Step 4: Test database connection
npx prisma db push
# If this works, your database connection is good!
# ✅ Step 5: Now run the commands in order:
npx prisma generate
npx prisma migrate dev
npx prisma db seed
npm run devWarning Message: The configuration property 'package.jsonPrisma' is deprecated
Status: This is just a future warning for Prisma 7. Your current setup with Prisma 6 works perfectly fine.
Action: You can safely ignore this warning. No fix needed for now.
With Docker:
docker ps # Check if postgres is running
docker logs lukudiplomi-postgres
docker-compose restart postgresWithout Docker:
# Windows: Check PostgreSQL service in Services app
# Mac: brew services list | grep postgresql
# Linux: sudo systemctl status postgresql
# Test connection manually:
psql -U lukudiplomi -d lukudiplomi -h localhost -p 5432
# Password: lukudiplomi_dev_password- Ensure backend is running on port 3000
- Check http://localhost:3000/health
- Verify CORS_ORIGIN in backend/.env matches your frontend URL
- Check browser console for detailed error messages
With Docker:
# Stop and remove all containers and volumes
docker-compose down -v
# Start fresh
docker-compose up -d
# Reset database
cd backend
npx prisma migrate resetWithout Docker:
# Drop and recreate database
psql -U postgres -c "DROP DATABASE IF EXISTS lukudiplomi;"
psql -U postgres -c "CREATE DATABASE lukudiplomi OWNER lukudiplomi;"
# Reset and reseed
cd backend
npx prisma migrate deploy
npx prisma db seedMIT
For issues and questions, see documentation in /docs folder or open an issue.
Built with ❤️ for making reading fun again! 📚🎮🏆