# anshuda231/smartattendance architecture

> Architecture diagram of the GitHub repository anshuda231/smartattendance, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-06). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/anshuda231/smartattendance
- Repository: https://github.com/anshuda231/smartattendance

## Overview

This is a Smart Attendance backend: an operator submits student photos for registration or classroom images for attendance, then can query students and attendance records. The runtime is concentrated in main.py, which also owns image preprocessing, face-model setup, recognition-related processing, session creation, and persistence helpers. The tree includes face-model files and local JSON data, while the excerpts show PostgreSQL support and JSON migration. Some processing and storage call sites fall in omitted excerpts, so those relationships are left unverified rather than inferred.

Main entry points: [`main.py`](https://github.com/anshuda231/smartattendance/blob/main/main.py) (Upload classroom photo), [`models/face_detection_yunet_2023mar.onnx`](https://github.com/anshuda231/smartattendance/blob/main/models/face_detection_yunet_2023mar.onnx) (YuNet model), [`models/face_recognition_sface_2021dec.onnx`](https://github.com/anshuda231/smartattendance/blob/main/models/face_recognition_sface_2021dec.onnx) (SFace model), [`data/students.json`](https://github.com/anshuda231/smartattendance/blob/main/data/students.json) (Student JSON)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API workflows"]
  node_register["Register student<br/>[main.py]"]
  node_classroom["Upload classroom photo<br/>[main.py]"]
  node_student_list["List students<br/>[main.py]"]
  node_attendance_list["List attendance<br/>[main.py]"]
  node_student_delete["Delete student<br/>[main.py]"]
end

subgraph group_vision["Face processing"]
  node_preprocess["Image preprocessing<br/>[main.py]"]
  node_face_detect["Face detection<br/>[main.py]"]
  node_yunet["YuNet model"]
  node_face_recognition["Face recognition<br/>[main.py]"]
  node_sface["SFace model"]
  node_student_lookup["Student matching<br/>[main.py]"]
end

subgraph group_records["Attendance records"]
  node_session["Attendance session<br/>[main.py]"]
  node_attendance_record["Attendance records<br/>[main.py]"]
end

subgraph group_storage["Persistence"]
  node_student_store["Student persistence<br/>[main.py]"]
  node_attendance_store["Attendance persistence<br/>[main.py]"]
  node_postgres[("PostgreSQL")]
  node_students_json[("Student JSON<br/>[students.json]")]
  node_attendance_json[("Attendance JSON<br/>[attendance.json]")]
  node_photos["Student photos"]
end

node_operator(("Operator"))

node_operator -->|"submits photo"| node_register
node_operator -->|"uploads image"| node_classroom
node_operator -->|"requests list"| node_student_list
node_operator -->|"requests records"| node_attendance_list
node_operator -->|"requests deletion"| node_student_delete
node_register -->|"preprocesses image"| node_preprocess
node_classroom -->|"preprocesses image"| node_preprocess
node_classroom -.->|"detects faces"| node_face_detect
node_face_detect -.->|"uses model"| node_yunet
node_classroom -.->|"recognizes faces"| node_face_recognition
node_face_recognition -.->|"uses model"| node_sface
node_classroom -->|"loads students"| node_student_lookup
node_student_lookup -.->|"reads records"| node_student_store
node_classroom -.->|"creates session"| node_session
node_classroom -.->|"creates records"| node_attendance_record
node_register -->|"saves student"| node_student_store
node_register -.->|"saves photo"| node_photos
node_student_list -->|"loads students"| node_student_store
node_attendance_list -->|"loads attendance"| node_attendance_store
node_student_delete -.->|"deletes student"| node_student_store
node_student_store -.->|"reads or writes"| node_postgres
node_student_store -.->|"reads or writes"| node_students_json
node_attendance_store -.->|"reads or writes"| node_postgres
node_attendance_store -.->|"reads or writes"| node_attendance_json

click node_register "https://github.com/anshuda231/smartattendance/blob/main/main.py"
click node_classroom "https://github.com/anshuda231/smartattendance/blob/main/main.py"
click node_student_list "https://github.com/anshuda231/smartattendance/blob/main/main.py"
click node_attendance_list "https://github.com/anshuda231/smartattendance/blob/main/main.py"
click node_student_delete "https://github.com/anshuda231/smartattendance/blob/main/main.py"
click node_preprocess "https://github.com/anshuda231/smartattendance/blob/main/main.py"
click node_face_detect "https://github.com/anshuda231/smartattendance/blob/main/main.py"
click node_yunet "https://github.com/anshuda231/smartattendance/blob/main/models/face_detection_yunet_2023mar.onnx"
click node_face_recognition "https://github.com/anshuda231/smartattendance/blob/main/main.py"
click node_sface "https://github.com/anshuda231/smartattendance/blob/main/models/face_recognition_sface_2021dec.onnx"
click node_student_lookup "https://github.com/anshuda231/smartattendance/blob/main/main.py"
click node_session "https://github.com/anshuda231/smartattendance/blob/main/main.py"
click node_attendance_record "https://github.com/anshuda231/smartattendance/blob/main/main.py"
click node_student_store "https://github.com/anshuda231/smartattendance/blob/main/main.py"
click node_attendance_store "https://github.com/anshuda231/smartattendance/blob/main/main.py"
click node_students_json "https://github.com/anshuda231/smartattendance/blob/main/data/students.json"
click node_attendance_json "https://github.com/anshuda231/smartattendance/blob/main/data/attendance.json"
click node_photos "https://github.com/anshuda231/smartattendance/tree/main/students"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_register,node_classroom,node_student_list,node_attendance_list,node_student_delete toneBlue
class node_preprocess,node_face_detect,node_yunet,node_face_recognition,node_sface,node_student_lookup toneAmber
class node_session,node_attendance_record toneMint
class node_student_store,node_attendance_store,node_postgres,node_students_json,node_attendance_json,node_photos toneRose
class node_operator toneIndigo
```

## Components

### API workflows

- [Register student](https://github.com/anshuda231/smartattendance/blob/main/main.py): `main.py`
- [Upload classroom photo](https://github.com/anshuda231/smartattendance/blob/main/main.py): `main.py`
- [List students](https://github.com/anshuda231/smartattendance/blob/main/main.py): `main.py`
- [List attendance](https://github.com/anshuda231/smartattendance/blob/main/main.py): `main.py`
- [Delete student](https://github.com/anshuda231/smartattendance/blob/main/main.py): `main.py`

### Face processing

- [Image preprocessing](https://github.com/anshuda231/smartattendance/blob/main/main.py): `main.py`
- [Face detection](https://github.com/anshuda231/smartattendance/blob/main/main.py): `main.py`
- [YuNet model](https://github.com/anshuda231/smartattendance/blob/main/models/face_detection_yunet_2023mar.onnx): `models/face_detection_yunet_2023mar.onnx`
- [Face recognition](https://github.com/anshuda231/smartattendance/blob/main/main.py): `main.py`
- [SFace model](https://github.com/anshuda231/smartattendance/blob/main/models/face_recognition_sface_2021dec.onnx): `models/face_recognition_sface_2021dec.onnx`
- [Student matching](https://github.com/anshuda231/smartattendance/blob/main/main.py): `main.py`

### Attendance records

- [Attendance session](https://github.com/anshuda231/smartattendance/blob/main/main.py): `main.py`
- [Attendance records](https://github.com/anshuda231/smartattendance/blob/main/main.py): `main.py`

### Persistence

- [Student persistence](https://github.com/anshuda231/smartattendance/blob/main/main.py): `main.py`
- [Attendance persistence](https://github.com/anshuda231/smartattendance/blob/main/main.py): `main.py`
- **PostgreSQL**
- [Student JSON](https://github.com/anshuda231/smartattendance/blob/main/data/students.json): `data/students.json`
- [Attendance JSON](https://github.com/anshuda231/smartattendance/blob/main/data/attendance.json): `data/attendance.json`
- [Student photos](https://github.com/anshuda231/smartattendance/tree/main/students): `students`

### Other components

- **Operator**

## Connections

- Operator → Register student: submits photo
- Operator → Upload classroom photo: uploads image
- Operator → List students: requests list
- Operator → List attendance: requests records
- Operator → Delete student: requests deletion
- Register student → Image preprocessing: preprocesses image (evidence: `main.py`)
- Upload classroom photo → Image preprocessing: preprocesses image (evidence: `main.py`)
- Upload classroom photo → Face detection: detects faces (evidence: `main.py`)
- Face detection → YuNet model: uses model
- Upload classroom photo → Face recognition: recognizes faces (evidence: `main.py`)
- Face recognition → SFace model: uses model
- Upload classroom photo → Student matching: loads students (evidence: `main.py`)
- Student matching → Student persistence: reads records (evidence: `main.py`)
- Upload classroom photo → Attendance session: creates session (evidence: `main.py`)
- Upload classroom photo → Attendance records: creates records (evidence: `main.py`)
- Register student → Student persistence: saves student (evidence: `main.py`)
- Register student → Student photos: saves photo
- List students → Student persistence: loads students (evidence: `main.py`)
- List attendance → Attendance persistence: loads attendance (evidence: `main.py`)
- Delete student → Student persistence: deletes student (evidence: `main.py`)
- Student persistence → PostgreSQL: reads or writes
- Student persistence → Student JSON: reads or writes
- Attendance persistence → PostgreSQL: reads or writes
- Attendance persistence → Attendance JSON: reads or writes
