# krishnakumaragrawal/artificial-intelligence-based-online-exam-proctoring-system architecture

> Architecture diagram of the GitHub repository krishnakumaragrawal/artificial-intelligence-based-online-exam-proctoring-system, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-13). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/krishnakumaragrawal/artificial-intelligence-based-online-exam-proctoring-system
- Repository: https://github.com/krishnakumaragrawal/artificial-intelligence-based-online-exam-proctoring-system

## Overview

##### Project Type and Purpose
- This is a full-stack, AI-powered online exam proctoring system built as a monolithic Flask application in Python.
- Purpose: Monitor test-takers in real time via computer-vision and audio modules, detect suspicious behavior (face, eyes, mouth, head pose, object movements, audio anomalies), log all activity to “activity.txt,” and store summary/session data in an SQL database.

##### File Structure Analysis
- Top-level scripts (app.py, server.py, main.py, temp.py) – entry points and orchestration logic.
- backend/ – database schema (database.sql) and helper (db_helper.py).
- detection modules at root (blink_detection.py, eye_tracker.py, mouth_tracking.py, head_pose_estimation.py, facial_detections.py, object_detection.py, audio_detection.py).
- object_detection_model/ – YOLO configs, weights, labels.
- shape_predictor_model/ – Dlib’s face landmarks model.
- static/ & templates/ – frontend (HTML, CSS, JS) for the exam UI.
- activity.txt – runtime log of all detection events.

##### README Insights
- Confirms technologies: Python, OpenCV, Dlib, PyAudio, Flask, HTML/CSS/JS, SQL.
- Lists key features aligning to modules in code.

