You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
CodeQuest is a full-stack gamified coding platform that teaches programming through structured courses, hands-on coding challenges, project-based learning, and social community engagement. The platform combines progression mechanics (XP, levels, streaks, badges), interactive coding workflows, and real-time communication.
Backend CORS origin is set to http://localhost:5173.
Frontend Axios base URL is set to http://localhost:5000/api.
Auth token is expected in Authorization: Bearer <token>.
8. Local Development Setup
1) Start backend
cd server
npm install
npm run seed
npm run dev
2) Start frontend
cd client
npm install
npm run dev
3) Access app
Frontend: http://localhost:5173
Backend API: http://localhost:5000/api
Health endpoint: GET /api/health
9. Available Scripts
Backend (server/package.json)
Script
Command
Purpose
npm run dev
nodemon index.js
Start API server in watch mode
npm start
node index.js
Start API server (production style)
npm run seed
node scripts/seed.js
Seed base course/challenge/narrative data
Additional scripts in server/scripts/:
seedHTML.js
seedJavaScript.js
seedPython.js
seedProjects.js
fixChallengeLanguages.js
fixPythonFunctionNames.js
fixPythonLanguage.js
fixPythonStarterCode.js
Frontend (client/package.json)
Script
Command
Purpose
npm run dev
vite
Start development server
npm run build
vite build
Create production build
npm run preview
vite preview
Preview production build
npm run lint
eslint .
Run ESLint
10. API Reference
Base URL: http://localhost:5000/api
Auth
Method
Endpoint
Auth
Description
POST
/auth/signup
No
Register user
POST
/auth/login
No
Authenticate and return JWT
Courses
Method
Endpoint
Auth
Description
GET
/courses
Yes
List available courses
GET
/courses/:id
Yes
Get full course details
GET
/courses/:id/user-progress
Yes
Get user progress for course
Challenges
Method
Endpoint
Auth
Description
GET
/challenges
Yes
List challenges (supports course/level query usage)
GET
/challenges/:id
Yes
Get challenge details
POST
/challenges/:id/submit
Yes
Submit challenge code
POST
/challenges/:id/run-python
Yes
Run Python-specific challenge checks
Gamification
Method
Endpoint
Auth
Description
GET
/gamification/streak
Yes
Get current streak
GET
/gamification/daily-challenge
Yes
Get daily challenge
POST
/gamification/daily-challenge/complete
Yes
Mark daily challenge complete
POST
/gamification/battle-complete
Yes
Mark battle completion
POST
/gamification/update-streak
Yes
Update streak state
GET
/gamification/avatar
Yes
Get avatar
PUT
/gamification/avatar
Yes
Update avatar
POST
/gamification/enroll
Yes
Enroll in a course
GET
/gamification/enrolled-courses
Yes
Get enrolled course list
GET
/gamification/course-progress/:courseId
Yes
Get course progress
PUT
/gamification/course-progress/:courseId
Yes
Update course progress
GET
/gamification/activity-days
Yes
Get activity day data
Narrative
Method
Endpoint
Auth
Description
GET
/narrative/course/:courseId
Yes
Get narrative for course
GET
/narrative/course/:courseId/chapter/:chapterNum
Yes
Get chapter content
POST
/narrative/progress
Yes
Update narrative progress
GET
/narrative/user-progress
Yes
Get narrative progress
Leaderboard and Profile
Method
Endpoint
Auth
Description
GET
/leaderboard
Yes
XP leaderboard
GET
/profile
Yes
Current user profile
Projects (Catalog/Tutorial)
Method
Endpoint
Auth
Description
GET
/projects
No
List projects with filters
GET
/projects/:id
No
Get project details
GET
/projects/slug/:slug
No
Get project by slug
POST
/projects/:id/like
Yes
Toggle like on project
POST
/projects/:id/complete
Yes
Mark project complete and award XP
User Projects (Custom Builder)
Method
Endpoint
Auth
Description
GET
/user-projects
Yes
List user projects
GET
/user-projects/:id
Yes
Get one user project
POST
/user-projects
Yes
Create user project
PUT
/user-projects/:id
Yes
Update code/output and run metadata
DELETE
/user-projects/:id
Yes
Delete user project
Project Progress (Tutorial Tracking)
Method
Endpoint
Auth
Description
GET
/project-progress/:projectId
Yes
Get progress for one project
GET
/project-progress
Yes
Get all project progress records
POST
/project-progress/:projectId/step
Yes
Complete step and award XP
POST
/project-progress/:projectId/draft
Yes
Save draft progress without XP
GET
/project-progress/:projectId/download
Yes
Download generated project zip
30 Nites of Coding
Method
Endpoint
Auth
Description
GET
/nites-of-coding
Yes
Get challenge overview
GET
/nites-of-coding/:day
Yes
Get challenge by day
POST
/nites-of-coding/:day/submit
Yes
Submit day solution
Code Execution
Method
Endpoint
Auth
Description
POST
/run-code
Yes
Run JavaScript/Python/HTML code payload
Comments (Project Comment Route Group)
Method
Endpoint
Auth
Description
GET
/comments/:projectId
No
Get comments for project
POST
/comments/:projectId
Yes
Add project comment
DELETE
/comments/:id
Yes
Delete comment
POST
/comments/:id/like
Yes
Like/unlike comment
Community Feed
Method
Endpoint
Auth
Description
GET
/community/posts
No
List posts by channel/page
POST
/community/posts
Yes
Create post
GET
/community/posts/:id
No
Get post detail
POST
/community/posts/:id/like
Yes
Toggle like
GET
/community/posts/:id/comments
No
List post comments
POST
/community/posts/:id/comment
Yes
Add post comment
DELETE
/community/posts/:postId/comments/:commentId
Yes
Delete comment
DELETE
/community/posts/:id
Yes
Delete post
GET
/community/search
No
Search posts
Chat REST Support
Method
Endpoint
Auth
Description
GET
/chat/messages
No
Get paginated messages by room
GET
/chat/messages/:id
No
Get single message
GET
/chat/rooms
No
Get available chat rooms
GET
/chat/rooms/:room/stats
No
Get room statistics
DELETE
/chat/messages/:id
Yes
Delete message (owner/admin)
GET
/chat/search/:room
No
Search messages in room
Health
Method
Endpoint
Auth
Description
GET
/health
No
Service health check
11. Real-Time Chat (Socket.IO)
Socket.IO server is initialized in server/index.js with CORS support for local frontend origin.
Client-to-Server events
chat:join (join/leave room context)
chat:send (send message)
chat:typing (typing indicator)
Server-to-Client events
chat:history (recent room history)
chat:message (broadcasted message/system event)
chat:online (online members in room)
chat:typing (typing relay)
12. Data Model Overview
Primary Mongoose models include:
User
Course
Challenge
Progress
CourseProgress
DailyChallenge
Narrative
Project
ProjectProgress
UserProject
Post
PostComment
Comment
ChatMessage
NitesOfCodingProgress
These models support progression tracking, social interactions, challenge states, and project lifecycle storage.
13. Project Learning Flows
Core learner flow
Register or login.
Access dashboard and course track.
Read theory and attempt level challenges.
Submit solutions, gain XP, unlock additional content.
Complete course to reach certificate level.
Tutorial project flow
Open tutorial project.
Complete steps and save draft/work output.
Earn XP for newly completed steps.
Complete all steps to mark tutorial complete.
Automatic community post can be generated for completion.
Custom project builder flow
Create custom project with language choice.
Edit and run code through run endpoint.
Save project updates and output history.
First successful run can award XP.
Automatic community post can be generated for project-built event.
14. Security and Auth Notes
Protected API routes require JWT bearer token.
Auth middleware validates token and loads current user.
Frontend Axios interceptor clears local auth state and redirects on 401.
Password handling is done with bcrypt-based hashing in backend auth flow.
15. Troubleshooting
Backend fails to connect to DB
Verify server/.env exists.
Ensure MONGO_URI is valid and reachable.
Confirm network/firewall allows DB access.
Frontend cannot hit API
Confirm backend is running on port 5000.
Confirm frontend runs on 5173.
Ensure CORS origin matches frontend URL.
Confirm Axios base URL points to backend API.
Frequent unauthorized responses
Verify JWT secret consistency and token freshness.
Re-login to refresh stored token.
Check request includes Authorization: Bearer <token>.
Seed data issues
Run npm run seed inside server/ after ensuring DB is reachable.
Use additional scripts from server/scripts/ for language/content fixes if needed.
16. Deployment Notes
Before production deployment, update and validate:
CORS origin configuration in backend.
API base URL in frontend Axios config.
Secure environment variable management.
HTTPS termination and reverse proxy settings.
MongoDB production cluster and backup policy.
Logging/monitoring strategy.
17. Repository Notes
This repository keeps the main project documentation in this README so the app stays easy to navigate without extra Markdown files.
18. Publish to GitHub
To push the project to GitHub:
git status
git add .
git commit -m "Update CodeQuest"
git branch -M main
git remote add origin <your-github-repo-url>
git push -u origin main
If origin already exists, use git remote set-url origin <your-github-repo-url> instead of git remote add.
About
CodeQuest is a full-stack gamified coding platform that teaches programming through structured courses, hands-on coding challenges, project-based learning, and social community engagement. The platform combines progression mechanics (XP, levels, streaks, badges), interactive coding workflows, and real-time communication.