Guard-AI-Designing-Remote-Proctoring-System

πŸŽ‰ Transforming Remote Assessments with AI!!! πŸŽ‰

AI-Based Proctoring System for Secure Assessments πŸ”’

Python FastAPI License PRs Welcome Social Winter of Code Contributors

An open-source initiative to transform remote assessment integrity using cutting-edge AI technology.

🌟 Features βš™οΈ Installation πŸ—οΈ Architecture πŸš€ Usage 🀝 Contributing πŸ‘₯ Community


Project Banner


Contributing Guide

Please refer to our CONTRIBUTING.md for contribution guidelines.


πŸ“„ Provide Your Feedback or Participate

We value your feedback! Please take a moment to fill out the Google Form and contribute to improving our project.

πŸ“‹ Google Form - Participate Now!


<tr border: 1px;> </tr>
🌟 Stars 🍴 Forks πŸ› Issues πŸ”” Open PRs πŸ”• Close PRs
Stars Forks Issues Open Pull Requests Close Pull Requests

</div>

🌟 Overview

This project introduces a cutting-edge AI-powered proctoring system designed to maintain fairness, security, and integrity in remote assessments. By leveraging advanced machine learning techniques, this system redefines how online tests are monitored.

ssoc Social Winter Of Code Social Winter of Code is an initiative to introduce students to the open-source world, fostering collaboration and development.
dwoc Delta Winter Of Code Delta Winter of Code empowers students by providing opportunities to contribute to meaningful open-source projects and grow their skills.
jgec JWOC Winter of Code JWoC provides a fully immersive learning experience for students and first-time contributors by promoting the wonders of open-source software and crafting a community of new and experienced technical developers. The best projects are selected for this program. Students get acquainted with the projects from the mentors during the Community Bonding Period. Students work on these projects during the coding phase. At the end of the coding period, the winners of the programs are announced on the basis of their contribution in terms of quantity as well as quality.

πŸ“Ί Project Demo

Watch our community demo:

πŸŽ₯ Watch Demo


🌟 Features

For teachers / proctors

For students

Server-side AI proctoring β€” the browser only uploads a compressed frame every ~1.5 s; all analysis runs on the API server:

Signal Model / method
Face count, no face, multiple people YuNet face detector (OpenCV, MIT) + YOLOX person class
Prolonged looking away, frequent head movement MediaPipe Face Landmarker head pose vs. the candidate’s calibrated neutral pose (port of the original anomaly_detection.py rules)
Eyes off screen, talking Face Landmarker gaze & jaw blendshapes + browser audio level
Phone, book/notes, extra laptop YOLOX-Tiny object detector (ONNX, Apache-2.0)
Identity verification & mid-exam swap SFace face embeddings (OpenCV, Apache-2.0), cosine match against the teacher-uploaded photo
Camera covered Frame brightness
Tab switch, window blur, fullscreen exit, copy/paste, extra monitor Browser events

All models are permissively licensed (no AGPL), CPU-only, ~65 MB total, ~100–130 ms per frame. Object detection runs on every 2nd frame and identity on every 8th, so a single vCPU handles roughly 8–12 concurrent candidates; the server tells browsers to slow down automatically when frames queue up.

πŸ—οΈ Architecture & Design

 Student browser ── JPEG frame + audio level every ~1.5 s ──┐        β”Œβ”€β”€ Teacher browser (live grid polls 3 s)
                                                            β–Ό        β–Ό
                     Next.js 14 on Vercel  (Clerk auth, UI only)
                                     β”‚  Bearer <Clerk session JWT>
                                     β–Ό
       FastAPI on Render ─ verifies JWT (Clerk JWKS), Clerk Backend API for student accounts
        β”œβ”€ AI runtime: YuNet Β· Face Landmarker Β· SFace Β· YOLOX-Tiny (bounded worker pool, back-pressure)
        β”œβ”€ Per-attempt anomaly tracker + in-memory live cache (thumbnails never hit the DB)
        └─ Alembic-migrated schema
              β”‚                                   β”‚
              β–Ό                                   β–Ό
     Supabase Postgres (RLS on)        Supabase Storage (private bucket: evidence + reference photos,
                                                          served via short-lived signed URLs)

Design notes:

πŸ”§ Technology Stack

