Enterprise InfrastructureCASE STUDY N001

Campus URP

7-Subsystem Enterprise URP & Asynchronous Systems Architecture

Next.jsFastAPIGoogle OR-ToolsPostgreSQLAsync SQLAlchemyDocker
01. OBJECTIVE & SYSTEM CONSTRAINTS

The Engineering Problem

An enterprise-grade, modular monolith University Resource Planning (URP) suite spanning 7 master subsystems—automated academic scheduling (CP-SAT + DFS solvers), digital cafe wallet & POS, integrated library & OPAC, campus societies, lost & found mediation, help desk ticketing, and stateful identity management.

Systemic Bounds & Operational Constraints:
  • Zero faculty/room/cohort double-booking enforced via CP-SAT hard constraints and bitmask pre-computation.
  • ACID row-level locking for zero-trust cafe POS double-spend prevention.
  • Strict RBAC enforcement across Student, Faculty, and 7 module-scoped admin roles (Timetable, Library, Societies, Lost & Found, Help Desk, Cafe, Super Admin).
02. STACK RATIONALE & ARCHITECTURE DECISIONS
STACK_RATIONALE // SYSTEM_ARCHITECTURE
Modular Monolith Architecture(vs. Microservices / Serverless Functions)

Single deployment unit with strict module boundaries avoids distributed system overhead (service mesh, eventual consistency) while maintaining sub-module isolation across 7 subsystems.

Async SQLAlchemy 2.0 + psycopg3(vs. Sync ORM (Django/Flask-SQLAlchemy))

Non-blocking I/O via native binary protocol driver handles concurrent BFF dashboard aggregations, real-time WebSocket broadcasting, and financial row-level locks without thread pool saturation.

Google OR-Tools CP-SAT(vs. Heuristic algorithms / Genetic solvers)

Guarantees mathematically optimal constraint satisfaction using interval variables and NoOverlap constraints for room, faculty, and cohort conflict resolution under a strict 2-minute solver timeout.

Stateful JWT + Refresh Token Rotation(vs. Stateless JWT / OAuth2 PKCE)

PostgreSQL-tracked refresh tokens enable instant session revocation and Token Theft Reuse Detection — if a revoked token is presented, all active sessions for that user are purged.

03. SYSTEM ARCHITECTURE TOPOLOGY

HOVER NODES TO INSPECT SERVICE BOUNDARIES AND IMPLEMENTATION DETAILS

System Boundary: CAMPUS URP SYSTEM
// PRESENTATION TIER
Campus Next.js Client
[Server-Rendered UI]

Next.js / TypeScript / Tailwind CSS

HTTPS / TLS 1.3
// GATEWAY TIER
Nginx Reverse Proxy
[Ingress Gateway]

Nginx / Docker Compose

REVERSE PROXY DISPATCH
// SERVICE TIER
FastAPI Application Engine
[Async REST Service]

FastAPI / Python / Uvicorn

CP-SAT Constraint Solver
[Algorithmic Optimizer]

Google OR-Tools / CP-SAT

ASYNC SQLALCHEMY / BFF AGGREGATION
// DATA & INTEGRATION TIER
PostgreSQL Database
[Relational Persistence]

PostgreSQL / Async SQLAlchemy

External Services
[Third-Party Integrations]

SMTP / ReportLab / OpenPyXL

Campus Next.js Client [Server-Rendered UI]Next.js / TypeScript / Tailwind CSS

App Router shell serving student, faculty, and 7 module-scoped admin portals with TanStack Query data fetching.

04. SYSTEM INTERFACES & PLATFORM GALLERY
Dashboard Overview
Dashboard Overview (Light)
Cafeteria POS
Cafeteria POS (Light)
Help Desk
Help Desk (Light)
Library
Library (Light)
Lost & Found
Lost & Found (Light)
Societies Hub
Societies Hub (Light)
Timetable Scheduler
Timetable Scheduler (Light)
05. SUBSYSTEM ARCHITECTURE DEEP-DIVE

7 MASTER SUBSYSTEMS — 40+ DATABASE TABLES — 250+ API ENDPOINTS

Core Identity & Access Management
IAM

Hybrid Roll No/Email identity with stateful JWT Refresh Token Rotation, RBAC enforcement, and Zero Information Leakage password recovery.

