How ankan00v/lpu-smart-campus works
Purpose and Entry Points
LPU Smart Campus is a production-style campus operations platform: attendance and remedial workflows, food ordering, academic administration/RMS, identity controls, realtime updates, and AI support. The FastAPI application starts at app/main.py; it assembles API domains from app/routers/. The browser SPA enters through web/index.html and web/app.js, with backend-served UI/static routes.
API Composition and Domain Boundaries
Routers are the primary HTTP authorization and product boundaries: authentication, attendance, remedial, food, messaging, resources/admin, enterprise, AI, identity, and realtime. Core paths: app/routers/auth.py, app/routers/attendance.py, app/routers/remedial.py. Supporting operations are separated into app/routers/food.py, app/routers/admin.py, and app/routers/enterprise.py; router handlers delegate to domain services rather than being the intended persistence boundary.
Academic Attendance and Recovery
Attendance accepts scheduled, time-windowed student submissions, verifies faces, persists ledger state, supports faculty review, and derives risk interventions. app/face_verification.py handles multi-frame/anti-spoof verification; app/attendance_ledger.py owns attendance records; app/attendance_recovery.py produces watch/high/critical recovery plans and may feed administrative/RMS actions. Academic policy and default scheduling logic reside in app/academic_policy.py and app/default_timetable.py.
Remedial and Messaging Lifecycle
Faculty creates section-scoped remedial classes, distributes codes/messages, and students validate codes before face-verified attendance. The workflow records class/attendance history and exposes faculty section status. Principal boundary: app/routers/remedial.py; associated delivery and recovery behavior: app/routers/messages.py, app/recovery_email_template.py. This shares identity, face verification, SQL persistence, asynchronous dispatch, and realtime publication with normal attendance.
Identity, Security, and Enterprise Governance
OTP-first authentication, sessions, roles, MFA, and identity consistency are centered in app/routers/auth.py, app/auth_utils.py, and app/id_alignment.py. Identity Shield case/graph functionality is isolated in app/routers/identity_shield.py and app/identity_shield.py. Enterprise endpoints cover SSO/SCIM, encryption rotation, compliance exports, DR, and capacity/SLA controls through app/routers/enterprise.py and app/enterprise_controls.py.
Persistence and Async/Realtime Runtime
PostgreSQL is the transactional system of record, represented by app/database.py and app/models.py. MongoDB holds auth plus mirrored/event/analytics-oriented views via app/mongo.py; alignment and snapshot consistency are explicit operational concerns. Redis provides rate-limit/cache primitives and cross-instance fanout through app/redis_dual_client.py and app/realtime_bus.py. Durable work is dispatched through an outbox/worker boundary (app/outbox.py, app/workers.py) for OTP, notifications, re-verification, and recomputation. SSE is exposed by app/routers/realtime.py; clients consume it in web/modules/realtime-event-bus.js.
Client, Integrations, and Deployment
The vanilla-JS SPA lazy-loads live workflow routes such as web/routes/attendance-live.js, web/routes/remedial-live.js, and web/routes/admin-live.js. Food operations include payment intent/webhook safety in app/routers/food.py, with Razorpay as the declared payment integration. AI assistance is split between Copilot and Saarthi (app/copilot_ai.py, app/saarthi_service.py) with environment-driven providers. Strict production runtime requires Redis and workers; the container topology is defined in deploy/docker-compose.strict.yml, while telemetry and health/metrics controls live in app/observability.py and app/runtime_infra.py.
Main entry points: main.py FastAPI application · attendance_ledger.py Attendance ledger · app.js Vanilla JS SPA · docker-compose.strict.yml Strict production topology
Components 20
Browser Client
- Vanilla JS SPA · Lazy-loads live campus workflows.
web/app.js - Live workflow routes
web/routes/attendance-live.js - Realtime event client
web/modules/realtime-event-bus.js
FastAPI API
- FastAPI application · Assembles routers and serves backend UI/static routes.
app/main.py - Auth API · OTP, sessions, roles, and MFA boundary.
app/routers/auth.py - Attendance API · Scheduled student submissions and faculty review.
app/routers/attendance.py - Remedial API · Section remedial lifecycle and code validation.
app/routers/remedial.py - Operations APIs · Food, admin, and enterprise operations.
app/routers/enterprise.py - Realtime API
app/routers/realtime.py - Identity Shield API
app/routers/identity_shield.py
Domain Services
- Attendance ledger · Owns attendance records and ledger state.
app/attendance_ledger.py - Face verification · Multi-frame and anti-spoof checks.
app/face_verification.py - Attendance recovery · Derives watch, high, and critical intervention plans.
app/attendance_recovery.py - Identity controls · Maintains identity alignment and Shield cases.
app/identity_shield.py - Copilot & Saarthi
app/copilot_ai.py
Data & Runtime
- PostgreSQL
app/database.py - MongoDB · Stores auth plus mirrored/event-oriented views.
app/mongo.py - Redis realtime bus · Provides rate limits, cache, and cross-instance fanout.
app/realtime_bus.py - Outbox workers · Dispatches OTP, notifications, re-verification, and recomputation.
app/workers.py - Strict production topology · Requires Redis and workers.
deploy/docker-compose.strict.yml
Connections 27
- Vanilla JS SPA → FastAPI application: HTTP and static UI
- Vanilla JS SPA → Live workflow routes: lazy-loads
- Vanilla JS SPA → Realtime event client: starts
- Realtime event client → Realtime API: SSE
- FastAPI application → Auth API: mounts
- FastAPI application → Attendance API: mounts
- FastAPI application → Remedial API: mounts
- FastAPI application → Operations APIs: mounts
- FastAPI application → Realtime API: mounts
- FastAPI application → Identity Shield API: mounts
- Auth API → MongoDB: auth state
- Auth API → Identity controls: aligns identities
- Attendance API → Face verification: verifies submission
- Attendance API → Attendance ledger: records and reviews
- Remedial API → Face verification: verifies attendance
- Remedial API → Attendance ledger: records history
- Attendance ledger → PostgreSQL: persists
- Attendance ledger → Attendance recovery: supplies risk data
- Attendance recovery → Outbox workers: queues interventions
- Operations APIs → PostgreSQL: transactional operations
- Identity Shield API → Identity controls: case and graph actions
- Copilot & Saarthi → PostgreSQL: uses campus context
- Outbox workers → Redis realtime bus: publishes events
- Redis realtime bus → Realtime API: fans out events
- Strict production topology → FastAPI application: runs
- Strict production topology → Outbox workers: runs
- Strict production topology → Redis realtime bus: requires