How alzuhairia/gestion_absences_universite works
1. UniAbsences is a Django monolith organized as a set of domain apps rather than a layered service architecture. The central runtime is Gunicorn running Django, with PostgreSQL as the system of record and Redis used for cache/rate-limiting style concerns.
2. The main business boundary is the attendance workflow. The absences app owns absence records, justification submission/review, QR attendance, GPS anti-fraud checks, and related utilities. It also contains custom management commands for maintenance jobs such as QR log cleanup and document migration, which indicates this domain has both interactive and batch-processing paths.
3. Academic structure is split across academics and academic_sessions. academics models faculties, departments, and courses; academic_sessions models academic years and teaching sessions. These apps provide the reference data that attendance, enrollment, dashboards, and rules depend on.
4. Identity and access are centralized in accounts. This app defines the custom user model, login/profile flows, 2FA setup and verification, backup codes, middleware for auth/session enforcement, and an admin superuser creation command. Role separation is a first-class architectural boundary: admin, secretary, professor, and student each have distinct views, templates, and permissions.
5. Student enrollment is isolated in enrollments. It manages registration status, exemption rules, and threshold-related eligibility logic. This app bridges academic structure and attendance policy, so it is one of the main data dependencies for both absence enforcement and dashboard reporting.
6. The dashboard app is the role-based presentation and control plane. It contains separate view modules for admin, secretary, professor, and student, plus export and statistics endpoints. This is where operational workflows converge: course management, settings, audits, user administration, attendance summaries, and data exports.
7. Communication and automation are split into messaging and notifications. messaging is the internal inbox/sent-box feature for authenticated users, while notifications handles outbound email delivery, templates, weekly summaries, and email logs. The email subsystem is closely tied to absence events, justification decisions, and threshold alerts.
8. Security and traceability are provided by audits and by the account middleware/2FA stack. audits persists sensitive action logs and exposes audit views, while accounts and middleware_2fa.py enforce stronger login/session controls. The repository’s tests and scripts suggest auditability is treated as a core requirement rather than an add-on.
9. The REST API lives under apps/api and wraps the same domain data through serializers, permissions, filters, throttles, and pagination. This is not a separate backend; it is an alternate interface over the same Django models and business rules used by the server-rendered pages.
10. The UI is server-rendered Django templates, organized by domain and role. Base templates such as base_admin.html, base_secretary.html, base_instructor.html, and base_student.html show that presentation is segmented by permission group. HTMX is used for some real-time interactions, especially attendance marking, without turning the project into a separate SPA.
11. Background and operational workflows are handled with Django management commands and helper scripts. Examples include seeding demo/UAT data, generating weekly summaries, fixing schema/data issues, and maintenance/verification scripts. This indicates the repository is built for institutional deployment with ongoing admin operations, not just request/response traffic.
12. Infrastructure is containerized. Docker Compose orchestrates at least the web app, PostgreSQL, Redis, Nginx, and monitoring. Nginx terminates TLS, serves static/media content, and reverse-proxies to Django. Redis supports application-side performance and throttling concerns. Uptime Kuma and a health endpoint provide availability monitoring.
13. The request flow is therefore: browser or API client -> Nginx -> Django/Gunicorn -> domain app logic -> PostgreSQL, with Redis used where request shaping or caching is needed, and email/notifications emitted asynchronously from business events. Most cross-cutting behavior is implemented inside Django apps via services, signals, middleware, and role-specific views rather than via external microservices.
14. The repository’s tests mirror these boundaries: there are dedicated tests for 2FA, absences, QR/GPS, sessions, enrollments, messaging, middleware, health, API auth, and performance queries. That test layout reflects the architecture: a modular monolith with strong domain separation, shared persistence, and role-aware workflows.
Main entry points: urls.py URL router · models.py Absences · dashboard/views.py Dashboard · api/views.py REST API
Components 20
Platform
Django runtime, deployment, cache, and operational tooling.
- Django app · Main Django application runtime served by Gunicorn.
config/wsgi.py - Settings · Central Django configuration and environment wiring.
config/settings.py - URL router · Top-level URL dispatch into domain apps and API.
config/urls.py - Compose stack · Container orchestration for web, database, cache, and proxy.
docker-compose.yml - Reverse proxy · TLS termination, static/media serving, and proxying to Django.
nginx/nginx.conf - Redis cache · Cache and request-shaping support such as throttling.
redis/redis.conf
Identity
Authentication, roles, and session enforcement.
Academic data
Reference data for institutions, years, and teaching sessions.
Attendance
Absence workflow, enrollment rules, and audit trail.
- Enrollments · Registration status, exemptions, and eligibility thresholds.
apps/enrollments/models.py - Absences · Absence records, justifications, QR attendance, and GPS anti-fraud checks.
apps/absences/models.py - Audits · Sensitive action logging and audit views.
apps/audits/models.py
Presentation
Server-rendered role-based UI and API surface.
Communication
Messaging and email notifications.
- Messaging · Internal inbox and sent-box for authenticated users.
apps/messaging/models.py - Notifications · Outbound email delivery, templates, logs, and weekly summaries.
apps/notifications/email.py
Connections 48
- Compose stack → Reverse proxy: routes through · Nginx fronts the web application stack.
- Compose stack → Django app: runs · Compose starts the Django web runtime.
- Compose stack → Redis cache: provides cache · Redis is part of the deployment stack.
- Reverse proxy → Django app: proxies · Requests are reverse-proxied to Django/Gunicorn.
- Django app → Settings: loads · Runtime behavior is driven by Django settings.
- Django app → URL router: dispatches · Top-level URL routing enters the app boundary.
- URL router → Accounts: includes · Authentication and profile flows are mounted here.
- URL router → Academics: includes · Academic reference data routes are mounted here.
- URL router → Sessions: includes · Academic session routes are mounted here.
- URL router → Enrollments: includes · Enrollment and rule routes are mounted here.
- URL router → Absences: includes · Attendance workflow routes are mounted here.
- URL router → Dashboard: includes · Role-based dashboard routes are mounted here.
- URL router → REST API: includes · REST API routes are mounted here.
- URL router → Messaging: includes · Internal messaging routes are mounted here.
- URL router → Notifications: includes · Notification-related routes are mounted here.
- URL router → Audits: includes · Audit views are exposed through routing.
- URL router → Health: includes · Health endpoint routes are mounted here.
- 2FA stack → Accounts: extends · 2FA and middleware deepen the account boundary.
- Academics → Sessions: depends on · Courses and structure are tied to academic sessions.
- Enrollments → Academics: depends on · Enrollment policy references academic structure.
- Enrollments → Sessions: depends on · Eligibility and status are session-aware.
- Absences → Academics: depends on · Attendance is evaluated against courses and departments.
- Absences → Sessions: depends on · Absence records are bound to teaching sessions.
- Absences → Enrollments: depends on · Policy checks use enrollment and exemption rules.
- Absences → Audits: emits logs · Sensitive attendance actions are audit-worthy.
- Dashboard → Accounts: uses roles · Role-specific views and permissions are account-driven.
- Dashboard → Academics: manages · Admins and secretaries manage academic structure.
- Dashboard → Sessions: manages · Session administration flows live in the dashboard.
- Dashboard → Enrollments: manages · Enrollment oversight and thresholds are surfaced here.
- Dashboard → Absences: reviews · Absence summaries, validation, and QR operations converge here.
- Dashboard → Audits: reviews · Audit logs are presented in the control plane.
- REST API → Accounts: secures · API permissions and auth are account-based.
- REST API → Academics: serializes · Academic reference data is exposed through the API.
- REST API → Sessions: serializes · Academic session data is exposed through the API.
- REST API → Enrollments: serializes · Enrollment and rule data are exposed through the API.
- REST API → Absences: serializes · Attendance and justification data are exposed through the API.
- REST API → Dashboard: supports · The API is an alternate interface over the same domain rules.
- Templates → Dashboard: renders · Role-specific pages are primarily dashboard-driven.
- Templates → Accounts: renders · Login, profile, and 2FA flows use dedicated templates.
- Templates → Absences: renders · Attendance and QR workflows are server-rendered.
- Messaging → Accounts: authenticates · Only authenticated roles can use the inbox.
- Notifications → Absences: notifies · Absence events trigger email notifications.
- Notifications → Enrollments: notifies · Eligibility and threshold changes can emit email alerts.
- Notifications → Accounts: notifies · Account-related messages and summaries depend on users.
- Audits → Accounts: records · Audit records are tied to user identity.
- Scripts → Django app: maintains · Maintenance and verification scripts support the deployed app.
- Scripts → Absences: maintains · Domain scripts cover attendance maintenance jobs.
- Scripts → Notifications: maintains · Operational scripts support email and summary workflows.