# velocitatem/cv_eye_tracking architecture

> Architecture diagram of the GitHub repository velocitatem/cv_eye_tracking, 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/velocitatem/cv_eye_tracking
- Repository: https://github.com/velocitatem/cv_eye_tracking

## Overview

##### Main Components
- Data Collection Module (classroom.py): This is responsible for video capture, face detection, eye tracking, and calculating attention scores. Represent this as the “Input/Processing” component.
- Dashboard/Visualization Module (dashboard.py): This uses Streamlit to create an interactive web interface where users can view attention trends, time-series analyses, and detailed individual metrics. Represent this as the “Visualization/UI” component.

##### Important Architectural Patterns
- Separation of concerns: Each main script (data collection, analysis, visualization) handles its specific aspect of the system.
- Pipeline or modular design: data flows linearly from input (video capture and immediate processing) to analysis, then finally to the user interface.
- That the system might combine synchronous (video processing) and asynchronous or batch processing (analysis), which is a point of interest when designing such systems.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Data Collection Module and its subcomponents
    subgraph "Data Collection (Input/Processing)"
        DC_main["Data Collection"]:::blue
        DC1["Video Capture"]:::blue
        DC2["Face Detection"]:::blue
        DC3["Eye Tracking"]:::blue
        DC4["Attention Scoring"]:::blue
        DC_main --> DC1
        DC_main --> DC2
        DC_main --> DC3
        DC_main --> DC4
    end

    %% Observation Storage as persistent file
    Observations["Observation Storage (observations.pkl)"]:::storage

    %% Data Processing Module and its subcomponents
    subgraph "Data Processing (Processing & Analytics)"
        DP_main["Data Processing"]:::blue
        DP1["Face Embedding Extraction"]:::blue
        DP2["Clustering (DBSCAN)"]:::blue
        DP3["Metric Calculation"]:::blue
        DP_main --> DP1
        DP_main --> DP2
        DP_main --> DP3
    end

    %% Dashboard Module and its subcomponents
    subgraph "Dashboard (Visualization/UI)"
        DB_main["Dashboard"]:::green
        DB1["Interactive UI"]:::green
        DB2["Time-series Visualizations"]:::green
        DB3["Individual Metric Analysis"]:::green
        DB_main --> DB1
        DB_main --> DB2
        DB_main --> DB3
    end

    %% Pipeline Data Flow
    DC_main -->|"ObservationData"| Observations
    Observations -->|"ProcessedData"| DP_main
    DP_main -->|"VisualizationData"| DB_main

    %% External Libraries and Dependencies
    ext1["OpenCV"]:::external
    ext2["MediaPipe"]:::external
    ext3["DeepFace"]:::external
    ext4["dlib"]:::external
    ext5["NumPy"]:::external
    ext6["Matplotlib"]:::external
    ext7["Scikit-learn"]:::external
    ext8["Streamlit"]:::external

    %% Integration Points via External Dependencies
    DC_main -->|"uses"| ext1
    DC_main -->|"uses"| ext2
    DP_main -->|"uses"| ext3
    DP_main -->|"uses"| ext4
    DP_main -->|"uses"| ext5
    DP_main -->|"uses"| ext6
    DP_main -->|"uses"| ext7
    DB_main -->|"uses"| ext8

    %% Click Events for Component Mapping
    click DC_main "https://github.com/velocitatem/cv_eye_tracking/blob/main/classroom.py"
    click DP_main "https://github.com/velocitatem/cv_eye_tracking/blob/main/analysis.py"
    click DB_main "https://github.com/velocitatem/cv_eye_tracking/blob/main/dashboard.py"

    %% Styling of Nodes
    classDef blue fill:#add8e6,stroke:#000,stroke-width:2px;
    classDef green fill:#90ee90,stroke:#000,stroke-width:2px;
    classDef external fill:#fdd835,stroke:#000,stroke-width:2px;
    classDef storage fill:#ffcc80,stroke:#000,stroke-width:2px;
```
