Skip to content

Latest commit

 

History

History
279 lines (230 loc) · 12.1 KB

File metadata and controls

279 lines (230 loc) · 12.1 KB

Virtual Courses - AI Proctoring LMS

Node.js React Vite Express MongoDB Redis YOLOv8 Docker CI/CD License: ISC

A production-grade, containerized AI-powered Learning Management System (LMS) with computer vision proctoring, multi-resolution video transcoding, AI certification interviews, Redis caching, robust security hardening, and real-time WebSocket communication.


Architecture Overview

graph TD
  subgraph Client_Layer [Client Layer]
    UI[React 19 + Vite + Redux Toolkit SPA]
  end

  subgraph Gateway_Proxy [Reverse Proxy & Caching]
    NGINX[Nginx Frontend Container]
    REDIS[(Redis 7 Cache & Rate Limiting)]
  end

  subgraph App_Cluster [Application Cluster]
    API[Express 5 Node.js Backend API]
    PY_AI[Python 3.11 YOLOv8 Microservice]
  end

  subgraph External_Services [External Cloud Services & Storage]
    MONGO[(MongoDB Atlas Database)]
    CLOUDINARY[Cloudinary CDN & Media Storage]
    RAZORPAY[Razorpay Payment Gateway]
    GROQ[Groq Cloud LLM - Llama 3.3]
    FIREBASE[Firebase Authentication]
    MAIL[Nodemailer SMTP]
  end

  UI --> NGINX
  NGINX --> API
  API --> REDIS
  API --> MONGO
  API --> PY_AI
  API --> CLOUDINARY
  API --> RAZORPAY
  API --> GROQ
  API --> FIREBASE
  API --> MAIL
Loading

Core Capabilities & Features

1. AI Proctoring System

  • YOLOv8 & OpenCV Microservice: Real-time object detection (cell phones, laptops, books, secondary screens), face count tracking, and head pose/gaze estimation.
  • Client-side Fallback & Behavioral Monitoring: TensorFlow.js Coco-SSD fallback, tab-switch detection, fullscreen exit monitoring, and violation risk scoring.
  • Auditing Dashboard: Educator view with timestamps, violation screenshots hosted on Cloudinary, and weighted severity penalties.

2. Video Transcoding Pipeline

  • Adaptive Bitrate Transcoding: Background FFmpeg transcoding generating 144p to 1080p resolution ladders capped at source resolution.
  • Resilient Background Processing: Lectures remain locked until ready status with automated failure recovery on server restart.

3. AI-Powered Certification & Exam Engine

  • Dynamic AI Oral/Text Interview: Interactive multi-turn technical assessments evaluated by Groq (Llama 3.3).
  • Automated Certificate Generation: Programmatic vector PDF certificate generation via pdfkit with verification codes.
  • Assessment Management: Timed MCQs, auto-grading, student performance analytics, and attempt histories.

4. Caching & Performance (Redis Layer)

  • High-Throughput Course Caching: Caching of published courses catalogue and course details with automatic cache invalidation on course/lecture mutations.
  • Graceful Fallback: Automatic in-memory LRU/Map fallback if Redis is unreachable.

5. Security & Resilience Hardening

  • Rate Limiting: Tiered request rate limiting via express-rate-limit across Auth/OTP routes, AI endpoints, and proctoring frame ingestion.
  • Strict Payload Validation: Schema validation using zod on all request bodies, query parameters, and IDs.
  • Server-side Firebase Auth Verification: Server-side ID token validation with firebase-admin to prevent client identity spoofing.

Tech Stack

Layer Technologies
Frontend React 19, Vite 6, Redux Toolkit, React Router v7, Tailwind CSS, Framer Motion, Recharts
Backend API Node.js 20, Express 5, Socket.io, Multer, JWT, BcryptJS, Zod, Express Rate Limit
Microservices Python 3.11, Flask, Gunicorn, Ultralytics YOLOv8, OpenCV
Databases & Cache MongoDB (Mongoose), Redis 7 (ioredis)
Media & Processing Cloudinary, FFmpeg (multi-resolution ladders), PDFKit
Integrations Razorpay, Firebase Admin & Client Auth, Groq Cloud (Llama 3.3), Nodemailer
DevOps & Testing Docker, Docker Compose, Nginx, GitHub Actions CI/CD, Vitest, Supertest, ESLint

Project Structure

.
├── .github/
│   └── workflows/
│       └── ci.yml                 # Automated CI/CD pipeline
├── backend/
│   ├── ai_proctoring/             # Python YOLOv8 Computer Vision Service
│   │   ├── Dockerfile
│   │   ├── requirements.txt
│   │   ├── yolo_detector.py
│   │   └── yolov8n.pt
│   ├── configs/                   # DB, Redis, Cloudinary, Mail, Firebase Admin
│   ├── controllers/               # Auth, Course, Exam, Proctoring, AI, Payment
│   ├── middlewares/               # Auth, RBAC, Rate Limiting, Zod Validation
│   ├── models/                    # Mongoose Schemas (User, Course, Exam, etc.)
│   ├── routes/                    # API Route Definitions
│   ├── services/                  # Cache, Transcode, Proctoring Services
│   ├── tests/                     # Automated Vitest & Supertest suite
│   ├── Dockerfile                 # Node.js + FFmpeg Container
│   ├── socket.js                  # Socket.io Real-time Event Handlers
│   ├── index.js                   # Application Entrypoint
│   └── package.json
├── frontend/
│   ├── public/
│   ├── src/
│   │   ├── components/            # Reusable UI Components
│   │   ├── pages/                 # Student, Educator, Admin & Exam Views
│   │   ├── redux/                 # Redux Slices & Store
│   │   └── utils/                 # Firebase & Helper Utilities
│   ├── Dockerfile                 # Multi-stage Vite + Nginx Container
│   ├── nginx.conf                 # SPA Routing & Proxy Configuration
│   └── package.json
├── docker-compose.yml             # Root Multi-Service Container Orchestration
├── README.md
└── ...

