A full-stack, real-time proctoring platform built for the modern academic environment. Graduation Project β Faculty of Computers & Artificial Intelligence
Watch the full system demo below:
Project-demo.mp4
If the video does not play inline, click here to download the demo.
- Overview
- Key Features
- Tech Stack
- System Architecture
- Database ERD
- Installation
- Configuration
- Running the System
- API Reference
- Project Structure
- Future Roadmap
- Team & Acknowledgements
Horas is an intelligent, real-time online exam proctoring system designed to uphold academic integrity without requiring physical invigilation. It combines a FastAPI backend, a React frontend, and a dedicated AI Engine that analyzes live webcam feeds using computer vision models to detect and log suspicious behavior during exams.
The name Horas derives from the Arabic word for "guardian" β the system acts as a silent, impartial invigilator, ensuring fair assessments regardless of geography.
- π JWT + Google OAuth2 Authentication β Secure, dual-mode login supporting both traditional credentials and Google Sign-In.
- π Role-Based Access Control β Distinct
student,teacher, andadminroles with guarded API routes. - π Full Exam Lifecycle Management β Teachers create exams with MCQ questions; students enroll and submit via access code.
- π Automatic Scoring Engine β Weighted point-per-question grading with configurable total/passing marks.
- ποΈ Real-Time AI Proctoring β Live video frames streamed over WebSocket to an AI pipeline that detects:
- Gaze deviation & head pose anomalies
- Foreign object detection via YOLO (phones, books)
- Behavioral anomaly detection (IForest / LSTM)
- π¦ AI Readiness Gate β Exam submission is blocked until the AI engine confirms it is calibrated and ready.
- π PDF Proctoring Reports β Auto-generated after each session with a full event log; securely downloadable by teacher or student.
- π‘ Structured Event Logging β Every AI anomaly is persisted to the DB with timestamp, category, description, and evidence screenshot path.
| Layer | Technology |
|---|---|
| Backend Framework | FastAPI (Python 3.10+) |
| Frontend | React 18 |
| AI / ML Engine | PyTorch, MediaPipe, Ultralytics YOLO, DeepFace / ArcFace |
| Anomaly Detection | Isolation Forest, LSTM (custom-trained) |
| Database ORM | SQLAlchemy + SQLite (dev) / PostgreSQL (prod-ready) |
| Data Validation | Pydantic v2 |
| Authentication | JWT (python-jose), Google OAuth2 (Authlib) |
| Real-Time Transport | WebSockets (FastAPI native) |
| Report Generation | ReportLab (PDF) |
| Dev Tools | Uvicorn, python-dotenv |
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Horas AI Proctoring Platform β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β
β βββββββββββββββββββ ββββββββββββββββββββββββ β
β β Student UI β β Teacher UI β β
β β (React) β β (React) β β
β ββββββββββ¬βββββββββ ββββββββββββ¬ββββββββββββ β
β β REST + WebSocket REST β β
β βββββββββββββββββ¬βββββββββββββββββββ β
β β β
β ββββββββββββββββββΌββββββββββββββββββββββ β
β β FastAPI Backend β β
β β βββββββββββββββββββββββββββββββββ β β
β β β Routers (auth/exam/session/ β β β
β β β questions/events/users/ws) β β β
β β ββββββββββββββββ¬βββββββββββββββββ β β
β β β β β
β β ββββββββββββββββΌββββββββββββββββ β β
β β β Services Layer β β β
β β β β’ ProctoringManager β β β
β β β β’ ScoringEngine β β β
β β β β’ ReportGenerator β β β
β β ββββββββββββββββ¬ββββββββββββββββ β β
β β β β β
β β ββββββββββββββββΌββββββββββββββββ β β
β β β SQLAlchemy ORM β SQLite/PG β β β
β β ββββββββββββββββββββββββββββββββ β β
β ββββββββββββββββββββββββββββββββββββββββ β
β β WebSocket frames β
β ββββββββββββββββββΌββββββββββββββββββββββ β
β β AI Engine (Python) β β
β β ββββββββββββββββββββββββββββββββ β β
β β β β’ Head Pose Estimation β β β
β β β β’ Gaze Tracking β β β
β β β β’ YOLO Object Detection β β β
β β β β’ Anomaly Detection β β β
β β β (IForest / LSTM) β β β
β β ββββββββββββββββββββββββββββββββ β β
β β Logs events β POST /api/events/log β β
β ββββββββββββββββββββββββββββββββββββββββ β
β β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β Mobile App (Flutter) β Planned / Future β β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββ β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Reverse-engineered directly from the SQLAlchemy models.
| Relationship | Cardinality | Cascade |
|---|---|---|
| User β Exams | One-to-Many (teacher creates exams) | β |
| User β Sessions | One-to-Many (student takes exams) | β |
| Exam β Questions | One-to-Many | delete-orphan |
| Exam β Sessions | One-to-Many | delete-orphan |
| Session β Events | One-to-Many | delete-orphan |
- Python 3.10+
- Node.js 18+ & npm
- Git
- Download only the
project_setup.batscript and place it where you want to install the project. - Right-click
project_setup.batβ Run as Administrator. - The script will automatically:
- Create a Python virtual environment
- Install all backend dependencies (
requirements.txt) - Install all frontend dependencies (
npm install) - Verify GPU availability for the AI engine
Caution
Dependencies must be installed in the exact order below to prevent binary conflicts between PyTorch, MediaPipe, and Whisper.
Step 1: Clone the repository
git clone https://github.com/Ali-Islam111/Horas-Demo.git
cd "Horas"Step 2: Create and activate a virtual environment
# Windows (use the Python Launcher to pin the exact version)
py -3.10 -m venv venv
venv\Scripts\activate
# Linux / macOS
python3 -3.10 -m venv venv
source venv/bin/activateStep 3 β Install GPU-Accelerated PyTorch
Install the CUDA 12.1 PyTorch wheels first. This ensures YOLO and DeepFace utilize the GPU instead of defaulting to slower CPU binaries.
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121Step 4 β Prevent Audio Library Conflicts
faster-whisper will break if ctranslate2 is not installed first. Lock in the correct binaries before proceeding.
pip install ctranslate2>=4.0.0Step 5 β Install Remaining Dependencies
Once the core ML binaries are locked in, install the rest of the web server and AI dependencies.
# Run from the repository root:
pip install -r backend/requirements.txtStep 6 β Install frontend dependencies
cd frontend
npm install
cd ..Create a .env file in the backend/ directory. Use the template below:
# βββ Application βββββββββββββββββββββββββββββββββββββββββββββ
SECRET_KEY=your-super-secret-jwt-key-change-this-in-production
ALGORITHM=HS256
ACCESS_TOKEN_EXPIRE_MINUTES=60
# βββ Database ββββββββββββββββββββββββββββββββββββββββββββββββ
# SQLite (default for local dev):
DATABASE_URL=sqlite:///./horas.db
# PostgreSQL (production-ready alternative):
# DATABASE_URL=postgresql://user:password@localhost:5432/horas_db
# βββ Google OAuth2 βββββββββββββββββββββββββββββββββββββββββββ
GOOGLE_CLIENT_ID=your-google-client-id.apps.googleusercontent.com
GOOGLE_CLIENT_SECRET=your-google-client-secret
GOOGLE_REDIRECT_URI=http://localhost:8000/auth/google/callback
# βββ Frontend ββββββββββββββββββββββββββββββββββββββββββββββββ
FRONTEND_URL=http://localhost:3000Note: Never commit your
.envfile. It is already listed in.gitignore.
- Place
server_startup.batin the project root directory (same level asbackend/andfrontend/). - Right-click β Run as Administrator.
The script will launch the FastAPI backend, wait for it to become healthy, then start the React frontend and open your browser automatically.
Terminal 1 β Backend API Server:
cd backend
python main.pyTerminal 2 β Frontend Dev Server:
cd frontend
npm run dev| Service | URL |
|---|---|
| Backend API | http://localhost:8000 |
| Interactive API Docs (Swagger) | http://localhost:8000/docs |
| Alternative API Docs (ReDoc) | http://localhost:8000/redoc |
| Frontend App | http://localhost:3000 |
All REST endpoints are prefixed with /api (e.g. http://localhost:8000/api/auth/login). The WebSocket endpoint is served at the root level without this prefix.
| Method | Route | Auth Required | Role | Description |
|---|---|---|---|---|
POST |
/auth/register |
β | Any | Register a new user account |
POST |
/auth/login |
β | Any | Login; returns a JWT Bearer token |
GET |
/auth/google |
β | Any | Redirect to Google OAuth2 login page |
GET |
/auth/google/callback |
β | Any | Google OAuth2 callback; issues JWT & redirects to frontend |
| Method | Route | Auth Required | Role | Description |
|---|---|---|---|---|
GET |
/users/ |
β | Any | Get all registered users |
GET |
/users/me |
β | Any | Get the currently authenticated user's profile |
GET |
/users/{user_id} |
β | Any | Get a specific user by ID |
| Method | Route | Auth Required | Role | Description |
|---|---|---|---|---|
POST |
/exams/ |
β | Teacher | Create a new exam (with questions in one batch) |
GET |
/exams/my-exams |
β | Teacher | Get all exams created by the authenticated teacher |
GET |
/exams/ |
β | Any | Get a list of all available exams |
GET |
/exams/{exam_id} |
β | Any | Get a specific exam's full metadata |
DELETE |
/exams/{exam_id} |
β | Teacher | Delete an exam (owner only; cascades to sessions & questions) |
| Method | Route | Auth Required | Role | Description |
|---|---|---|---|---|
POST |
/questions/{exam_id} |
β | Teacher | Add a single question to an existing exam |
GET |
/questions/{exam_id} |
β | Any | Get all questions; teachers see correct_choice, students do not |
| Method | Route | Auth Required | Role | Description |
|---|---|---|---|---|
POST |
/sessions/enroll/{exam_id} |
β | Student | Enroll in an exam; creates (or returns existing) session |
POST |
/sessions/{session_id}/submit |
β | Student | Submit answers; triggers scoring; blocked if AI not ready |
GET |
/sessions/my-submissions |
β | Student | Get all of the student's own exam sessions |
GET |
/sessions/all-submissions |
β | Teacher | Get all student sessions for the teacher's exams |
GET |
/sessions/{session_id}/events |
β | Teacher | Get all proctoring event logs for a specific session |
GET |
/sessions/{session_id}/ai-status |
β | Any | Poll AI readiness status (waiting/initializing/ready/failed) |
GET |
/sessions/my-reports |
β | Student | Get all sessions with a generated proctoring PDF report |
GET |
/sessions/{session_id}/report |
β | Teacher/Student | Stream-download the proctoring PDF for a session |
GET |
/sessions/reports/student/{user_id} |
β | Teacher | Get all reports for a specific student (teacher's exams only) |
| Method | Route | Auth Required | Role | Description |
|---|---|---|---|---|
POST |
/events/log |
β* | AI Engine | Internal: AI engine POSTs a detected anomaly event to persist it |
*The
/events/logendpoint is called internally by the AI Engine process running server-side and does not require a user JWT in the current implementation.
Note
The WebSocket router is registered without the /api prefix. Connect to ws://localhost:8000/ws/sessions/{session_id} directly.
| Protocol | Route | Description |
|---|---|---|
WS |
ws://localhost:8000/ws/sessions/{session_id} |
Bi-directional: frontend streams raw video frames β AI engine processes and returns real-time alerts |
Horas Demo V1.0/
β
βββ backend/
β βββ main.py # FastAPI app entrypoint β registers all routers,
β β # CORS, SessionMiddleware, and DB creation
β βββ requirements.txt # Python dependency list (pip freeze)
β βββ yolo11n.pt # YOLOv11-nano weights file (object detection)
β βββ database_seeder.py # One-off script to populate DB with test data
β β
β βββ core/
β β βββ config.py # Pydantic Settings β loads all .env variables
β β βββ database.py # SQLAlchemy engine, SessionLocal, create_tables()
β β βββ security.py # bcrypt hashing, JWT create/verify
β β βββ dependencies.py # FastAPI Depends guards: get_current_user/teacher/student
β β βββ crud/ # All DB query helpers (users, exams, sessions, questions)
β β βββ user.py
β β βββ exam.py
β β βββ questions.py
β β βββ session.py
β β
β βββ models/ # SQLAlchemy ORM β defines the actual DB tables
β β βββ user.py # users table
β β βββ exam.py # exams table (FK β users)
β β βββ questions.py # questions table (FK β exams, stores choices as JSON)
β β βββ session.py # sessions table (FK β users + exams, stores answers as JSON)
β β βββ events.py # events table (FK β sessions, AI anomaly log)
β β
β βββ schemas/ # Pydantic v2 β request/response validation shapes
β β βββ auth.py # UserCreate, UserResponse, Token, TokenData
β β βββ exam.py # ExamCreate, ExamCreateBatch, ExamResponse
β β βββ questions.py # QuestionCreate, QuestionResponse, QuestionTeacherResponse
β β βββ session.py # SessionCreate/Response, StudentAnswerSubmit,
β β β SubmissionResult, AIStatusResponse, ReportListItem
β β βββ events.py # EventCreate, EventOut
β β
β βββ routers/ # FastAPI route handler files (one per domain)
β β βββ auth.py # POST /auth/register, /auth/login, GET /auth/google*
β β βββ users.py # GET /users/, /users/me, /users/{id}
β β βββ exam.py # CRUD for /exams/ (teacher-gated creates/deletes)
β β βββ questions.py # POST/GET /questions/{exam_id}
β β βββ session.py # Full session lifecycle: enroll β submit β reports
β β βββ events.py # POST /events/log (internal AI β DB bridge)
β β βββ streaming.py # WS /ws/sessions/{id} (live video frame pipeline)
β β
β βββ services/
β β βββ proctoring_manager.py # WebSocket connection registry; routes frames to
β β β ProctoringSession; tracks per-session AI status
β β βββ exam_scoring.py # ScoringEngine.calculate_score() β weighted MCQ grading
β β
β βββ AI_engine/ # Self-contained CV/ML proctoring pipeline
β βββ config.py # All AI tunables: thresholds, paths, model settings
β βββ core.py # AlertHook, AttentionScore, play_alert() β shared primitives
β βββ main.py # run() β top-level proctoring loop; draws HUD on frames
β βββ proctoring_session.py # ProctoringSession β per-student thread; starts/stops detectors
β βββ offline_trainer.py # CLI tool: trains IForest & LSTM on collected datasets
β βββ yolo11n.pt # YOLO weights copy inside AI_engine
β β
β βββ detectors/ # One file per detection modality
β β βββ head_pose.py # HeadPoseDetector β MediaPipe + solvePnP yaw/pitch/roll
β β βββ face_signals.py # GazeDetector, LipMovementDetector, GlowDetector, BlinkDetector
β β βββ object_detector.py # ObjectDetector β async YOLO inference on background thread
β β βββ anomaly.py # IForestDetector, LSTMAutoencoder β unsupervised anomaly scoring
β β βββ audio.py # MicMonitor β volume, faster-whisper transcription, YAMNet events
β β βββ identity.py # IdentityVerifier β ArcFace face enrollment + frame verification
β β βββ dataset_collector.py # DatasetCollector β snapshots frames + metadata to disk for retraining
β β βββ llm_verifier.py # Gemini API vision fallback for ambiguous cheating frames
β β βββ one_euro_filter.py # 1β¬ smoothing filter for noisy landmark coordinates
β β
β βββ reports/
β β βββ pdf_report.py # generate() β full PDF evidence report with sparklines & snapshots
β β
β βββ evidence/ # Runtime: AI stores screenshot evidence here
β βββ session_reports/ # Runtime: generated PDF reports stored here
β βββ saved_models/ # Runtime: persisted IForest & LSTM model files
β βββ dataset/ # Runtime: DatasetCollector frame snapshots per category
β βββ reference_faces/ # Runtime: ArcFace enrollment embeddings per student
β
βββ frontend/ # React 18 + Vite web application
β βββ index.html # Vite HTML entry point
β βββ vite.config.js # Vite config (proxy, plugins)
β βββ package.json # npm dependencies & scripts
β βββ eslint.config.js # ESLint rules
β β
β βββ src/
β βββ main.jsx # React DOM root mount
β βββ App.jsx # Top-level router β maps URL query params to page components
β βββ App.css / index.css # Global styles & CSS variables
β β
β βββ components/ # Page-level React components (one file = one screen/page)
β β βββ LandingPage.jsx # Public home page β hero, features, CTA
β β βββ Login.jsx # Login form with role selector (student / teacher)
β β βββ CreateAccount.jsx # Registration form with validation
β β βββ GoogleCallback.jsx # Handles /auth/callback redirect from Google OAuth
β β βββ CookieBanner.jsx # GDPR cookie consent banner
β β β
β β βββ StudentDashboard.jsx # Student home β exam list, enroll, history
β β βββ StudentExam.jsx # Exam-taking UI β timer, question nav, webcam feed
β β βββ AIInitializingScreen.jsx # Blocks exam start; polls AI readiness status
β β βββ ExamSubmission.jsx # Post-submit score screen with pass/fail feedback
β β β
β β βββ ExaminerDashboard.jsx # Teacher home β stats overview, exam list
β β βββ ExamCreation.jsx # Multi-step exam builder with question editor
β β βββ ExaminerExam.jsx # Teacher exam detail view β metadata, questions
β β βββ ExaminerStudents.jsx # Student submission table for a teacher's exam
β β βββ ExaminerAlerts.jsx # Proctoring event log viewer per session
β β βββ ExaminerSettings.jsx # Teacher account & platform settings
β β β
β β βββ ProctoringMonitor.jsx # Live WebSocket status dashboard during exam
β β βββ ExamReportScreen.jsx # Full PDF-style report viewer with evidence timeline
β β
β βββ controllers/ # Custom hooks β business logic decoupled from UI
β β βββ useAuthController.js # Login/register state, role switching
β β βββ useExamController.js # Exam CRUD, enroll, answer, submit, submissions
β β
β βββ hooks/
β β βββ useExamCreation.js # Multi-step exam creation form state machine
β β
β βββ services/ # Raw API call wrappers (fetch/axios)
β β βββ authService.js # login(), register(), getProfile(), setSession()
β β βββ examService.js # CRUD for exams + questions; parseExamFile() via AI
β β βββ sessionService.js # enrollExam(), submitExam(), getMySubmissions(), getAIStatus()
β β βββ proctoringService.js # WebSocket client: connectProctoringWS(), sendFrame(), close()
β β βββ geminiService.js # Client-side Gemini API integration for exam file parsing
β β
β βββ contexts/
β β βββ LanguageContext.jsx # i18n context provider; useLanguage() hook
β β
β βββ i18n/
β β βββ translations.js # AR/EN translation strings (~58 KB, full bilingual UI)
β β
β βββ utils/
β βββ routeMapping.js # URL β page name mapping helpers
β
βββ frontend/mobile app/ # Flutter mobile app (Android, iOS, Web)
β βββ pubspec.yaml # Flutter dependency manifest
β βββ lib/
β βββ main.dart # App entry point, MaterialApp root
β βββ models/models.dart # JSON-serializable data models (User, Exam, etc.)
β βββ services/api_service.dart # Singleton HTTP client β wraps all backend API calls
β βββ screens/ # One file per screen
β βββ login_screen.dart
β βββ create_account_screen.dart
β βββ student_dashboard_screen.dart
β βββ student_exam_screen.dart
β βββ examiner_dashboard_screen.dart
β βββ exam_creation_screen.dart
β βββ proctoring_monitor_screen.dart
β
βββ docs/
β βββ COMPLETE-FUNCTIONS-LIST.md # Granular breakdown of all 200+ internal functions
β βββ Exam Session Interaction.png # Database ERD diagram
β βββ Project-demo.mp4 # Full system demonstration video
β βββ Graduuation Project Report- 2026.docx
β
βββ project_setup.bat # One-click Windows installer (clones, venv, deps)
βββ server_startup.bat # Launches backend + frontend + opens browser
βββ Exam_Monitor_Postman_Collection.json # Ready-to-import Postman test suite
βββ README.md
π For a granular breakdown of all 200+ internal functions across every module, see COMPLETE-FUNCTIONS-LIST.md.
- Mobile App β Develop a Flutter-based cross-platform client (Android/iOS) to extend exam access beyond web browsers.
- Dockerization β Containerize the FastAPI backend, AI Engine, and React frontend into a single
docker-composestack for zero-friction deployment. - PostgreSQL Migration β Transition from the local SQLite database to a managed PostgreSQL instance for production scalability and concurrent write support.
- Admin Dashboard β A dedicated admin panel for user management, platform-wide analytics, and system health monitoring.
- Live Alerts to Teacher β Push real-time proctoring alerts to the teacher's dashboard via a second WebSocket channel.
- Question Bank β Allow teachers to maintain a reusable pool of questions across multiple exams.
This project was developed as a graduation project.
| Name | Role | GitHub | |
|---|---|---|---|
| Ibrahim Mohammed Al-Batrawshy | Team Lead & Frontend Developer | IbrahimAlBatrawshy | Ibrahim Al-Batrawshy |
| Ali Islam Taha | Backend Lead | Ali-Islam111 | Ali Islam |
| Mohammed Emad Mohammed | Backend Developer | mohamedemad6244 | β |
| Saif El-Dien El-Saied Mohammed | AI Engineer | saifs22 | Saif El Dien El Saied |
| Karim Abdel-Hakim Amer | AI Engineer | Karim-Abdel-Hakim-Amer | Karim Abd-Elhakim |
| Amr Bakr | Data Scientist | AmrBakr12 | Amr Bakr |
| Moamen Hekal | DevOps Engineer | MoamenHekal | Moamen Hekal |
We would like to thank our academic supervisor: Dr.Mahmoud Mounir Mahmoud for his guidance throughout the project.
Made with β€οΈ for the love of clean architecture and academic integrity.
