# shabesa/automated-attendance-system architecture

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

- Interactive diagram: https://gitdiagram.com/shabesa/automated-attendance-system
- Repository: https://github.com/shabesa/automated-attendance-system

## Overview

##### Project Type and Purpose
- This is an embedded-plus-software attendance system.
- It uses Python for core logic (face recognition, UI, CSV logging, Firebase integration, email) and Arduino (RFID reader + TFT display) for hardware interfacing.

##### File Structure
- Top-level Python modules:
- main.py – orchestrator
- SerialComms.py – serial link to Arduino
- UI.py – Tkinter GUI
- face_recog.py – camera + face_recognition lib
- add_card.py – RFID tag registration
- data_map.py – plotting attendance graphs
- firebase.py – firebase_admin pushes
- mail.py – emailing CSV reports
- Arduino code under `arduino/rfid` and `arduino/tft_info`: RFID tag reading and TFT display logic.
- Data storage: `cards.csv` (RFID ↔ student map) and attendance CSV files under `attendance/`.
- Configuration: `settings.txt`, `requirements.txt`.
- Tests under `test/`.

##### README Insights
- Real-time face recognition + RFID tag verification.
- Attendance logged locally (CSV) and remotely (Firebase).
- Final report emailed and optionally visualized on a Flutter mobile app.

##### Main Components
a. Hardware Layer
- Arduino Uno/Mega with RFID Reader
- TFT Display Module
- Camera (USB or embedded)
b. Application Layer (Python)
- main.py (Controller)
- face_recog.py (Vision module)
- SerialComms.py (Serial I/O)
- UI.py (User interface)
- add_card.py (Tag enrollment)
- data_map.py (Graphing module)
- firebase.py (Cloud sync)
- mail.py (Email service)
c. Data Layer
- Local CSV files (`cards.csv`, attendance CSVs)
- Firebase Realtime Database
d. External Services
- SMTP Mail Server
- (Optional) Flutter Attendance_Viewer App via Firebase

##### Relationships and Data Flow
- Camera → face_recog.py → main.py
- RFID tag present → Arduino (rfid.ino) → SerialComms.py → main.py
- main.py checks face + tag → updates attendance CSV → triggers data_map.py and mail.py
- firebase.py pushes attendance records to Firebase → Flutter App reads from Firebase
- UI.py provides real-time status and controls add_card.py for new tag enrollment
- TFT module (tft_info.ino) receives simple status messages from Python over serial

##### Architectural Patterns and Design Principles
- Layered architecture: Hardware ↔ Serial I/O ↔ Core logic ↔ Data ↔ External services
- Single-responsibility modules (one Python file = one major function)
- Loose coupling via well-defined serial protocol and CSV/Firebase interfaces

- Clear, human-readable labels on every component.
- Notes on any configuration files or settings (e.g., serial baud rate in settings.txt).

## Diagram (Mermaid)

```mermaid
graph TD
    %% Hardware Layer
    subgraph "Hardware Layer"
        direction TB
        rfid["RFID Reader"]:::hardware
        tft["TFT Display Module"]:::hardware
        cam["Camera"]:::hardware
    end

    %% Application Layer
    subgraph "Application Layer"
        direction TB
        main["main.py (Controller)"]:::app
        face["face_recog.py"]:::app
        serial["SerialComms.py"]:::app
        ui["UI.py (Tkinter GUI)"]:::app
        enroll["add_card.py"]:::app
        graphmod["data_map.py"]:::app
        firemod["firebase.py"]:::app
        mailmod["mail.py"]:::app
    end

    %% Data Layer
    subgraph "Data Layer"
        direction TB
        cards["cards.csv"]:::data
        attend["attendance/"]:::data
    end

    %% Configuration
    subgraph "Configuration"
        direction TB
        settings["settings.txt"]:::config
        reqs["requirements.txt"]:::config
    end

    %% External Services
    subgraph "External Services"
        direction TB
        smtp["SMTP Mail Server"]:::external
        firebaseSrv["Firebase Realtime Database"]:::external
        flutter["Flutter Attendance Viewer"]:::external
    end

    %% Connections: Hardware to App
    cam -->|"Image"| face
    rfid -->|"Serial (JSON)"| serial
    serial -->|"Tag ID"| main

    %% App Internal Flows
    face -->|"Face data"| main
    main -->|"Update UI"| ui
    ui -->|"Enroll cmd"| enroll
    main -->|"Append CSV"| attend
    main -->|"Read/write"| cards
    main -->|"Trigger graph"| graphmod
    main -->|"Trigger email (CSV)"| mailmod
    main -->|"Record attendance"| firemod
    main -->|"Serial status"| tft

    %% App to Config
    main -->|"Load settings"| settings
    main -->|"Dependencies"| reqs

    %% App to External
    firemod -->|"HTTP/REST"| firebaseSrv
    mailmod -->|"SMTP"| smtp
    firebaseSrv -->|"Realtime sync"| flutter

    %% Click Events
    click rfid "https://github.com/shabesa/automated-attendance-system/blob/main/arduino/rfid/rfid.ino"
    click tft "https://github.com/shabesa/automated-attendance-system/blob/main/arduino/tft_info/tft_info.ino"
    click cam "https://github.com/shabesa/automated-attendance-system/blob/main/face_recog.py"
    click main "https://github.com/shabesa/automated-attendance-system/blob/main/main.py"
    click serial "https://github.com/shabesa/automated-attendance-system/blob/main/SerialComms.py"
    click ui "https://github.com/shabesa/automated-attendance-system/blob/main/UI.py"
    click enroll "https://github.com/shabesa/automated-attendance-system/blob/main/add_card.py"
    click graphmod "https://github.com/shabesa/automated-attendance-system/blob/main/data_map.py"
    click firemod "https://github.com/shabesa/automated-attendance-system/blob/main/firebase.py"
    click mailmod "https://github.com/shabesa/automated-attendance-system/blob/main/mail.py"
    click cards "https://github.com/shabesa/automated-attendance-system/blob/main/cards.csv"
    click attend "https://github.com/shabesa/automated-attendance-system/tree/main/attendance/"
    click settings "https://github.com/shabesa/automated-attendance-system/blob/main/settings.txt"
    click reqs "https://github.com/shabesa/automated-attendance-system/blob/main/requirements.txt"

    %% Styles
    classDef hardware fill:#9f6,stroke:#333,stroke-width:1px
    classDef app fill:#6cf,stroke:#333,stroke-width:1px
    classDef data fill:#f96,stroke:#333,stroke-width:1px
    classDef external fill:#c9f,stroke:#333,stroke-width:1px
    classDef config fill:#fc6,stroke:#333,stroke-width:1px
```