11 tables|45+ endpoints
Academic Scheduling & Timetable Engine
SCHEDULER

CP-SAT constraint solver and recursive backtracking DFS with O(1) bitmask caches, manual builder planner, and Time Travel dashboard.

13 tables|55+ endpoints
Campus Engagement & Society Management
SOCIETIES

Role-based mini social network with dual-channel chat (General/Executive), membership lifecycle state machine, and Admin Oversight Mode.

4 tables|35+ endpoints
Integrated Library & OPAC System
OPAC

Unified Inventory Architecture separating Book metadata from physical BookCopy assets, with automated Waitlist/Hold-Shelf routing and late-fee financials.

6 tables|45+ endpoints
Lost & Found Inventory Management
L&F

Verified crowdsourcing platform with moderation-first triage, multi-party claim mediation engine, and edit-locking on approved items.

2 tables|30+ endpoints
Cafe POS & Digital Wallet
POS

Digital wallet and cash-hybrid POS with Smart Classification (Payment vs Loan), row-level locks (SELECT FOR UPDATE), and Digital Kitchen Display System.

6 tables|25+ endpoints
Digital Help Desk & Ticketing
ITSM

Enterprise facility ticketing across 6 domains (IT, Maintenance, Electrical, Plumbing, Furniture, Other) with SLA severity tiers, War Room hourly ticket heatmap analytics, and custom SQL priority sorting.

1 tables|15+ endpoints
06. IMPLEMENTATION CHALLENGES & HARD BUGS
CHALLENGE 01

Constraint-Based Timetable Optimization

Problem Encountered:

Manual scheduling across shared building pools consumed 1.5 days of administrative labor per semester for the largest departments, with frequent room and cohort conflicts.

Architectural Solution:

Integrated dual-mode automated scheduling: Google OR-Tools CP-SAT solver (2-minute timeout) for optimal placement, and recursive backtracking DFS (200K node cap) for rapid conflict-free generation.

System Guardrail:Pre-computed room, faculty, and cohort bitmask caches enforce O(1) conflict detection before committing any slot allocation.
CHALLENGE 02

Cross-Module State Machine Integrity

Problem Encountered:

Multiple subsystems (Help Desk, Lost & Found, Library, Cafe POS) each manage independent lifecycles with strict transition rules that must prevent invalid state mutations.

Architectural Solution:

Implemented server-enforced state machine guardrails: Help Desk tickets lock editing once review starts, Lost & Found items lock critical fields once approved, and Library holds expire after 48-hour pickup windows.

System Guardrail:All state transitions are validated server-side with explicit enum checks — client cannot bypass lifecycle rules via direct API calls.
CHALLENGE 03

Zero-Trust Financial Engine & Concurrency

Problem Encountered:

Concurrent cafeteria checkouts risked race conditions and balance overdrafts during peak meal hours across hundreds of simultaneous users.

Architectural Solution:

Engineered PostgreSQL row-level locks (SELECT FOR UPDATE) on wallet rows with 5-second idempotency deduplication, zero-trust server-side price recalculation, and automated defaulter ban logic.

System Guardrail:Server strictly recalculates item costs from DB — client-submitted prices are ignored. Banned users can deposit but cannot take loans.
07. TELEMETRY & METRIC STACK
~30 min
AUTOMATED SCHEDULING
Replaces 1.5 days of manual timetable labor for the largest departments
O(1)
BITMASK LOOKUP
Bitwise AND for room, faculty & cohort conflict detection
7 MODULES
MASTER SUBSYSTEMS
IAM, Timetable, Cafe POS, Library OPAC, Societies, Lost & Found, Help Desk
9 ROLES
RBAC HIERARCHY
Module-scoped admin delegation with per-subsystem access control
08. ARCHITECTURAL TRADEOFFS & INSIGHTS
MONOLITHIC CPU CORE RESERVATION: Google OR-Tools CP-SAT solver natively saturates all available CPU cores during constraint solving. To prevent CPU starvation across the shared FastAPI service and ensure incoming API requests stay responsive, the solver is worker-capped (e.g. reserving 1 CPU core for the web server while allocating remaining cores for the optimization engine).
Technology Stack:
Next.jsFastAPIGoogle OR-ToolsPostgreSQLAsync SQLAlchemyDocker