a. Main Components
- User’s Browser (UI)
- Flask Application Server
- Detection Modules (face, eyes, mouth, blink, head, audio, object)
- Machine-Learning Models (Dlib shape_predictor, YOLO configs & weights)
- Database (SQL)
- Activity Log File
- External Devices (Webcam, Microphone)
b. Relationships & Interactions
1. Browser ↔ Flask Server (HTTPS requests for login, quiz pages, real-time video/audio streams)
2. Server invokes appropriate detection module(s) per frame/audio chunk
3. Detection modules load ML models and process streams from Webcam/Microphone
4. Detection results → Server → persisted to Database & appended to activity.txt
5. Server sends alerts or flags back to UI (optional real-time feedback)
c. Architectural Patterns / Design Principles
- MVC-style: Templates (View), server routes/controllers (Controller), backend/db (Model)
- Modular design: each detection as separate Python module
- Single monolith vs microservices: monolithic for simplicity
d. Key Technologies & Frameworks
- Flask: HTTP server, routing, template rendering
- OpenCV & Dlib: image processing, facial landmarks
- YOLO (via object_detection_model): object detection
- PyAudio & Winsound: audio capture & event signaling
- SQLite/MySQL (backend/database.sql) via db_helper.py
- HTML/CSS/JS: client-side quiz interface

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Devices
    subgraph "External Devices"
        direction TB
        Webcam["Webcam"]:::device
        Microphone["Microphone"]:::device
    end

    %% Frontend Layer
    subgraph "Frontend Layer"
        direction TB
        Browser["User’s Browser (UI)"]:::frontend
        Static["Static Assets"]:::frontend
        Templates["Templates"]:::frontend
    end

    %% Backend Layer
    subgraph "Backend Layer"
        direction TB
        Server["Flask Application Server"]:::backend
        blink["Blink Detection Module"]:::aml
        eye["Eye Tracker Module"]:::aml
        mouth["Mouth Tracking Module"]:::aml
        head["Head Pose Estimation Module"]:::aml
        face["Facial Detection Module"]:::aml
        object["Object Detection Module"]:::aml
        audio["Audio Detection Module"]:::aml
    end

    %% ML Models
    subgraph "Machine-Learning Models"
        direction TB
        shape["Dlib Shape Predictor Model"]:::aml
        yolocfg["YOLO Configs"]:::aml
        yoloweights["YOLO Weights"]:::aml
        yololabels["YOLO Object Labels"]:::aml
    end

    %% Data Layer
    subgraph "Data Layer"
        direction TB
        Database["SQL Database"]:::data
        ActivityLog["Activity Log File"]:::data
    end

    %% Connections
    Webcam -->|"video frames"| Server
    Microphone -->|"audio stream"| Server
    Browser -->|"/start_exam, /submit_frame"| Server
    Server -->|calls| blink
    Server -->|calls| eye
    Server -->|calls| mouth
    Server -->|calls| head
    Server -->|calls| face
    Server -->|calls| object
    Server -->|calls| audio

    blink -->|loads model| shape
    eye -->|loads model| shape
    mouth -->|loads model| shape
    head -->|loads model| shape
    face -->|loads model| shape
    object -->|loads config/weights| yolocfg
    object -->|loads config/weights| yololabels
    object -->|loads weights| yoloweights

    blink -->|result| Server
    eye -->|result| Server
    mouth -->|result| Server
    head -->|result| Server
    face -->|result| Server
    object -->|result| Server
    audio -->|result| Server

    Server -->|"SQL INSERT"| Database
    Server -->|"append event"| ActivityLog
    Server -->|"alerts/flags"| Browser

    %% Click Events
    click Static "https://github.com/krishnakumaragrawal/artificial-intelligence-based-online-exam-proctoring-system/tree/main/static/"
    click Templates "https://github.com/krishnakumaragrawal/artificial-intelligence-based-online-exam-proctoring-system/tree/main/templates/"
    click Server "https://github.com/krishnakumaragrawal/artificial-intelligence-based-online-exam-proctoring-system/blob/main/app.py"
    click Server "https://github.com/krishnakumaragrawal/artificial-intelligence-based-online-exam-proctoring-system/blob/main/server.py"
    click Server "https://github.com/krishnakumaragrawal/artificial-intelligence-based-online-exam-proctoring-system/blob/main/main.py"
    click blink "https://github.com/krishnakumaragrawal/artificial-intelligence-based-online-exam-proctoring-system/blob/main/blink_detection.py"
    click eye "https://github.com/krishnakumaragrawal/artificial-intelligence-based-online-exam-proctoring-system/blob/main/eye_tracker.py"
    click mouth "https://github.com/krishnakumaragrawal/artificial-intelligence-based-online-exam-proctoring-system/blob/main/mouth_tracking.py"
    click head "https://github.com/krishnakumaragrawal/artificial-intelligence-based-online-exam-proctoring-system/blob/main/head_pose_estimation.py"
    click face "https://github.com/krishnakumaragrawal/artificial-intelligence-based-online-exam-proctoring-system/blob/main/facial_detections.py"
    click object "https://github.com/krishnakumaragrawal/artificial-intelligence-based-online-exam-proctoring-system/blob/main/object_detection.py"
    click audio "https://github.com/krishnakumaragrawal/artificial-intelligence-based-online-exam-proctoring-system/blob/main/audio_detection.py"
    click shape "https://github.com/krishnakumaragrawal/artificial-intelligence-based-online-exam-proctoring-system/blob/main/shape_predictor_model/shape_predictor_68_face_landmarks.dat"
    click yolocfg "https://github.com/krishnakumaragrawal/artificial-intelligence-based-online-exam-proctoring-system/blob/main/object_detection_model/config/yolov3.cfg"
    click yolocfg "https://github.com/krishnakumaragrawal/artificial-intelligence-based-online-exam-proctoring-system/blob/main/object_detection_model/config/yolov3-tiny.cfg"
    click yoloweights "https://github.com/krishnakumaragrawal/artificial-intelligence-based-online-exam-proctoring-system/blob/main/object_detection_model/weights/yolov3-tiny.weights"
    click yololabels "https://github.com/krishnakumaragrawal/artificial-intelligence-based-online-exam-proctoring-system/blob/main/object_detection_model/objectLabels/coco.names"
    click Database "https://github.com/krishnakumaragrawal/artificial-intelligence-based-online-exam-proctoring-system/blob/main/backend/database.sql"
    click Database "https://github.com/krishnakumaragrawal/artificial-intelligence-based-online-exam-proctoring-system/blob/main/backend/db_helper.py"
    click ActivityLog "https://github.com/krishnakumaragrawal/artificial-intelligence-based-online-exam-proctoring-system/blob/main/activity.txt"

    %% Styles
    classDef frontend fill:#AED6F1,stroke:#2980B9,stroke-width:1px
    classDef backend fill:#A9DFBF,stroke:#27AE60,stroke-width:1px
    classDef aml fill:#F7DC6F,stroke:#D68910,stroke-width:1px
    classDef data fill:#D5D8DC,stroke:#5D6D7E,stroke-width:1px
    classDef device fill:#EBEDEF,stroke:#85929E,stroke-width:1px
```
