Enterprise Infrastructure•CASE STUDY N001

Campus URP

8-Subsystem Enterprise URP with a LangGraph Multi-Agent Operations Layer

Next.jsFastAPILangGraphGoogle GeminiGoogle OR-ToolsPostgreSQLDocker
01. OBJECTIVE & SYSTEM CONSTRAINTS

The Engineering Problem

An enterprise-grade, modular-monolith University Resource Planning suite spanning 8 master subsystems. A bounded LangGraph multi-agent layer routes natural-language requests across live campus services while scheduling, cafe POS, library, societies, lost & found, help desk, and IAM retain deterministic control of data and transactions.

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.
  • ▶The AI layer receives trusted request context only after JWT authentication; specialists have isolated tool registries and can draft, never directly execute, operational writes.
02. STACK RATIONALE & ARCHITECTURE DECISIONS
STACK_RATIONALE // SYSTEM_ARCHITECTURE
⚡LangGraph Multi-Agent Orchestration(vs. Free-form Chatbot / Direct LLM Database Access)

A compiled routing graph connects one primary agent to six domain specialists with isolated tool lists. The LLM interprets intent and drafts typed UI; existing backend services remain authoritative for data, permissions, and writes.

⚡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
// APPLICATION & AI ORCHESTRATION TIER
FastAPI Application Engine
[Async REST Service]

FastAPI / Python / Uvicorn

Campus Agent Orchestration
[Bounded Multi-Agent Graph]

LangGraph / Google Gemini / SSE

CP-SAT Constraint Solver
[Algorithmic Optimizer]

Google OR-Tools / CP-SAT

LANGGRAPH ROUTING / ISOLATED TOOLS / SSE
// 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, eight subsystem experiences, and typed generative UI widgets with TanStack Query data fetching.

04. SYSTEM INTERFACES & PLATFORM GALLERY
Campus Agent — Multi-Agent Operations
Campus Agent — Multi-Agent Operations (Light)
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

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

Campus Agent & Generative UI Layer
AI AGENT

LangGraph routing agent and six domain specialists provide live, tool-grounded campus assistance with SSE streaming, typed UI widgets, isolated tools, and confirmation-gated writes.

0 tables|3 AI 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 week 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

Bounded Multi-Agent Campus Operations

Problem Encountered:

A campus assistant needs useful, live answers across six operational domains without receiving authority to invent facts or execute transactions.

Architectural Solution:

Built a compiled LangGraph StateGraph with one routing agent, six domain specialists, isolated ToolNodes, low-temperature streaming models, and typed SSE widget events.

System Guardrail:The graph selects intent only. Trusted identity stays server-side, tools are domain-scoped, and every write remains an explicit confirmation through the existing authorized API.
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 week of manual timetable labor for the largest departments
O(1)
BITMASK LOOKUP
Bitwise AND for room, faculty & cohort conflict detection
8 MODULES
MASTER SUBSYSTEMS
Campus Agent, 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
⚠ CPU CAPACITY & BOUNDED AGENT AUTONOMY: 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 (for example, reserving one CPU core for the web server while allocating the remaining cores to the optimization engine). The Campus Agent is bounded separately: LangGraph limits it to defined routes and domain tools, and every operational write still requires explicit user confirmation through the existing authorized API.
Technology Stack:
Next.jsFastAPILangGraphGoogle GeminiGoogle OR-ToolsPostgreSQLDocker