An interactive learning platform teaching children about their fundamental rights through gamified modules. Built with React, Express, and MongoDB.
- 📖 6 Learning Modules - Comprehensive coverage of children's rights
- 🎮 4 Interactive Games - Legal Hero Journey, Build Your School, Broken Story, Match the Right
- 📊 Progress Tracking - Real-time points, badges, and achievement system
- 🎯 Personal Dashboard - Track your learning journey
Frontend
- ⚛️ React 19 + ⚡ Vite 7
- 🎨 Tailwind CSS + Radix UI
- 🔄 TanStack Query
- 🧭 React Router
Backend
- 🟢 Node.js + Express 5
- 🍃 MongoDB + Mongoose 9
- 🔐 bcrypt + CORS
Tooling
- ✅ ESLint 9
- 🔄 Nodemon
Monorepo structure: frontend at root, backend in server/ directory.
git clone <your-repo-url>
cd edurightsInstall all frontend dependencies:
npm installKey Dependencies:
🎯 Core
react&react-dom- UI libraryvite- Lightning-fast build toolreact-router-dom- Client-side routingaxios- HTTP client for API calls@tanstack/react-query- Data fetching & caching
🎨 UI & Styling
tailwindcss- Utility-first CSS framework@radix-ui/*- Accessible component primitiveslucide-react- Icon libraryclsx&tailwind-merge- Class utilitiesnext-themes- Theme management
✨ Animations
framer-motion- Smooth animationsreact-confetti- Celebration effectsreact-dnd- Drag-and-drop for games
📊 Visualization - recharts for charts & statistics
📝 Forms - react-hook-form for form handling
Other Features - sonner (toasts), react-pageflip (storybook), @emailjs/browser (feedback), custom fonts
Dev Tools - ESLint, Autoprefixer, PostCSS
Navigate to server directory and install dependencies:
cd server
npm installDependencies:
- 🚀
express- Web framework - 🍃
mongoose- MongoDB ODM - 🔐
bcryptjs- Password hashing - 🌐
cors- Cross-origin requests - ⚙️
dotenv- Environment variables - 🔄
nodemon- Auto-restart on changes
Make sure MongoDB is running:
Windows:
# Start MongoDB service
net start MongoDBmacOS/Linux:
# Start MongoDB
brew services start mongodb-community
# OR
sudo systemctl start mongodVerify MongoDB is running:
# Connect to MongoDB shell
mongoshThe app will automatically create the edurights database on first run.
Create a .env file in the server/ directory:
cd server
# Create .env file
echo. > .env # Windows
touch .env # macOS/LinuxAdd these variables to server/.env:
PORT=5000
MONGO_URI=mongodb://127.0.0.1:27017/edurightsNote: Currently, the server code has these values hardcoded, so the .env is optional for now but recommended for production deployment.
Open a terminal and start the backend:
cd server
npm run devExpected Output:
Server running on port 5000
MongoDB Connected
If MongoDB connection fails, ensure MongoDB service is running (see MongoDB Setup section).
Open another terminal and start the frontend:
# From project root
npm run devExpected Output:
VITE v7.x.x ready in XXX ms
➜ Local: http://localhost:5173/
-
Open Browser - Navigate to
http://localhost:5173 -
Test Registration
- Go to Register page
- Create a new account with name, email, password, and age
- Submit form
-
Test Login
- Login with your credentials
- Should redirect to dashboard
-
Test Modules
- Navigate to Modules section
- Select any module (1-6)
- Complete the story, explanation, and quiz
- Verify progress is saved
-
Test Games
- Go to Games section
- Try each game:
- Legal Hero Journey (5 levels)
- Build Your School
- Broken Story (10 levels)
- Match the Right
- Check if badges are awarded
-
Test Dashboard
- Return to dashboard
- Verify stats: points, progress, badges
- Check if data persists after refresh
Use Postman, Thunder Client, or curl:
Test Registration:
curl -X POST http://localhost:5000/api/auth/register \
-H "Content-Type: application/json" \
-d '{"name":"Test User","email":"[email protected]","password":"test123","age":12}'Test Login:
curl -X POST http://localhost:5000/api/auth/login \
-H "Content-Type: application/json" \
-d '{"email":"[email protected]","password":"test123"}'Test Dashboard (replace userId):
curl http://localhost:5000/api/user/{userId}/dashboardUser Flow Test
- Register → Login → Complete Module → Play Game → Check Dashboard
Progress Persistence Test
- Complete 50% of module → Logout → Login → Verify progress saved
Badge System Test
- Complete game level → Verify badge appears in dashboard
Points Calculation Test
- Submit quiz score → Check if points update correctly
Can't connect to backend
- Verify backend is running on port 5000
- Check MongoDB is running
- Look for error messages in server terminal
Frontend API calls failing
- Check Vite proxy config in
vite.config.js - Verify CORS is enabled in backend
- Check browser console for errors
Data not persisting
- Verify MongoDB connection
- Check
mongoshand viewedurightsdatabase - Use
db.users.find()to verify data
edurights/
├── public/ # Static assets
│ ├── assets/ # Images and icons
│ ├── canva-book/ # Module storybook pages
│ └── images/ # Module-specific images
├── server/ # Backend application
│ ├── config/
│ │ └── db.js # MongoDB connection logic
│ ├── controllers/ # Request handlers
│ │ ├── authController.js
│ │ ├── learnController.js
│ │ └── pointsController.js
│ ├── models/ # Mongoose schemas
│ │ ├── User.js
│ │ ├── QuizPoints.js
│ │ ├── LearnProgress.js
│ │ └── UserBadge.js
│ ├── routes/ # API endpoints
│ │ ├── authRoutes.js
│ │ ├── badges.js
│ │ ├── dashboard.js
│ │ ├── learn.js
│ │ └── pointsRoutes.js
│ ├── server.js # Express app entry
│ └── package.json # Backend dependencies
├── src/
│ ├── components/ # React components
│ │ ├── layout/ # Navbar, Footer
│ │ ├── StoryBook/ # Page-flip components
│ │ └── ui/ # Reusable UI primitives
│ ├── pages/ # Route components
│ │ ├── Dashboard.jsx
│ │ ├── Login.jsx
│ │ ├── Register.jsx
│ │ ├── Modules.jsx
│ │ ├── module1-6/ # Learning modules
│ │ └── EducationalGames/ # Game components
│ ├── data/ # Static data files
│ ├── hooks/ # Custom React hooks
│ ├── lib/ # Utility functions
│ ├── App.jsx # Root component with routes
│ └── main.jsx # Entry point
├── eslint.config.js # ESLint configuration
├── tailwind.config.js # Tailwind customization
├── vite.config.js # Vite build config
└── package.json # Frontend dependencies
npm run dev # Start development server with hot reload
npm run build # Create production build in dist/
npm run preview # Preview production build locally
npm run lint # Check code quality with ESLintnpm run dev # Start server with nodemon (auto-restart)
npm start # Start server with node (production)Base URL: http://localhost:5000/api
Register User
POST /api/auth/register
Content-Type: application/json
{
"name": "John Doe",
"email": "[email protected]",
"password": "securepass123",
"age": 12
}Login
POST /api/auth/login
Content-Type: application/json
{
"email": "[email protected]",
"password": "securepass123"
}Get User Dashboard
GET /api/user/:userId/dashboardReturns comprehensive dashboard with name, level, total points, overall progress, game-wise progress, learning progress, and earned badges.
Earn Badge
POST /api/badges/earn
Content-Type: application/json
{
"userId": "...",
"gameType": "legalHero",
"levelId": "1",
"badge": "Bronze Champion"
}Get Badges by Game
GET /api/badges/game/:gameType/:userIdGet Progress
GET /api/learn/progress/:userIdUpdate Progress
POST /api/learn/progress
Content-Type: application/json
{
"userId": "...",
"moduleKey": "module-1-progress",
"progress": 75
}Reset Progress
DELETE /api/learn/progress/:userIdSubmit Score
POST /api/points/submit/:userId
Content-Type: application/json
{
"moduleId": "module-1",
"score": 85
}Automatically saves the highest score per module.
Get User Points
GET /api/points/:userIdReturns total points and per-module breakdown.
{
name: String,
age: Number,
email: String (unique),
password: String (bcrypt hashed)
}{
userId: ObjectId,
moduleId: String,
highestScore: Number
}Unique constraint on userId + moduleId.
{
userId: ObjectId,
moduleKey: String, // module-1-progress, module-2-progress, etc.
progress: Number, // 0-100
completedAt: Date
}Unique constraint on userId + moduleKey.
{
userId: ObjectId,
gameType: String, // legalHero, brokenStory, buildSchool, matchTheRight
levelId: String,
badge: String,
earnedAt: Date
}| Route | Description |
|---|---|
/ |
Landing page |
/login |
User login |
/register |
New user registration |
/dashboard |
Personalized dashboard |
/modules |
Module selection screen |
/module-1 to /module-6 |
Individual learning modules |
/module-*/explanation |
Module explanation section |
/module-*/quiz |
Module quiz |
/games |
Games hub |
/games/legal-hero-journey |
Legal Hero game |
/games/legal-hero-journey/level-:id |
Specific level |
/games/build-your-school |
Build Your School game |
/games/build-your-school/level/:id |
School building level |
/games/broken-story |
Broken Story game |
/games/match-the-right |
Match the Right game |
/resources |
Educational resources |
/feedback |
Feedback form |
Both frontend (Vite) and backend (nodemon) support hot reload. Changes reflect automatically without restart.
Use @/ to import from src directory:
import { Button } from '@/components/ui/button'Custom design tokens are in tailwind.config.js. Uses CSS variables for theming.
API calls are cached and managed by TanStack Query. Check network tab to see optimized requests.
If you see connection errors, verify:
- MongoDB service is running
- Port 27017 is not blocked
- Database name matches in connection string
npm run buildCreates optimized production build in dist/ directory. To test:
npm run previewcd server
npm startFor production deployment:
- Use environment variables properly (configure dotenv in server.js)
- Set up reverse proxy (nginx/apache)
- Use process manager like PM2
- Configure MongoDB Atlas for cloud database
- Add rate limiting and security middleware
- Implement proper JWT authentication
Port already in use:
# Find process using port 5000
netstat -ano | findstr :5000 # Windows
lsof -i :5000 # macOS/Linux
# Kill the process
taskkill /PID <PID> /F # Windows
kill -9 <PID> # macOS/LinuxMongoDB connection failed:
- Check if MongoDB service is running
- Verify connection string in server code
- Try
mongoshto test connection manually
Module not found errors:
- Delete
node_modulesandpackage-lock.json - Run
npm installagain - Clear npm cache:
npm cache clean --force
Vite port conflict: Vite will automatically try next available port (5174, 5175, etc.)
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit changes (
git commit -m 'Add amazing feature') - Push to branch (
git push origin feature/amazing-feature) - Open a Pull Request
Current Limitations:
- No JWT implementation yet
- Passwords hashed but no session management
- CORS enabled for all origins
- No input validation middleware
- No rate limiting
Before Production:
- Implement proper authentication with JWT/cookies
- Add request validation (express-validator)
- Configure CORS for specific origins only
- Add rate limiting (express-rate-limit)
- Use helmet.js for security headers
- Implement refresh token rotation
- Add logging (winston/morgan)
This project is currently unlicensed. Please add appropriate license before distribution.