CPS Academy is a comprehensive Learning Management System built for competitive programming, computer science, and software engineering education. The platform supports four distinct user roles (Admin, Content Manager, Instructor, Student) with secure role-based access control, video lessons, timed quiz assessments, Stripe payments, and learning analytics.
- Frontend: Next.js 16 (App Router, React 19, Tailwind CSS v4, Lucide / React Icons)
- Backend / CMS: Strapi v5 Headless CMS (Node.js,
@strapi/plugin-users-permissions) - Database: Neon PostgreSQL (Serverless Postgres)
- Authentication: JWT & Google OAuth 2.0
- Payments: Stripe API & Webhook Fulfillment
- Media Hosting: ImgBB API & YouTube Video Embed Engine
Ensure you have the following installed on your machine:
- Node.js:
v18.xorv20.x(LTS recommended) - Package Manager:
npm(v9+) oryarn/pnpm - Database: PostgreSQL instance (or free serverless database like Neon)
- Stripe Account (Optional for payments): Stripe Test Mode API Keys
- Google Cloud Console (Optional for OAuth): OAuth 2.0 Web Client Credentials
git clone <your-repo-url>
cd "CPS Academy"-
Navigate to the backend directory:
cd learning-management-system-back-end -
Install dependencies:
npm install
-
Configure Environment Variables: Copy
.env.exampleto.envor create a new.envfile inlearning-management-system-back-end/:# Server Config HOST=0.0.0.0 PORT=1337 PUBLIC_URL=http://localhost:1337 FRONTEND_URL=http://localhost:3000 # Security Salts & Secrets (Generate random strings or keep defaults for local dev) APP_KEYS=randomKeyA,randomKeyB API_TOKEN_SALT=randomTokenSalt ADMIN_JWT_SECRET=randomAdminJwtSecret TRANSFER_TOKEN_SALT=randomTransferTokenSalt JWT_SECRET=randomJwtSecretString ENCRYPTION_KEY=randomEncryptionKey32CharsLong123 # Database (PostgreSQL / Neon connection string) DATABASE_CLIENT=postgres DATABASE_URL=postgresql://<user>:<password>@<host>:<port>/<dbname>?sslmode=require DATABASE_SSL=true DATABASE_SSL_REJECT_UNAUTHORIZED=false # Google OAuth 2.0 (Optional for social login) GOOGLE_CLIENT_ID=your-google-client-id.apps.googleusercontent.com GOOGLE_CLIENT_SECRET=your-google-client-secret # Stripe Payments & Webhooks STRIPE_SECRET_KEY=sk_test_... STRIPE_WEBHOOK_SECRET=whsec_...
-
Start the Strapi CMS Server:
npm run develop
- API Endpoint:
http://localhost:1337 - Admin Panel:
http://localhost:1337/admin - Note: On first launch, visit
http://localhost:1337/adminto register your local Strapi administrator account. The system bootstrap will automatically seed the 4 application roles (Admin,Content Manager,Instructor,Student) and configure essential public permissions.
- API Endpoint:
-
Open a new terminal and navigate to the frontend directory:
cd learning-management-system-front-end -
Install dependencies:
npm install
-
Configure Environment Variables: Create a
.env.localfile inlearning-management-system-front-end/:# Backend Connection NEXT_PUBLIC_STRAPI_URL=http://localhost:1337 NEXT_PUBLIC_SITE_URL=http://localhost:3000 # Stripe (Publishable Key for Checkout redirection) NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=pk_test_...
-
Start the Next.js Development Server:
npm run dev
- Frontend App:
http://localhost:3000
- Frontend App:
-
Create an Account:
- Go to
http://localhost:3000/auth/registerand create a student account. - Newly registered users are assigned the Student role by default and redirected to
/dashboard/student.
- Go to
-
Switch Roles (Admin / Instructor / Content Manager):
- Go to the Strapi Admin Panel at
http://localhost:1337/admin. - Navigate to Content Manager ➔ Users (Users-Permissions).
- Select the target user and change their Role to
Admin,Content Manager,Instructor, orStudent. - Log out and log back in on the frontend to access the respective dashboard (
/dashboard/admin,/dashboard/manager,/dashboard/instructor,/dashboard/student).
- Go to the Strapi Admin Panel at
To test the payment reconciliation and automatic course enrollment locally:
- Download and authenticate the Stripe CLI.
- Forward events directly to the local backend:
stripe listen --forward-to localhost:1337/api/orders/webhook
- Copy the output signing secret (
whsec_...) and updateSTRIPE_WEBHOOK_SECRETin your backend.envfile.
- Strict Role Isolation: 4 dedicated dashboard workspaces (
/dashboard/student,/dashboard/instructor,/dashboard/manager,/dashboard/admin). - Edge Route Guards: Next.js 16 proxy middleware (
src/proxy.js) automatically intercepts unauthenticated requests and isolates cross-role access. - Granular Permissions Matrix:
- Admin: Full platform control, user management, global role assignment, and audit logs.
- Content Manager: Global curriculum authoring (courses, modules, lessons, quizzes, blogs) and cross-course analytics.
- Instructor: Ownership-scoped course authoring, module & lesson management, quiz builders, and student progress tracking for assigned courses.
- Student: Course discovery, Stripe checkout enrollment, distraction-free video learning interface, timed quizzes, and scorecard tracking.
- Search & Filtering: Real-time query search, category filters, difficulty sorting, and dynamic course badges.
- Hierarchical Curriculum: Nested relational structure (
Course➔Modules➔Lessons&Quizzes). - Interactive Player: Responsive YouTube video player with progress checkpoints, completion toggles, lesson navigation sidebar, and downloadable resources.
- Media Uploads: Built-in ImgBB media engine for direct thumbnail uploads with preview support.
- Zero-Cheat Architecture: Correct answer keys and explanations are omitted from student-facing payloads and validated strictly server-side upon submission.
- Timer & Auto-Submit: Active countdown timer with automated submission on expiry.
- Instant Detailed Scorecard: Breakdown of total score, pass/fail status, and explanation for each question post-submission.
- Secure Server-Side Checkout: Dynamic Stripe checkout session generation with automatic currency and price validation.
- Transactional Webhook Listener: Webhook endpoint (
/api/orders/webhook) verifies Stripe signatures and atomically creates enrollment and payment records upon payment completion.
- Engineering Blog: Public articles with category filtering, search, and rich markdown rendering.
- Student Success Stories: Verified alumni rating jumps, contest achievements, and career trajectories.
- Strict 4-Color Design System: Clean, flat design system using 4 brand colors (
#355872,#7AAACE,#9CD5FF,#F7F8F0) with full light and dark mode support.
-
Strapi v5 Relation Sanitization:
- Challenge: Strapi v5's default
sanitizeOutputstripped author and instructor relation attributes for unauthenticated and student users due to Users-Permissions field restrictions. - Solution: Custom controller overrides explicitly preserve safe public profile fields (
id,username,email) on instructor relations after output sanitization.
- Challenge: Strapi v5's default
-
Nested Module & Lesson Permission Propagation:
- Challenge: Nested relations (
course.modules.lessons) were filtered out forPublicandStudentroles when child permissions were not explicitly enabled in the Users & Permissions plugin. - Solution: Programmatically seeded read permissions for modules, lessons, and quizzes in the Strapi bootstrap lifecycle (
src/index.js) and ensured controllers preserve curriculum arrays.
- Challenge: Nested relations (
-
Cloud Reverse Proxy & HTTPS Cookies in OAuth:
- Challenge: Deploying backend to Railway behind an HTTPS proxy triggered
Cannot send secure cookie over unencrypted connectionduring Google OAuth callbacks because internal Koa instances received plain HTTP. - Solution: Configured
proxy: { koa: true }inconfig/server.js, updated session cookie policies (secure: false,sameSite: 'lax'), and added dynamic CORS origin matching.
- Challenge: Deploying backend to Railway behind an HTTPS proxy triggered
-
Next.js 16 Route Interception & Hydration Consistency:
- Challenge: Direct
localStoragereads during initial SSR caused client hydration mismatches, andsrc/middleware.jstriggered Next.js 16 deprecation warnings. - Solution: Migrated edge route interception to the Next.js 16
src/proxy.jsconvention and implemented deterministic SSR state with mounted synchronization insideuseEffect.
- Challenge: Direct
-
Quiz Answer Security & Integrity:
- Challenge: Ensuring students cannot inspect client-side network payloads or DOM state to view quiz answers beforehand.
- Solution: Built server-side answer sanitization on
find/findOnequiz endpoints, computing final scores and explanations exclusively inside custom Strapi submission controllers.