A modern Learning Management System (LMS) built by the Student Web Committee for hosting educational modules, quizzes, progress tracking, and leaderboards.
- Tech Stack
- Project Structure
- Getting Started
- Development
- API Documentation
- Contributing
- Troubleshooting
- Runtime: Node.js
- Framework: Express.js
- Database: MongoDB (Cloud: MongoDB Atlas)
- Authentication: GitHub OAuth 2.0 + JWT
- Package Manager: npm
- Framework: React 19
- Router: React Router DOM v7
- Build Tool: Vite
- Styling: Tailwind CSS
- Animations: Framer Motion
- Package Manager: npm
Hackstack-Portal/
βββ backend/
β βββ config/
β β βββ db.js # Database connection config
β βββ controllers/ # Business logic
β β βββ authController.js
β β βββ moduleController.js
β β βββ userController.js
β β βββ progressController.js
β β βββ quizController.js
β βββ middleware/ # Express middleware
β β βββ authMiddleware.js # JWT verification
β β βββ adminMiddleware.js # Admin role check
β βββ models/ # MongoDB schemas
β β βββ User.js
β β βββ Module.js
β β βββ Quiz.js
β β βββ Progress.js
β βββ routes/ # API endpoints
β β βββ authRoutes.js
β β βββ moduleRoutes.js
β β βββ userRoutes.js
β β βββ progressRoutes.js
β β βββ quizRoutes.js
β β βββ adminRoutes.js
β βββ .env.example # Environment template
β βββ package.json
β βββ server.js # Express server entry point
β
βββ frontend/
β βββ src/
β β βββ assets/ # Images, icons, etc.
β β βββ context/
β β β βββ AuthContext.jsx # Global auth state
β β βββ pages/ # Page components
β β β βββ Login.jsx
β β β βββ AuthCallback.jsx
β β βββ services/
β β β βββ authService.js # API client for auth
β β βββ App.jsx # Main app + routing
β β βββ main.jsx # React entry point
β β βββ index.css
β βββ public/ # Static assets
β βββ .env.example # Environment template
β βββ vite.config.js
β βββ package.json
β βββ index.html
β
βββ .gitignore
βββ README.md # This file
βββ CODE_REVIEW_REPORT.md # Detailed code review
- Node.js (v18 or higher)
- npm (v8 or higher)
- MongoDB Account (MongoDB Atlas recommended - free tier available)
- GitHub OAuth App (for authentication)
git clone <repository-url>
cd Hackstack-Portal- Go to GitHub Settings β Developer settings β OAuth Apps
- Click "New OAuth App"
- Fill in the form:
- Application name: Hackstack Portal
- Homepage URL:
http://localhost:5173 - Authorization callback URL:
http://localhost:5000/api/auth/github/callback
- Copy your Client ID and Client Secret
- Go to MongoDB Atlas
- Create a free account and cluster
- Create a database user with a strong password
- Get your connection URI (looks like:
mongodb+srv://username:password@cluster.mongodb.net/hackstack)
cd backend
# Install dependencies
npm install
# Create .env file
cp .env.example .env
# Edit .env with your credentials:
# - MONGO_URI: Your MongoDB connection string
# - JWT_SECRET: Generate a random secret (e.g., openssl rand -hex 32)
# - GITHUB_CLIENT_ID: Your GitHub OAuth Client ID
# - GITHUB_CLIENT_SECRET: Your GitHub OAuth Client Secret
# - FRONTEND_URL: http://localhost:5173 (for development)
# Start the server
npm run devServer runs on http://localhost:5000
cd ../frontend
# Install dependencies
npm install
# Create .env file
cp .env.example .env
# Verify VITE_API_URL=http://localhost:5000/api
# Start the development server
npm run devFrontend runs on http://localhost:5173
- Navigate to
http://localhost:5173/login - Click "Continue with GitHub"
- You should be redirected to login and then to the dashboard
- β If you see the dashboard, authentication is working!
cd backend
# Start development server (with hot reload via nodemon)
npm run dev
# Run linting (if configured)
npm run lint
# Note: Test suite not yet implementedcd frontend
# Start development server
npm run dev
# Build for production
npm run build
# Preview production build locally
npm run preview
# Run linting
npm run lintBackend (.env):
MONGO_URI=mongodb+srv://username:password@cluster.mongodb.net/hackstack
JWT_SECRET=your_random_secret_here
GITHUB_CLIENT_ID=your_client_id
GITHUB_CLIENT_SECRET=your_client_secret
FRONTEND_URL=http://localhost:5173
PORT=5000
Frontend (.env):
VITE_API_URL=http://localhost:5000/api
| Method | Endpoint | Description | Auth Required |
|---|---|---|---|
| GET | /api/auth/github |
Redirect to GitHub OAuth | β |
| GET | /api/auth/github/callback |
OAuth callback handler | β |
| GET | /api/auth/me |
Get current user | β |
| Method | Endpoint | Description | Auth Required |
|---|---|---|---|
| GET | /api/modules |
List all modules | β |
| GET | /api/modules/:slug |
Get module by slug | β |
| POST | /api/modules/:id/register |
Register for module | β |
| POST | /api/modules |
Create module | β Admin |
| PUT | /api/modules/:id |
Update module | β Admin |
| DELETE | /api/modules/:id |
Delete module | β Admin |
| Method | Endpoint | Description | Auth Required |
|---|---|---|---|
| GET | /api/quizzes |
List all quizzes | β |
| GET | /api/quizzes/:id |
Get quiz by ID | β |
| POST | /api/quizzes/:id/submit |
Submit quiz answers | β |
| POST | /api/quizzes |
Create quiz | β Admin |
| PATCH | /api/quizzes/:id |
Update quiz | β Admin |
| DELETE | /api/quizzes/:id |
Delete quiz | β Admin |
| Method | Endpoint | Description | Auth Required |
|---|---|---|---|
| GET | /api/progress |
List progress records | β |
| GET | /api/progress/:id |
Get progress record | β |
| PATCH | /api/progress/:id |
Update progress | β |
| Method | Endpoint | Description | Auth Required |
|---|---|---|---|
| GET | /api/users |
List all users | β |
| GET | /api/users/:id |
Get user by ID | β |
| POST | /api/users |
Create user | β |
| PATCH | /api/users/:id |
Update user | β |
| DELETE | /api/users/:id |
Delete user | β |
All admin endpoints require auth + admin middleware:
GET /api/admin/modules- List modulesPOST /api/admin/modules- Create modulePUT /api/admin/modules/:id- Update moduleDELETE /api/admin/modules/:id- Delete module- Similar endpoints for
/admin/quizzes,/admin/progress,/admin/users
-
Create a feature branch:
git checkout -b feature/your-feature-name
-
Make your changes and test thoroughly
-
Lint your code:
# Frontend cd frontend && npm run lint # Backend (if linting is configured) cd backend && npm run lint
-
Commit with clear messages:
git add . git commit -m "feat: describe your changes"
-
Push your branch:
git push origin feature/your-feature-name
-
Create a Pull Request on GitHub with a clear description
- JavaScript: Use ES6+ syntax
- React: Use functional components with hooks
- Naming: Use camelCase for variables/functions, PascalCase for components
- Imports: Organize imports (React, third-party, local)
- Comments: Add comments for complex logic
# Clear node_modules and reinstall
rm -rf node_modules package-lock.json
npm install# Backend (Port 5000)
lsof -i :5000
kill -9 <PID>
# Frontend (Port 5173)
lsof -i :5173
kill -9 <PID>- Verify connection URI in
.env - Check MongoDB Atlas IP whitelist (add your IP or 0.0.0.0)
- Ensure database user has correct credentials
- Test connection:
mongo "your-connection-string"
- Verify Client ID and Client Secret in
.env - Check OAuth redirect URL matches
http://localhost:5000/api/auth/github/callback - Ensure FRONTEND_URL is correctly set
- Verify
FRONTEND_URLin backend.envmatches your frontend URL - Check that CORS middleware in
server.jsallows your frontend domain
# Rebuild Vite cache
rm -rf frontend/node_modules/.vite
npm run dev- Complete Dashboard component
- Module detail pages with content rendering
- Quiz taking interface
- Progress tracking dashboard
- Leaderboard implementation
- Admin panel UI
- User profile pages
- Notification system
- Test suite (Jest + Supertest for backend, Vitest for frontend)
- API documentation (Swagger/OpenAPI)
- Production deployment guide