# shiv4ah/facial-emotion-detection architecture

> Architecture diagram of the GitHub repository shiv4ah/facial-emotion-detection, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/shiv4ah/facial-emotion-detection
- Repository: https://github.com/shiv4ah/facial-emotion-detection

## Overview

This appears to be a student-attentiveness desktop application. The visible workflow begins with a Tkinter landing window and staff login; a successful database lookup opens a staff area. Separate camera scripts capture face images for enrollment and compare live faces with saved templates, emailing an alert after repeated unknown matches. CNN training and eye/head-pose calculations are also present, but the excerpts do not show them connected to a runtime attentiveness workflow. Several referenced modules and the README are unavailable, so those connections are omitted.

Main entry points: [`log.py`](https://github.com/shiv4ah/facial-emotion-detection/blob/main/log.py) (Staff login), [`name.py`](https://github.com/shiv4ah/facial-emotion-detection/blob/main/name.py) (Live face matching), [`face_reg.py`](https://github.com/shiv4ah/facial-emotion-detection/blob/main/face_reg.py) (Face enrollment), [`main.py`](https://github.com/shiv4ah/facial-emotion-detection/blob/main/main.py) (Landing window)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["Desktop interface"]
  node_landing["Landing window<br/>[main.py]"]
  node_staff_login["Staff login<br/>[log.py]"]
  node_staff_area["Staff area"]
end

subgraph group_identity["Face identity"]
  node_face_capture["Face enrollment<br/>[face_reg.py]"]
  node_face_templates[("Face templates<br/>[face_reg.py]")]
  node_live_match["Live face matching<br/>[name.py]"]
  node_template_match["Template comparison<br/>[name.py]"]
  node_unknown_alert["Unknown-face alert<br/>[name.py]"]
end

subgraph group_analytics["Attention analysis"]
  node_cnn_training["CNN training<br/>[model.py]"]
  node_eye_ratio["Eye ratio<br/>[EAR.py]"]
  node_eye_mouth_ratio["Eye and mouth ratios<br/>[EAR_calculator.py]"]
  node_head_pose["Head-pose estimation<br/>[HeadPose.py]"]
end

node_user(("Staff user"))
node_staff_store[("Staff records")]
node_camera(("Camera"))
node_mail_service["Email service"]

node_landing -->|"imports"| node_staff_login
node_staff_login -->|"queries"| node_staff_store
node_staff_login -->|"opens on success"| node_staff_area
node_camera -->|"provides frames"| node_face_capture
node_face_capture -->|"writes images"| node_face_templates
node_camera -->|"provides frames"| node_live_match
node_live_match -->|"calls"| node_template_match
node_template_match -->|"reads images"| node_face_templates
node_live_match -->|"counts unknown matches"| node_unknown_alert
node_unknown_alert -->|"sends email"| node_mail_service

click node_landing "https://github.com/shiv4ah/facial-emotion-detection/blob/main/main.py"
click node_staff_login "https://github.com/shiv4ah/facial-emotion-detection/blob/main/log.py"
click node_face_capture "https://github.com/shiv4ah/facial-emotion-detection/blob/main/face_reg.py"
click node_face_templates "https://github.com/shiv4ah/facial-emotion-detection/blob/main/face_reg.py"
click node_live_match "https://github.com/shiv4ah/facial-emotion-detection/blob/main/name.py"
click node_template_match "https://github.com/shiv4ah/facial-emotion-detection/blob/main/name.py"
click node_unknown_alert "https://github.com/shiv4ah/facial-emotion-detection/blob/main/name.py"
click node_cnn_training "https://github.com/shiv4ah/facial-emotion-detection/blob/main/model.py"
click node_eye_ratio "https://github.com/shiv4ah/facial-emotion-detection/blob/main/EAR.py"
click node_eye_mouth_ratio "https://github.com/shiv4ah/facial-emotion-detection/blob/main/EAR_calculator.py"
click node_head_pose "https://github.com/shiv4ah/facial-emotion-detection/blob/main/HeadPose.py"

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_landing,node_staff_login,node_staff_area,node_user toneBlue
class node_face_capture,node_face_templates,node_live_match,node_template_match,node_unknown_alert,node_staff_store toneAmber
class node_cnn_training,node_eye_ratio,node_eye_mouth_ratio,node_head_pose toneMint
class node_camera,node_mail_service toneIndigo
```

## Components

### Desktop interface

- [Landing window](https://github.com/shiv4ah/facial-emotion-detection/blob/main/main.py): `main.py`
- [Staff login](https://github.com/shiv4ah/facial-emotion-detection/blob/main/log.py): `log.py`
- **Staff area**

### Face identity

- [Face enrollment](https://github.com/shiv4ah/facial-emotion-detection/blob/main/face_reg.py): `face_reg.py`
- [Face templates](https://github.com/shiv4ah/facial-emotion-detection/blob/main/face_reg.py): `face_reg.py`
- [Live face matching](https://github.com/shiv4ah/facial-emotion-detection/blob/main/name.py): `name.py`
- [Template comparison](https://github.com/shiv4ah/facial-emotion-detection/blob/main/name.py): `name.py`
- [Unknown-face alert](https://github.com/shiv4ah/facial-emotion-detection/blob/main/name.py): `name.py`

### Attention analysis

- [CNN training](https://github.com/shiv4ah/facial-emotion-detection/blob/main/model.py): `model.py`
- [Eye ratio](https://github.com/shiv4ah/facial-emotion-detection/blob/main/EAR.py): `EAR.py`
- [Eye and mouth ratios](https://github.com/shiv4ah/facial-emotion-detection/blob/main/EAR_calculator.py): `EAR_calculator.py`
- [Head-pose estimation](https://github.com/shiv4ah/facial-emotion-detection/blob/main/HeadPose.py): `HeadPose.py`

### Other components

- **Staff user**
- **Staff records**
- **Camera**
- **Email service**

## Connections

- Landing window → Staff login: imports (evidence: `main.py`)
- Staff login → Staff records: queries (evidence: `log.py`)
- Staff login → Staff area: opens on success (evidence: `log.py`)
- Camera → Face enrollment: provides frames (evidence: `face_reg.py`)
- Face enrollment → Face templates: writes images (evidence: `face_reg.py`)
- Camera → Live face matching: provides frames (evidence: `name.py`)
- Live face matching → Template comparison: calls (evidence: `name.py`)
- Template comparison → Face templates: reads images (evidence: `name.py`)
- Live face matching → Unknown-face alert: counts unknown matches (evidence: `name.py`)
- Unknown-face alert → Email service: sends email (evidence: `name.py`)
