# vardanagarwal/proctoring-ai architecture

> Architecture diagram of the GitHub repository vardanagarwal/proctoring-ai, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-31). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/vardanagarwal/proctoring-ai
- Repository: https://github.com/vardanagarwal/proctoring-ai

## Overview

##### Project Type and Purpose
- The project is an automated proctoring system designed to monitor exam-takers through both the webcam (vision) and microphone (audio).
- Vision functionalities include eye tracking, mouth opening detection, face detection and landmarks, head pose estimation, person and mobile phone detection, as well as face spoofing.
- The audio module records speech via the microphone, converts it to text (using Google’s speech recognition API), and then applies NLP (using NLTK) to compare with an exam script.
- The README clearly emphasizes both vision and audio pipelines along with usage instructions, prerequisites, and performance metrics (FPS).

##### File Structure
- Notice file-level separation: There are standalone scripts (e.g., main.py, audio_part.py) and directories such as face_detection, eye_tracking, and models.
- The “face_detection” directory contains various detection models (dlib, dnn, haar, mtcnn, etc.), indicating that different approaches for face detection are available.
- The “eye_tracking” folder contains a separate README, CSV or video files for testing, and sample outputs.
- The “coco models” folder contains TensorFlow Lite models for detection (used for person and mobile phone detection).
- There are dedicated scripts for head pose estimation, face spoofing, and mouth opening detection, hinting that each functionality has been decoupled into a separate module.
- Configuration files are provided (such as requirements.txt) to set up the environment.

##### Main Components of the System
a. Input Devices:
- Webcam (providing video stream)
- Microphone (providing audio stream)
b. Vision Pipeline:
- Face Detection Module (e.g., face_detector.py and models in face_detection and models directories)
- Eye Tracking Module (e.g., eye_tracker.py inside eye_tracking directory)
- Facial Landmarks Detection (implemented in face_landmarks.py)
- Mouth Opening Detection (mouth_opening_detector.py)
- Head Pose Estimation (head_pose_estimation.py)
- Person Counting & Mobile Phone Detection (person_and_phone.py using models like YOLOv3 and TFLite models)
- Face Spoofing Detection (face_spoofing.py)
c. Audio Pipeline:
- Audio Capture and Speech-to-Text Service (handled in audio_part.py using libraries like pyaudio and speech_recognition)
- Text Processing and Comparison (using NLTK to process and compare exam content)
d. Integration & Coordination:
- The main entry point (main.py) which likely coordinates data intake and bridges between the vision and audio components.

##### Relationships and Data Flows
- Input from the webcam is sent to multiple parallel vision modules:
– A face detection module that feeds the face landmarks detection, eye tracking, and head pose modules.
– Other vision modules operate on the same video feed to detect mouth opening or count persons/mobile devices.
- Audio input is streamed to the speech recognition module, which outputs text that gets processed by NLP functions to compare with an exam script.
- There is potential integration in the main control script (main.py) that aggregates outputs from the different modules and possibly logs or reports the candidate’s status.

##### Architectural Patterns and Design Principles
- Modular Design: Each functionality (e.g., eye tracking, face detection, audio transcription) is implemented in its own module—which makes the system easier to maintain, test, and extend.
- Separation of Concerns: Clear division between vision and audio pipelines ensures that changes in one part won’t affect the other.
- Extensibility: With directories for different models (various face detection approaches) and clear "to do" items, the design allows easy replacement or enhancements.
- Parallel Processing: Consideration is given to using multithreading (as noted in the audio component) so that the recording thread does not block continuous processing.

##### Final Recommendations
- Modularity, clarity of data flow, and the separation between vision and audio pipelines.
- The main driver (main.py) should be highlighted to show integration.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Input Devices
    W["Webcam (Video Input)"]:::input
    M["Microphone (Audio Input)"]:::input

    %% Vision Pipeline Subgraph
    subgraph "Vision Pipeline"
        FD["Face Detection"]:::vision
        EL["Facial Landmarks Detection"]:::vision
        ET["Eye Tracking"]:::vision
        HO["Mouth Opening Detection"]:::vision
        HP["Head Pose Estimation"]:::vision
        PM["Person & Mobile Detection"]:::vision
        FS["Face Spoofing Detection"]:::vision
    end

    %% Audio Pipeline Subgraph
    subgraph "Audio Pipeline"
        AC["Audio Capture & Speech-to-Text"]:::audio
        TP["Text Processing (NLP)"]:::audio
    end

    %% Integration / Coordination
    IN["Main Coordinator"]:::integration

    %% Data Flows from Inputs to Pipelines
    W -->|"video"| FD
    W -->|"video"| HO
    W -->|"video"| PM
    W -->|"video"| FS

    M -->|"audio"| AC

    %% Vision Pipeline internal relations
    FD -->|"feeds"| EL
    FD -->|"feeds"| ET
    FD -->|"feeds"| HP

    %% Audio Pipeline internal relation
    AC -->|"transcribes"| TP

    %% Modules converging to Coordinator
    FD -->|"output"| IN
    EL -->|"output"| IN
    ET -->|"output"| IN
    HO -->|"output"| IN
    HP -->|"output"| IN
    PM -->|"output"| IN
    FS -->|"output"| IN
    TP -->|"output"| IN

    %% Click Events for Component Mapping
    click FD "https://github.com/vardanagarwal/proctoring-ai/blob/master/face_detection/faces_detection.py"
    click FD "https://github.com/vardanagarwal/proctoring-ai/blob/master/face_detector.py"
    click EL "https://github.com/vardanagarwal/proctoring-ai/blob/master/face_landmarks.py"
    click ET "https://github.com/vardanagarwal/proctoring-ai/blob/master/eye_tracker.py"
    click ET "https://github.com/vardanagarwal/proctoring-ai/tree/master/eye_tracking/"
    click HO "https://github.com/vardanagarwal/proctoring-ai/blob/master/mouth_opening_detector.py"
    click HP "https://github.com/vardanagarwal/proctoring-ai/blob/master/head_pose_estimation.py"
    click PM "https://github.com/vardanagarwal/proctoring-ai/blob/master/person_and_phone.py"
    click PM "https://github.com/vardanagarwal/proctoring-ai/tree/master/coco models"
    click PM "https://github.com/vardanagarwal/proctoring-ai/tree/master/coco models/tflite mobnetv1 ssd"
    click FS "https://github.com/vardanagarwal/proctoring-ai/blob/master/face_spoofing.py"
    click AC "https://github.com/vardanagarwal/proctoring-ai/blob/master/audio_part.py"
    click IN "https://github.com/vardanagarwal/proctoring-ai/blob/master/main.py"

    %% Styles and Classes
    classDef input fill:#FDEBD0,stroke:#E67E22,stroke-width:2px;
    classDef vision fill:#AED6F1,stroke:#2874A6,stroke-width:2px;
    classDef audio fill:#A9DFBF,stroke:#239B56,stroke-width:2px;
    classDef integration fill:#F5B7B1,stroke:#C0392B,stroke-width:2px;
```