Quickstart Guide

Option 1: One-Command Docker Setup (Recommended)

Ensure you have Docker Desktop installed:

  1. Clone the repository:

    git clone https://github.com/AyushCipher/AI-Procturing-LMS.git
    cd AI-Procturing-LMS
  2. Create a .env file in the root directory (or inside backend/.env):

    MONGODB_URL=your_mongodb_connection_string
    JWT_SECRET=your_super_secret_jwt_key
    CLOUDINARY_CLOUD_NAME=your_cloudinary_name
    CLOUDINARY_API_KEY=your_cloudinary_key
    CLOUDINARY_API_SECRET=your_cloudinary_secret
    RAZORPAY_KEY_ID=your_razorpay_key
    RAZORPAY_SECRET=your_razorpay_secret
    EMAIL=your_email@gmail.com
    EMAIL_PASS=your_email_app_password
    GROQ_API_KEY=your_groq_api_key
  3. Build and launch all services:

    docker compose up --build
  4. Access the applications:

    • Frontend UI: http://localhost:5173
    • Backend API: http://localhost:8000
    • AI Proctoring Microservice: http://localhost:5001
    • Redis Cache: localhost:6379

Option 2: Local Manual Setup

1. Backend & Cache Setup

cd backend
npm install
npm run dev

2. Python AI Proctoring Microservice Setup

cd backend/ai_proctoring
python -m venv venv
# On Windows:
venv\Scripts\activate
# On Linux/macOS:
source venv/bin/activate

pip install -r requirements.txt
python yolo_detector.py

3. Frontend Setup

cd frontend
npm install
npm run dev

4. Run Automated Tests

cd backend
npm test

Environment Variables Reference

Backend (backend/.env)

Variable Required Description
PORT Optional Server port (defaults to 8000)
MONGODB_URL Yes MongoDB Atlas or local connection string
JWT_SECRET Yes Secret used to sign JSON Web Tokens
FRONTEND_URL Optional Frontend URL for CORS and emails (defaults to http://localhost:5173)
REDIS_URL Optional Redis connection URL (defaults to redis://localhost:6379)
YOLO_SERVICE_URL Optional Python YOLO microservice endpoint (defaults to http://localhost:5001)
CLOUDINARY_CLOUD_NAME Yes Cloudinary cloud account name
CLOUDINARY_API_KEY Yes Cloudinary API Key
CLOUDINARY_API_SECRET Yes Cloudinary API Secret
RAZORPAY_KEY_ID Yes Razorpay Merchant Key ID
RAZORPAY_SECRET Yes Razorpay Merchant Key Secret
EMAIL Yes SMTP email address for transactional emails & OTPs
EMAIL_PASS Yes SMTP password or App Password
GROQ_API_KEY Yes Groq API key for Llama 3.3 AI features
FIREBASE_PROJECT_ID Optional Firebase Project ID for server-side token validation
FIREBASE_CLIENT_EMAIL Optional Firebase service account client email
FIREBASE_PRIVATE_KEY Optional Firebase service account private key

Frontend (frontend/.env)

Variable Description
VITE_API_URL Base URL of the Express backend API (e.g. http://localhost:8000)
VITE_FIREBASE_APIKEY Firebase Client Web API Key

API Surface

Category Endpoint Method Rate Limited Validation Description
Auth /api/auth/signup POST 20 / 15m Zod Schema Register new student or educator
Auth /api/auth/login POST 20 / 15m Zod Schema Authenticate user & set JWT cookie
Auth /api/auth/googlesignup POST 20 / 15m Zod Schema Verify Firebase ID token & login
Auth /api/auth/sendotp POST 20 / 15m Zod Schema Generate and email 4-digit OTP
Auth /api/auth/verifyotp POST 20 / 15m Zod Schema Verify OTP for password reset
Courses /api/course/getpublishedcourses GET General - Cached catalogue of active courses
Courses /api/course/getcourse/:id GET General - Cached detailed course information
Courses /api/course/create POST General Zod / Role Create course (educators only)
Courses /api/course/editlecture/:id POST General Multer Upload video & trigger FFmpeg transcode
Exams /api/exam/create/:courseId POST General Role Create exam with questions & timer
Exams /api/exam/:examId/start POST General Auth Initiate exam attempt session
Exams /api/exam/attempt/:id/submit POST General Auth Submit answers & auto-compute grades
Proctoring /api/proctoring/analyze-frame POST 120 / 1m Zod Schema YOLOv8 computer vision frame check
Proctoring /api/proctoring/tab-switch/:id POST General Auth Record tab switch violation
Proctoring /api/proctoring/dashboard GET General Instructor View proctoring event logs & proofs
Certification /api/certification/start-interview POST 30 / 1m Auth Start AI technical interview
Certification /api/certification/submit-answer POST 30 / 1m Auth Evaluate oral/text response with Groq
AI /api/ai/search POST 30 / 1m Zod Schema Natural language course search
AI /api/ai/summary POST 30 / 1m Zod Schema Generate lecture summary
AI /api/ai/quiz POST 30 / 1m Zod Schema Auto-generate practice quizzes

License

This project is licensed under the ISC License.