# yxshee/realtime-face-attendance architecture

> Architecture diagram of the GitHub repository yxshee/realtime-face-attendance, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-04). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/yxshee/realtime-face-attendance
- Repository: https://github.com/yxshee/realtime-face-attendance

## Overview

##### Main Components

a) Input Layer:
- Camera Interface Module (represented by img_capture.py)
- Real-time Video Stream Handler

b) Processing Layer:
- Face Detection Module (using Haarcascade)
- Face Recognition Engine
- Image Processing Pipeline
- Training Module (shown by training.py and retrain.py)

c) Data Management Layer:
- Database System (indicated by init_db.sql)
- Image Organization System (organizeImages.py)
- Authentication System (admin_credentials.json)

d) System Core:
- Main Application Logic (system.py)
- Logging System (app.log)

**┌─────────────────────────────────────────┐**
- Input Layer                │
- ┘
- ↓
**┌─────────────────────────────────────────┐**
- Face Detection Pipeline         │
- ┌─────────┐    ┌─────────┐            │
- Haar     │ → │OpenCV    │            │
- Cascade  │    │Processing│            │
- ┘    └─────────┘            │
- ┘
- ↓
**┌─────────────────────────────────────────┐**
- Recognition & Training          │
- ┌─────────┐    ┌─────────┐            │
- Model    │ → │Feature   │            │
- Training │    │Extraction│            │
- ┘    └─────────┘            │
- ┘
- ↓
**┌─────────────────────────────────────────┐**
- Data Management Layer           │
- ┘

##### Connection Types

- Double lines (═): Data persistence operations

##### Component Details

For each major component, include:
- Input/Output formats
- Key dependencies
- Processing steps
- Storage requirements

##### Performance Indicators

Annotations for:
- Expected processing times
- System requirements
- Scalability limits
- Resource usage

##### Integration Points

Clearly mark:
- External system interfaces
- API endpoints
- Database connections
- File system interactions

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Input
        Camera["Camera Interface"]:::input
        Stream["Video Stream Handler"]:::input
    end

    subgraph "Face Detection Pipeline"
        Haar["Haar Cascade Detector"]:::processing
        OpenCV["OpenCV Processing"]:::processing
    end

    subgraph "Recognition & Training"
        Training["Training Module"]:::ml
        Retrain["Retraining Module"]:::ml
        Recognition["Face Recognition Engine"]:::ml
    end

    subgraph "Data Management"
        DB[(Database)]:::storage
        ImageOrg["Image Organization"]:::storage
        Auth["Authentication System"]:::security
        Log["Logging System"]:::utility
    end

    %% Main System Flow
    Camera --> Stream
    Stream --> Haar
    Haar --> OpenCV
    OpenCV --> Recognition
    Recognition --> DB

    %% Training Flow
    Training --> Recognition
    Retrain --> Recognition
    ImageOrg --> Training
    ImageOrg --> Retrain

    %% Data Management Flow
    Auth -.-> Recognition
    Recognition -.-> Log
    DB -.-> ImageOrg

    %% Styling
    classDef input fill:#3498db,stroke:#2980b9,stroke-width:2px
    classDef processing fill:#2ecc71,stroke:#27ae60,stroke-width:2px
    classDef ml fill:#e74c3c,stroke:#c0392b,stroke-width:2px
    classDef storage fill:#f1c40f,stroke:#f39c12,stroke-width:2px
    classDef security fill:#95a5a6,stroke:#7f8c8d,stroke-width:2px
    classDef utility fill:#bdc3c7,stroke:#95a5a6,stroke-width:2px

    %% Click Events
    click Camera "https://github.com/yxshee/realtime-face-attendance/blob/main/img_capture.py"
    click Haar "https://github.com/yxshee/realtime-face-attendance/blob/main/Haarcascade.xml"
    click Recognition "https://github.com/yxshee/realtime-face-attendance/blob/main/system.py"
    click Training "https://github.com/yxshee/realtime-face-attendance/blob/main/training.py"
    click Retrain "https://github.com/yxshee/realtime-face-attendance/blob/main/retrain.py"
    click DB "https://github.com/yxshee/realtime-face-attendance/blob/main/init_db.sql"
    click ImageOrg "https://github.com/yxshee/realtime-face-attendance/blob/main/organizeImages.py"
    click Auth "https://github.com/yxshee/realtime-face-attendance/blob/main/admin_credentials.json"
    click Log "https://github.com/yxshee/realtime-face-attendance/blob/main/app.log"

    %% Legend
    subgraph Legend
        L1["Input Components"]:::input
        L2["Processing Components"]:::processing
        L3["ML Components"]:::ml
        L4["Storage Components"]:::storage
        L5["Security Components"]:::security
        L6["Utility Components"]:::utility
    end
```
