# nuby911/absen-ai-bot architecture

> Architecture diagram of the GitHub repository nuby911/absen-ai-bot, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/nuby911/absen-ai-bot
- Repository: https://github.com/nuby911/absen-ai-bot

## Overview

SmartSchool AI combines a teacher kiosk attendance workflow, school administration, and parent-facing WhatsApp services. Teachers scan students on-device; the backend verifies faces, records attendance, and sends notifications. Parents can query attendance and schedules or submit leave requests through the WhatsApp chatbot, while administrators manage school data and evaluate system performance. Mobile source beyond its Android entrypoint is not in the supplied tree, so its detailed implementation is represented only at the documented product level; edges reflect README statements or shown backend wiring.

Main entry points: [`backend/app/main.py`](https://github.com/nuby911/absen-ai-bot/blob/main/backend/app/main.py) (FastAPI application), [`backend/app/routers/attendance.py`](https://github.com/nuby911/absen-ai-bot/blob/main/backend/app/routers/attendance.py) (Attendance API), [`backend/app/routers/admin.py`](https://github.com/nuby911/absen-ai-bot/blob/main/backend/app/routers/admin.py) (Admin operations), [`backend/app/models.py`](https://github.com/nuby911/absen-ai-bot/blob/main/backend/app/models.py) (School records)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_clients["User applications"]
  node_web["Admin dashboard"]
  node_webapi["Web API client<br/>[api.ts]"]
  node_mobile["Teacher kiosk app"]
end

subgraph group_api["Backend API"]
  node_backend["FastAPI application<br/>[main.py]"]
  node_auth["Authentication<br/>[auth.py]"]
  node_security["JWT and PIN security<br/>[security.py]"]
  node_schemas["API contracts<br/>[schemas.py]"]
  node_adminroutes["Admin operations<br/>[admin.py]"]
  node_attendance["Attendance API<br/>[attendance.py]"]
  node_leaves["Leave requests<br/>[leaves.py]"]
  node_webhook["WhatsApp webhook<br/>[webhook.py]"]
  node_dbengine["Database sessions<br/>[database.py]"]
  node_models[("School records<br/>[models.py]")]
end

subgraph group_domain["School workflows"]
  node_faceengine["Face embedding engine<br/>[face_engine.py]"]
  node_faceindex["Face index cache<br/>[face_index.py]"]
  node_rules["School rules<br/>[school_rules.py]"]
  node_semester["Semester maintenance"]
  node_recap["Semester recap<br/>[semester_recap.py]"]
  node_chatbot["Chatbot orchestrator<br/>[chatbot.py]"]
  node_waqueue["WhatsApp delivery queue<br/>[wa_queue.py]"]
end

subgraph group_integrations["External services"]
  node_llm["LLM provider<br/>[llm.py]"]
  node_wa["WhatsApp provider<br/>[whatsapp.py]"]
  node_gateway["WhatsApp gateway"]
  node_gemini["Gemini AI"]
end

node_admin(("School admin"))
node_teacher(("Teacher"))
node_student(("Student"))
node_parent(("Parent"))

node_admin -->|"manages school"| node_web
node_teacher -->|"uses kiosk"| node_mobile
node_student -->|"scans at kiosk"| node_mobile
node_parent -->|"messages via"| node_gateway
node_web -->|"uses client"| node_webapi
node_webapi -->|"calls REST API"| node_backend
node_mobile -->|"sends scan data"| node_backend
node_backend -->|"registers routes"| node_auth
node_backend -->|"registers routes"| node_adminroutes
node_backend -->|"registers routes"| node_attendance
node_backend -->|"registers routes"| node_leaves
node_backend -->|"registers routes"| node_webhook
node_auth -->|"uses credentials"| node_security
node_attendance -->|"verifies faces"| node_faceengine
node_attendance -->|"uses face index"| node_faceindex
node_attendance -->|"applies school rules"| node_rules
node_attendance -->|"queues notifications"| node_waqueue
node_adminroutes -->|"extracts embeddings"| node_faceengine
node_adminroutes -->|"maintains semesters"| node_semester
node_adminroutes -.->|"builds semester recap"| node_recap
node_webhook -->|"delegates message"| node_chatbot
node_chatbot -->|"interprets messages"| node_llm
node_chatbot -->|"sends replies"| node_wa
node_llm -->|"uses AI service"| node_gemini
node_waqueue -->|"dispatches messages"| node_wa
node_wa -->|"sends WhatsApp"| node_gateway
node_gateway -->|"posts incoming messages"| node_webhook
node_attendance -->|"records attendance"| node_models
node_adminroutes -->|"manages records"| node_models
node_leaves -->|"stores requests"| node_models
node_dbengine -->|"maps records"| node_models
node_backend -->|"configures database"| node_dbengine

click node_web "https://github.com/nuby911/absen-ai-bot/tree/main/web_admin/src/app"
click node_webapi "https://github.com/nuby911/absen-ai-bot/blob/main/web_admin/src/lib/api.ts"
click node_mobile "https://github.com/nuby911/absen-ai-bot/tree/main/mobile_guru"
click node_backend "https://github.com/nuby911/absen-ai-bot/blob/main/backend/app/main.py"
click node_auth "https://github.com/nuby911/absen-ai-bot/blob/main/backend/app/routers/auth.py"
click node_security "https://github.com/nuby911/absen-ai-bot/blob/main/backend/app/security.py"
click node_schemas "https://github.com/nuby911/absen-ai-bot/blob/main/backend/app/schemas.py"
click node_adminroutes "https://github.com/nuby911/absen-ai-bot/blob/main/backend/app/routers/admin.py"
click node_attendance "https://github.com/nuby911/absen-ai-bot/blob/main/backend/app/routers/attendance.py"
click node_leaves "https://github.com/nuby911/absen-ai-bot/blob/main/backend/app/routers/leaves.py"
click node_webhook "https://github.com/nuby911/absen-ai-bot/blob/main/backend/app/routers/webhook.py"
click node_dbengine "https://github.com/nuby911/absen-ai-bot/blob/main/backend/app/database.py"
click node_models "https://github.com/nuby911/absen-ai-bot/blob/main/backend/app/models.py"
click node_faceengine "https://github.com/nuby911/absen-ai-bot/blob/main/backend/app/providers/face_engine.py"
click node_faceindex "https://github.com/nuby911/absen-ai-bot/blob/main/backend/app/services/face_index.py"
click node_rules "https://github.com/nuby911/absen-ai-bot/blob/main/backend/app/services/school_rules.py"
click node_semester "https://github.com/nuby911/absen-ai-bot/blob/main/backend/app/services/semester_maintenance.py"
click node_recap "https://github.com/nuby911/absen-ai-bot/blob/main/backend/app/services/semester_recap.py"
click node_chatbot "https://github.com/nuby911/absen-ai-bot/blob/main/backend/app/services/chatbot.py"
click node_llm "https://github.com/nuby911/absen-ai-bot/blob/main/backend/app/providers/llm.py"
click node_waqueue "https://github.com/nuby911/absen-ai-bot/blob/main/backend/app/services/wa_queue.py"
click node_wa "https://github.com/nuby911/absen-ai-bot/blob/main/backend/app/providers/whatsapp.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_web,node_webapi,node_mobile toneBlue
class node_backend,node_auth,node_security,node_schemas,node_adminroutes,node_attendance,node_leaves,node_webhook,node_dbengine,node_models toneAmber
class node_faceengine,node_faceindex,node_rules,node_semester,node_recap,node_chatbot,node_waqueue toneMint
class node_llm,node_wa,node_gateway,node_gemini toneRose
class node_admin,node_teacher,node_student,node_parent toneIndigo
```

## Components

### User applications

- [Admin dashboard](https://github.com/nuby911/absen-ai-bot/tree/main/web_admin/src/app): `web_admin/src/app`
- [Web API client](https://github.com/nuby911/absen-ai-bot/blob/main/web_admin/src/lib/api.ts): `web_admin/src/lib/api.ts`
- [Teacher kiosk app](https://github.com/nuby911/absen-ai-bot/tree/main/mobile_guru): `mobile_guru`

### Backend API

- [FastAPI application](https://github.com/nuby911/absen-ai-bot/blob/main/backend/app/main.py): `backend/app/main.py`
- [Authentication](https://github.com/nuby911/absen-ai-bot/blob/main/backend/app/routers/auth.py): `backend/app/routers/auth.py`
- [JWT and PIN security](https://github.com/nuby911/absen-ai-bot/blob/main/backend/app/security.py): `backend/app/security.py`
- [API contracts](https://github.com/nuby911/absen-ai-bot/blob/main/backend/app/schemas.py): `backend/app/schemas.py`
- [Admin operations](https://github.com/nuby911/absen-ai-bot/blob/main/backend/app/routers/admin.py): `backend/app/routers/admin.py`
- [Attendance API](https://github.com/nuby911/absen-ai-bot/blob/main/backend/app/routers/attendance.py): `backend/app/routers/attendance.py`
- [Leave requests](https://github.com/nuby911/absen-ai-bot/blob/main/backend/app/routers/leaves.py): `backend/app/routers/leaves.py`
- [WhatsApp webhook](https://github.com/nuby911/absen-ai-bot/blob/main/backend/app/routers/webhook.py): `backend/app/routers/webhook.py`
- [Database sessions](https://github.com/nuby911/absen-ai-bot/blob/main/backend/app/database.py): `backend/app/database.py`
- [School records](https://github.com/nuby911/absen-ai-bot/blob/main/backend/app/models.py): `backend/app/models.py`

### School workflows

- [Face embedding engine](https://github.com/nuby911/absen-ai-bot/blob/main/backend/app/providers/face_engine.py): `backend/app/providers/face_engine.py`
- [Face index cache](https://github.com/nuby911/absen-ai-bot/blob/main/backend/app/services/face_index.py): `backend/app/services/face_index.py`
- [School rules](https://github.com/nuby911/absen-ai-bot/blob/main/backend/app/services/school_rules.py): `backend/app/services/school_rules.py`
- [Semester maintenance](https://github.com/nuby911/absen-ai-bot/blob/main/backend/app/services/semester_maintenance.py): `backend/app/services/semester_maintenance.py`
- [Semester recap](https://github.com/nuby911/absen-ai-bot/blob/main/backend/app/services/semester_recap.py): `backend/app/services/semester_recap.py`
- [Chatbot orchestrator](https://github.com/nuby911/absen-ai-bot/blob/main/backend/app/services/chatbot.py): `backend/app/services/chatbot.py`
- [WhatsApp delivery queue](https://github.com/nuby911/absen-ai-bot/blob/main/backend/app/services/wa_queue.py): `backend/app/services/wa_queue.py`

### External services

- [LLM provider](https://github.com/nuby911/absen-ai-bot/blob/main/backend/app/providers/llm.py): `backend/app/providers/llm.py`
- [WhatsApp provider](https://github.com/nuby911/absen-ai-bot/blob/main/backend/app/providers/whatsapp.py): `backend/app/providers/whatsapp.py`
- **WhatsApp gateway**
- **Gemini AI**

### Other components

- **School admin**
- **Teacher**
- **Student**
- **Parent**

## Connections

- School admin → Admin dashboard: manages school (evidence: `README.md`)
- Teacher → Teacher kiosk app: uses kiosk (evidence: `README.md`)
- Student → Teacher kiosk app: scans at kiosk (evidence: `README.md`)
- Parent → WhatsApp gateway: messages via (evidence: `README.md`)
- Admin dashboard → Web API client: uses client (evidence: `README.md`)
- Web API client → FastAPI application: calls REST API (evidence: `README.md`)
- Teacher kiosk app → FastAPI application: sends scan data (evidence: `README.md`)
- FastAPI application → Authentication: registers routes (evidence: `backend/app/main.py`)
- FastAPI application → Admin operations: registers routes (evidence: `backend/app/main.py`)
- FastAPI application → Attendance API: registers routes (evidence: `backend/app/main.py`)
- FastAPI application → Leave requests: registers routes (evidence: `backend/app/main.py`)
- FastAPI application → WhatsApp webhook: registers routes (evidence: `backend/app/main.py`)
- Authentication → JWT and PIN security: uses credentials (evidence: `backend/app/routers/auth.py`)
- Attendance API → Face embedding engine: verifies faces (evidence: `README.md`)
- Attendance API → Face index cache: uses face index (evidence: `backend/app/routers/attendance.py`)
- Attendance API → School rules: applies school rules (evidence: `backend/app/routers/attendance.py`)
- Attendance API → WhatsApp delivery queue: queues notifications (evidence: `README.md`)
- Admin operations → Face embedding engine: extracts embeddings (evidence: `backend/app/routers/admin.py`)
- Admin operations → Semester maintenance: maintains semesters (evidence: `backend/app/routers/admin.py`)
- Admin operations → Semester recap: builds semester recap
- WhatsApp webhook → Chatbot orchestrator: delegates message (evidence: `backend/app/routers/webhook.py`)
- Chatbot orchestrator → LLM provider: interprets messages (evidence: `README.md`)
- Chatbot orchestrator → WhatsApp provider: sends replies (evidence: `README.md`)
- LLM provider → Gemini AI: uses AI service (evidence: `README.md`)
- WhatsApp delivery queue → WhatsApp provider: dispatches messages (evidence: `README.md`)
- WhatsApp provider → WhatsApp gateway: sends WhatsApp (evidence: `README.md`)
- WhatsApp gateway → WhatsApp webhook: posts incoming messages (evidence: `README.md`)
- Attendance API → School records: records attendance (evidence: `README.md`)
- Admin operations → School records: manages records (evidence: `backend/app/routers/admin.py`)
- Leave requests → School records: stores requests (evidence: `backend/app/routers/leaves.py`)
- Database sessions → School records: maps records (evidence: `backend/app/models.py`)
- FastAPI application → Database sessions: configures database (evidence: `backend/app/main.py`)