Layer Tech Free hosting
Frontend Next.js 14 (App Router), Tailwind, shadcn/ui, Recharts Vercel Hobby
Auth Clerk (sessions + Backend API for student accounts) Clerk free tier
Backend FastAPI, SQLAlchemy 2 (async), Alembic, PyJWT, httpx Render
AI OpenCV (YuNet, SFace), MediaPipe Tasks, ONNX Runtime (YOLOX) Render (CPU)
Database PostgreSQL Supabase free tier
Storage Supabase Storage Supabase free tier (1 GB)
CI GitHub Actions β€” ruff, pytest, Docker smoke test, Next.js lint/typecheck/build free for public repos

βš™οΈ Development Setup

Prerequisites: Node 18+ with pnpm, Python 3.12+, a free Clerk application with Email address + Password sign-in enabled.

1. Backend

cd backend
python -m venv .venv
.venv/Scripts/activate                          # macOS/Linux: source .venv/bin/activate
pip install -r requirements-dev.txt
pip install --no-deps -r requirements-mediapipe.txt
python scripts/download_models.py               # ~65 MB of model weights into backend/models/
cp .env.example .env                            # set CLERK_ISSUER and CLERK_SECRET_KEY
uvicorn app.main:app --reload --port 8000 --env-file .env

Migrations run automatically on startup (SQLite file guardai_dev.db locally). Tests: pytest -q.

2. Frontend

cd main-web-vecel
pnpm install
cp .env.example .env.local                      # Clerk keys + NEXT_PUBLIC_API_URL=http://localhost:8000
pnpm dev                                        # http://localhost:3000

Sign up, choose β€œI conduct exams”, add a student under Students (copy the generated password), upload their photo, create a batch, build an exam assigned to it and publish. Sign in as the student in a private window.

☁️ Free Deployment Guide

Piece Free service Holds
Database Neon Postgres users, exams, attempts, violations
Files Backblaze B2 (or any S3-compatible store, e.g. Cloudflare R2) evidence snapshots, reference photos
API + AI models Render free web service (Docker) FastAPI, vision models, live state
Web app Vercel Next.js frontend
Auth Clerk sign-in, student accounts, invites
Assistant Groq teacher chat assistant (optional)

1. Neon (database). Create a project. Connect β†’ copy the pooled connection string (host contains -pooler) β†’ DATABASE_URL. Pick AWS ap-southeast-1 (Singapore) to sit next to the Render service. The ?sslmode=require suffix is handled; migrations run automatically when the API starts.

