How theanomicg/risely-smartattend works
1. Repository shape
SmartAttend is a three-part monorepo: a Python kiosk client (kiosk/), a FastAPI backend (server/), and a React/Tailwind teacher dashboard (dashboard/). The root also contains Docker Compose files and OS-specific startup scripts that act as the operational boundary for local development.
2. Primary domain concept
The key cross-system identifier is class_id. It ties together kiosk check-in/out events, teacher dashboard views, attendance logs, alerts, and camera configuration so all subsystems refer to the same academic class record.
3. Kiosk edge client
The kiosk is the classroom capture endpoint running on a Raspberry Pi or similar device. Its job is to use a local camera, capture face data for check-in/check-out, and send those events to the backend over HTTP. It is intentionally separate from the dashboard so classroom capture can continue even if the UI is not in use.
4. Backend API and orchestration
The backend is the system’s central coordinator. server/app/main.py exposes FastAPI routes, while supporting modules handle authentication, configuration, database access, face processing, WebSocket broadcasting, and runtime monitoring. This is the only component that talks directly to PostgreSQL and to stored enrollment photos.
5. Attendance and presence processing
Attendance logic is split into dedicated services under server/app/services/. One service handles attendance recording, another performs face matching, and another manages presence state. This separation suggests a flow where captured face embeddings are matched first, then attendance/session state is updated, then events are exposed to downstream consumers.
6. Face recognition and storage boundary
Student enrollment photos are stored on disk under server/storage/enrollment_photos/ by default, while face embeddings live in PostgreSQL with the vector extension. That means the backend keeps a dual representation: image files for review and vector rows for similarity matching. The face-processing layer uses DeepFace/OpenCV, with the current spec expecting 128-dimensional embeddings.
7. Database layer
PostgreSQL is the authoritative persistence layer for attendance records, student/class metadata, and vector search data. server/sql/init.sql and server/app/db.py indicate an explicit schema/bootstrap path, and the repo assumes pgvector is enabled. The database is started separately via Compose or helper scripts, reinforcing that it is an infrastructure dependency rather than an embedded store.
8. Teacher dashboard
The dashboard is a browser-based React app built with Vite and Tailwind. It provides the teacher-facing operational view, including attendance logs, status banners, resource lists, and a teacher/admin panel. It does not own business logic; it consumes backend APIs and WebSocket updates through dashboard/src/api.js.
9. Admin and classroom operations
The admin panel appears to manage operational resources such as cameras and enrollment photo review. The README notes that camera RTSP URLs are masked in list responses and that the admin panel shows camera runtime health from the backend monitoring loop. This indicates an admin boundary focused on configuration and observability rather than student attendance entry.
10. Real-time updates and monitoring
server/app/ws.py and server/app/monitoring.py point to two real-time concerns: pushing state to the dashboard and tracking backend/camera health. The dashboard likely subscribes to live updates for attendance and monitoring, while the backend schedules periodic checks using APScheduler. This creates a feedback loop for camera availability and classroom presence status.
11. Authentication boundary
Authentication is optional and token-based. TEACHER_TOKEN and ADMIN_TOKEN can be enabled in the backend, and the dashboard can inject corresponding tokens through environment variables. In local development, auth can be disabled, which keeps the default architecture simple while still supporting protected deployments.
12. Runtime and deployment topology
The repo is designed to run either as separate local processes or via Docker Compose. Canonical startup scripts live in scripts/, the backend is a Python 3.11/FastAPI service, the dashboard is a Node/Vite frontend, and the kiosk is another Python process. The result is a loosely coupled system: edge capture, central processing, and browser-based supervision.
13. Main data flow
The end-to-end flow is: kiosk captures a face event → backend matches the face against stored embeddings → attendance/session state is persisted in PostgreSQL → backend optionally publishes live updates over WebSocket → dashboard renders attendance and monitoring views. Enrollment photos and camera health data support this flow but live at different boundaries: photos on disk, embeddings in the database, and camera status in the monitoring subsystem.
Main entry points: main.py API entry · TeacherDashboard.jsx Teacher view · compose.yaml Compose/launch · App.jsx Dashboard app
Components 22
Operations
Local runtime and deployment boundary.
- Compose/launch · Root scripts and compose files start the three runtimes and database.
compose.yaml
Kiosk
Edge capture client on the classroom device.
- Kiosk client · Camera-based classroom capture process that sends attendance events to the backend.
kiosk/main.py
Backend
FastAPI coordinator, persistence, and real-time services.
- API entry · FastAPI application entry point that wires routes and services.
server/app/main.py - Auth · Optional teacher/admin token boundary for protected deployments.
server/app/auth.py - Config · Environment-driven settings for deployment, auth, and feature flags.
server/app/config.py - Postgres · Authoritative database access and bootstrap path for attendance and metadata.
server/app/db.py - Domain models · Core attendance, class, student, and camera domain objects.
server/app/models.py - API schemas · Request and response shapes exposed by the backend API.
server/app/schemas.py - Face pipeline · OpenCV/DeepFace-based face handling for recognition and embeddings.
server/app/face.py - Matching · Compares captured embeddings against stored enrollment embeddings.
server/app/services/matching.py - Attendance · Persists check-in and check-out events and class attendance records.
server/app/services/attendance.py - Presence · Maintains live presence/session state for downstream consumers.
server/app/services/presence.py - WebSocket · Broadcasts live attendance and status updates to the dashboard.
server/app/ws.py - Monitoring · Tracks backend and camera runtime health for operational visibility.
server/app/monitoring.py - Photo store · Disk boundary for enrollment photos used by recognition and review.
server/app/storage.py
Dashboard
Teacher-facing React UI and API client.
- Dashboard app · Frontend shell that assembles the teacher and admin views.
dashboard/src/App.jsx - API client · Browser-side backend integration for REST and live updates.
dashboard/src/api.js - Teacher view · Primary operational screen for attendance and classroom status.
dashboard/src/components/TeacherDashboard.jsx - Attendance log · Displays attendance events and classroom records.
dashboard/src/components/AttendanceLog.jsx - Status banner · Shows live state and health summaries to the teacher.
dashboard/src/components/StatusBanner.jsx - Resource lists · Operational lists for cameras and enrollment-related resources.
dashboard/src/components/ResourceLists.jsx - Admin panel · Teacher/admin controls for operational resources and review.
dashboard/src/components/AdminPanel.jsx
Connections 29
- Compose/launch → Kiosk client: starts · Launches the edge capture client.
- Compose/launch → API entry: starts · Launches the backend API service.
- Compose/launch → Dashboard app: starts · Launches the browser frontend.
- Compose/launch → Postgres: provisions · Brings up the PostgreSQL dependency.
- Kiosk client → API entry: events · Sends check-in and check-out requests over HTTP.
- Dashboard app → API client: uses · UI shell delegates backend communication to the API client.
- Dashboard app → Teacher view: renders · Composes the main operational classroom view.
- Dashboard app → Admin panel: renders · Includes the admin/operator controls.
- Teacher view → Attendance log: contains · Shows attendance history and current records.
- Teacher view → Status banner: contains · Shows live status and health banners.
- Teacher view → Resource lists: contains · Shows operational resource listings.
- Teacher view → Admin panel: contains · Surfaces administrative classroom operations.
- API client → API entry: calls · Consumes backend REST and real-time endpoints.
- API entry → Auth: guards · Applies optional teacher/admin token checks.
- API entry → Config: reads · Loads runtime configuration and feature flags.
- API entry → Postgres: persists · Central API boundary writes and reads authoritative state.
- API entry → Domain models: uses · Shares domain objects across the application boundary.
- API entry → API schemas: serializes · Shapes API inputs and outputs.
- API entry → Face pipeline: routes · Directs image/embedding processing requests.
- API entry → WebSocket: publishes · Streams live updates to connected clients.
- API entry → Monitoring: observes · Exposes health and runtime state.
- Face pipeline → Matching: feeds · Produces embeddings for similarity matching.
- Face pipeline → Photo store: reads · Uses enrollment photos from disk.
- Matching → Postgres: queries · Looks up stored embeddings and related metadata.
- Matching → Attendance: triggers · Matched identity flows into attendance recording.
- Attendance → Postgres: writes · Stores attendance events and class records.
- Attendance → Presence: updates · Refreshes session and presence state after recording.
- Presence → WebSocket: broadcasts · Pushes live presence changes to the dashboard.
- Monitoring → WebSocket: broadcasts · Sends runtime health updates to clients.