2. Backblaze B2 (files, 10 GB free, no card). Buckets β†’ Create a Bucket guardai-evidence, Private; note its Endpoint (e.g. s3.us-west-004.backblazeb2.com, region us-west-004). Application Keys β†’ Add a New Application Key with Read and Write on that bucket β†’ S3_ACCESS_KEY_ID (keyID) and S3_SECRET_ACCESS_KEY (applicationKey). Evidence is served to proctors through short-lived signed links; the bucket never needs to be public. Any S3-compatible store works the same way (Cloudflare R2: endpoint https://<account>.r2.cloudflarestorage.com, region auto).

3. Clerk (auth). Enable Email address and Password sign-in. Copy the publishable and secret keys; API keys β†’ Frontend API URL β†’ CLERK_ISSUER. A development instance works on *.vercel.app; a production instance needs your own domain.

4. Render (API + AI). New β†’ Blueprint β†’ this repo. Render reads render.yaml: a free Docker web service built from backend/Dockerfile (models baked in, health check /health, region Singapore). It asks for the secrets: DATABASE_URL, S3_ENDPOINT, S3_REGION, S3_BUCKET, S3_ACCESS_KEY_ID, S3_SECRET_ACCESS_KEY, CLERK_ISSUER, CLERK_SECRET_KEY, GROQ_API_KEY, and CORS_ORIGINS / FRONTEND_URL = your Vercel URL. Keep one instance (the AI runtime and live view are in-process). Free services sleep after 15 minutes idle and take about a minute to wake, so open the app a few minutes before an exam starts.

5. Vercel (web). Import the repo with Root Directory main-web-vecel; set the variables from main-web-vecel/.env.example, with NEXT_PUBLIC_API_URL=https://<your-api>.onrender.com (no trailing slash).

Optional: TURN relay for live video. Live video connects peer to peer using public STUN servers, which works on most networks. Very strict networks (some campus/office Wi-Fi, some mobile carriers) need a relay: create a free TURN key in Cloudflare’s dashboard (Realtime β†’ TURN) and set CLOUDFLARE_TURN_KEY_ID + CLOUDFLARE_TURN_API_TOKEN on Render.

Optional: branded invitation emails. Brevo is free for 300 emails/day and needs no domain: add and verify your own address under Senders, create an API key, then set BREVO_API_KEY and EMAIL_FROM="Guard AI <you@gmail.com>" on Render. (Resend also works with RESEND_API_KEY if you own a domain.) Without either, Clerk sends its plain invitation email. Render’s free plan blocks SMTP, so Gmail SMTP isn’t an option.

Capacity on free tiers. All models together use ~185 MB RAM, well inside 512 MB. CPU is the limit: Render’s free instance has 0.1 CPU, so a frame takes ~1.5–2 s and the server automatically thins out object detection (every 3rd–4th frame plus any frame with a suspicious cue such as eyes or head down) and asks browsers to send frames less often. Expect phones flagged in ~3–6 s with 1–3 simultaneous candidates: right for a demo or a small class. On 1 full vCPU (e.g. Render Starter) the same code flags phones in ~1–1.5 s with ~5 candidates, ~8–11 under load.

πŸ“ Project Structure

β”œβ”€β”€ backend/                          FastAPI service (Render)
β”‚   β”œβ”€β”€ app/
β”‚   β”‚   β”œβ”€β”€ main.py                   app factory, lifespan (migrations, bucket, model loading), middleware
β”‚   β”‚   β”œβ”€β”€ api/                      routers: me, exams, monitor, students, candidate
β”‚   β”‚   β”œβ”€β”€ ml/                       detector.py (YuNet, Face Landmarker, SFace, YOLOX), tracker.py (rules),
β”‚   β”‚   β”‚                             runtime.py (worker pool, back-pressure, live cache)
β”‚   β”‚   β”œβ”€β”€ services/                 exams (grading, timing, serializers), analytics, storage
β”‚   β”‚   β”œβ”€β”€ core/                     config, db, security (Clerk JWT), clerk (Backend API client)
β”‚   β”‚   β”œβ”€β”€ models.py Β· schemas.py
β”‚   β”œβ”€β”€ alembic/                      migrations (0001 schema, 0002 RLS)
β”‚   β”œβ”€β”€ scripts/download_models.py
β”‚   β”œβ”€β”€ tests/                        API flow, frame pipeline, anomaly rules
β”‚   └── Dockerfile (render.yaml at the repo root)
β”œβ”€β”€ main-web-vecel/                   Next.js frontend (Vercel)
β”‚   β”œβ”€β”€ app/
β”‚   β”‚   β”œβ”€β”€ page.tsx                  landing page
β”‚   β”‚   β”œβ”€β”€ (root)/proctor/           overview, exams (builder, live monitor, analytics), students & batches, attempt review
β”‚   β”‚   β”œβ”€β”€ (root)/candidate/         home (assigned exams, access code), results
β”‚   β”‚   └── exam/[attemptId]/         system check β†’ identity β†’ calibration β†’ proctored exam
β”‚   β”œβ”€β”€ components/app/               design-system kit, app shell, charts
β”‚   └── lib/                          API client, types
└── .github/workflows/ci.yml

πŸš€ Usage

  1. Teacher: Students β†’ Add student (or Import CSV) β†’ upload a reference photo β†’ Batches β†’ New batch.
  2. Teacher: Exams β†’ New exam β†’ assign the batch β†’ Publish.
  3. Student: sign in β†’ the exam is on the home screen β†’ camera check β†’ identity β†’ calibration β†’ exam β†’ submit.
  4. Teacher: Live tab while it runs; Results and Analytics afterwards; open any attempt for evidence and grading.

🀝 Contributing

We warmly welcome contributions from developers of all skill levels! Here’s how you can help:

graph TD
    A[Fork Repository] --> B[Create Branch]
    B --> C[Make Changes]
    C --> D[Commit Changes]
    D --> E[Push to Branch]
    E --> F[Create Pull Request]

🎯 Good First Issues

πŸ‘₯ Community

🌟 Contributors

Thanks to these wonderful people:

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ™ Acknowledgments


Made with ❀️ by the Guard AI Community [⬆ Back to Top](#ai-based-proctoring-system-for-secure-assessments-)