# dsingh0304/hostleseatallocation architecture

> Architecture diagram of the GitHub repository dsingh0304/hostleseatallocation, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-12). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/dsingh0304/hostleseatallocation
- Repository: https://github.com/dsingh0304/hostleseatallocation

## Overview

ResidentIQ is a role-based hostel allocation platform. Students authenticate and complete onboarding, browse eligibility and availability, then book rooms or coordinate roommate invites; administrators manage hostels, students, allocation windows and exceptions, and review reports. The Next.js pages call a REST API, whose Express routes dispatch to feature controllers and allocation logic backed by Prisma/PostgreSQL. Auth, audit and rate-limit middleware support the API, while the server synchronizes window state and starts an email worker. Some README capabilities lack sampled implementation excerpts, so those are represented at documented subsystem level only.

Main entry points: [`server/src/app.ts`](https://github.com/dsingh0304/hostleseatallocation/blob/main/server/src/app.ts) (Express API), [`server/src/modules/allocation/allocation.routes.ts`](https://github.com/dsingh0304/hostleseatallocation/blob/main/server/src/modules/allocation/allocation.routes.ts) (Booking routes), [`server/src/lib/prisma.ts`](https://github.com/dsingh0304/hostleseatallocation/blob/main/server/src/lib/prisma.ts) (PostgreSQL access), [`server/src/modules/auth/auth.routes.ts`](https://github.com/dsingh0304/hostleseatallocation/blob/main/server/src/modules/auth/auth.routes.ts) (Auth routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Web client"]
  node_student_ui["Student dashboard<br/>[page.tsx]"]
  node_admin_ui["Admin dashboard<br/>[page.tsx]"]
  node_admin_tabs["Admin tools"]
  node_client_api["API client<br/>[api.ts]"]
  node_auth_store["Auth state<br/>[authStore.ts]"]
end

subgraph group_api["API and access"]
  node_server_app["Express API<br/>[app.ts]"]
  node_auth_routes["Auth routes<br/>[auth.routes.ts]"]
  node_auth_controller["Auth workflows<br/>[auth.controller.ts]"]
  node_auth_service["Token and password service<br/>[auth.service.ts]"]
  node_auth_middleware["Authentication and roles<br/>[auth.middleware.ts]"]
  node_rate_limit["Rate limiting"]
  node_audit["Audit logging"]
  node_error_handler["Error handling"]
end

subgraph group_domain["Allocation operations"]
  node_admin_routes["Admin routes<br/>[admin.routes.ts]"]
  node_admin_controller["Admin management"]
  node_student_routes["Student routes<br/>[student.routes.ts]"]
  node_student_controller["Student services"]
  node_allocation_routes["Booking routes"]
  node_allocation_controller["Booking controller"]
  node_allocation_service["Booking logic"]
end

subgraph group_runtime["Runtime services"]
  node_database[("PostgreSQL access<br/>[prisma.ts]")]
  node_redis[("Redis<br/>[redis.ts]")]
  node_email_worker["Email worker<br/>[email.worker.ts]"]
  node_logger["Logger<br/>[logger.ts]"]
end

node_student_actor(("Student"))
node_admin_actor(("Admin or warden"))

node_student_actor -->|"uses"| node_student_ui
node_admin_actor -->|"uses"| node_admin_ui
node_student_ui -->|"calls"| node_client_api
node_admin_ui -->|"renders"| node_admin_tabs
node_admin_tabs -->|"calls"| node_client_api
node_student_ui -->|"reads"| node_auth_store
node_admin_ui -->|"reads"| node_auth_store
node_client_api -->|"calls REST"| node_server_app
node_server_app -->|"mounts"| node_auth_routes
node_server_app -->|"mounts"| node_allocation_routes
node_server_app -->|"mounts"| node_admin_routes
node_server_app -->|"mounts"| node_student_routes
node_auth_routes -->|"dispatches"| node_auth_controller
node_auth_routes -->|"applies"| node_rate_limit
node_auth_routes -->|"applies"| node_auth_middleware
node_auth_controller -->|"uses"| node_auth_service
node_auth_controller -->|"reads/writes"| node_database
node_auth_service -->|"uses"| node_redis
node_admin_routes -->|"dispatches"| node_admin_controller
node_admin_routes -->|"applies"| node_auth_middleware
node_admin_controller -->|"reads/writes"| node_database
node_student_routes -->|"dispatches"| node_student_controller
node_student_routes -->|"applies"| node_auth_middleware
node_student_controller -->|"reads/writes"| node_database
node_allocation_routes -->|"dispatches"| node_allocation_controller
node_allocation_routes -->|"applies"| node_auth_middleware
node_allocation_routes -->|"applies"| node_audit
node_allocation_routes -->|"applies"| node_rate_limit
node_allocation_controller -->|"calls"| node_allocation_service
node_allocation_service -->|"reads/writes"| node_database
node_allocation_service -->|"uses"| node_redis
node_server_app -->|"syncs windows"| node_database
node_server_app -->|"starts"| node_email_worker
node_error_handler -->|"logs errors"| node_logger

click node_student_ui "https://github.com/dsingh0304/hostleseatallocation/blob/main/client/app/dashboard/student/page.tsx"
click node_admin_ui "https://github.com/dsingh0304/hostleseatallocation/blob/main/client/app/dashboard/admin/page.tsx"
click node_admin_tabs "https://github.com/dsingh0304/hostleseatallocation/tree/main/client/app/dashboard/admin/components"
click node_client_api "https://github.com/dsingh0304/hostleseatallocation/blob/main/client/app/lib/api.ts"
click node_auth_store "https://github.com/dsingh0304/hostleseatallocation/blob/main/client/app/store/authStore.ts"
click node_server_app "https://github.com/dsingh0304/hostleseatallocation/blob/main/server/src/app.ts"
click node_auth_routes "https://github.com/dsingh0304/hostleseatallocation/blob/main/server/src/modules/auth/auth.routes.ts"
click node_auth_controller "https://github.com/dsingh0304/hostleseatallocation/blob/main/server/src/modules/auth/auth.controller.ts"
click node_auth_service "https://github.com/dsingh0304/hostleseatallocation/blob/main/server/src/modules/auth/auth.service.ts"
click node_auth_middleware "https://github.com/dsingh0304/hostleseatallocation/blob/main/server/src/middleware/auth.middleware.ts"
click node_rate_limit "https://github.com/dsingh0304/hostleseatallocation/blob/main/server/src/middleware/rateLimiter.middleware.ts"
click node_audit "https://github.com/dsingh0304/hostleseatallocation/blob/main/server/src/middleware/auditLog.middleware.ts"
click node_error_handler "https://github.com/dsingh0304/hostleseatallocation/blob/main/server/src/middleware/errorHandler.middleware.ts"
click node_admin_routes "https://github.com/dsingh0304/hostleseatallocation/blob/main/server/src/modules/admin/admin.routes.ts"
click node_admin_controller "https://github.com/dsingh0304/hostleseatallocation/blob/main/server/src/modules/admin/admin.controller.ts"
click node_student_routes "https://github.com/dsingh0304/hostleseatallocation/blob/main/server/src/modules/student/student.routes.ts"
click node_student_controller "https://github.com/dsingh0304/hostleseatallocation/blob/main/server/src/modules/student/student.controller.ts"
click node_allocation_routes "https://github.com/dsingh0304/hostleseatallocation/blob/main/server/src/modules/allocation/allocation.routes.ts"
click node_allocation_controller "https://github.com/dsingh0304/hostleseatallocation/blob/main/server/src/modules/allocation/allocation.controller.ts"
click node_allocation_service "https://github.com/dsingh0304/hostleseatallocation/blob/main/server/src/modules/allocation/allocation.service.ts"
click node_database "https://github.com/dsingh0304/hostleseatallocation/blob/main/server/src/lib/prisma.ts"
click node_redis "https://github.com/dsingh0304/hostleseatallocation/blob/main/server/src/lib/redis.ts"
click node_email_worker "https://github.com/dsingh0304/hostleseatallocation/blob/main/server/src/workers/email.worker.ts"
click node_logger "https://github.com/dsingh0304/hostleseatallocation/blob/main/server/src/lib/logger.ts"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_student_ui,node_admin_ui,node_admin_tabs,node_client_api,node_auth_store toneBlue
class node_server_app,node_auth_routes,node_auth_controller,node_auth_service,node_auth_middleware,node_rate_limit,node_audit,node_error_handler toneAmber
class node_admin_routes,node_admin_controller,node_student_routes,node_student_controller,node_allocation_routes,node_allocation_controller,node_allocation_service toneMint
class node_database,node_redis,node_email_worker,node_logger toneRose
class node_student_actor,node_admin_actor toneIndigo
```

## Components

### Web client

- [Student dashboard](https://github.com/dsingh0304/hostleseatallocation/blob/main/client/app/dashboard/student/page.tsx): `client/app/dashboard/student/page.tsx`
- [Admin dashboard](https://github.com/dsingh0304/hostleseatallocation/blob/main/client/app/dashboard/admin/page.tsx): `client/app/dashboard/admin/page.tsx`
- [Admin tools](https://github.com/dsingh0304/hostleseatallocation/tree/main/client/app/dashboard/admin/components): `client/app/dashboard/admin/components`
- [API client](https://github.com/dsingh0304/hostleseatallocation/blob/main/client/app/lib/api.ts): `client/app/lib/api.ts`
- [Auth state](https://github.com/dsingh0304/hostleseatallocation/blob/main/client/app/store/authStore.ts): `client/app/store/authStore.ts`

### API and access

- [Express API](https://github.com/dsingh0304/hostleseatallocation/blob/main/server/src/app.ts): `server/src/app.ts`
- [Auth routes](https://github.com/dsingh0304/hostleseatallocation/blob/main/server/src/modules/auth/auth.routes.ts): `server/src/modules/auth/auth.routes.ts`
- [Auth workflows](https://github.com/dsingh0304/hostleseatallocation/blob/main/server/src/modules/auth/auth.controller.ts): `server/src/modules/auth/auth.controller.ts`
- [Token and password service](https://github.com/dsingh0304/hostleseatallocation/blob/main/server/src/modules/auth/auth.service.ts): `server/src/modules/auth/auth.service.ts`
- [Authentication and roles](https://github.com/dsingh0304/hostleseatallocation/blob/main/server/src/middleware/auth.middleware.ts): `server/src/middleware/auth.middleware.ts`
- [Rate limiting](https://github.com/dsingh0304/hostleseatallocation/blob/main/server/src/middleware/rateLimiter.middleware.ts): `server/src/middleware/rateLimiter.middleware.ts`
- [Audit logging](https://github.com/dsingh0304/hostleseatallocation/blob/main/server/src/middleware/auditLog.middleware.ts): `server/src/middleware/auditLog.middleware.ts`
- [Error handling](https://github.com/dsingh0304/hostleseatallocation/blob/main/server/src/middleware/errorHandler.middleware.ts): `server/src/middleware/errorHandler.middleware.ts`

### Allocation operations

- [Admin routes](https://github.com/dsingh0304/hostleseatallocation/blob/main/server/src/modules/admin/admin.routes.ts): `server/src/modules/admin/admin.routes.ts`
- [Admin management](https://github.com/dsingh0304/hostleseatallocation/blob/main/server/src/modules/admin/admin.controller.ts): `server/src/modules/admin/admin.controller.ts`
- [Student routes](https://github.com/dsingh0304/hostleseatallocation/blob/main/server/src/modules/student/student.routes.ts): `server/src/modules/student/student.routes.ts`
- [Student services](https://github.com/dsingh0304/hostleseatallocation/blob/main/server/src/modules/student/student.controller.ts): `server/src/modules/student/student.controller.ts`
- [Booking routes](https://github.com/dsingh0304/hostleseatallocation/blob/main/server/src/modules/allocation/allocation.routes.ts): `server/src/modules/allocation/allocation.routes.ts`
- [Booking controller](https://github.com/dsingh0304/hostleseatallocation/blob/main/server/src/modules/allocation/allocation.controller.ts): `server/src/modules/allocation/allocation.controller.ts`
- [Booking logic](https://github.com/dsingh0304/hostleseatallocation/blob/main/server/src/modules/allocation/allocation.service.ts): `server/src/modules/allocation/allocation.service.ts`

### Runtime services

- [PostgreSQL access](https://github.com/dsingh0304/hostleseatallocation/blob/main/server/src/lib/prisma.ts): `server/src/lib/prisma.ts`
- [Redis](https://github.com/dsingh0304/hostleseatallocation/blob/main/server/src/lib/redis.ts): `server/src/lib/redis.ts`
- [Email worker](https://github.com/dsingh0304/hostleseatallocation/blob/main/server/src/workers/email.worker.ts): `server/src/workers/email.worker.ts`
- [Logger](https://github.com/dsingh0304/hostleseatallocation/blob/main/server/src/lib/logger.ts): `server/src/lib/logger.ts`

### Other components

- **Student**
- **Admin or warden**

## Connections

- Student → Student dashboard: uses
- Admin or warden → Admin dashboard: uses
- Student dashboard → API client: calls (evidence: `client/app/dashboard/student/page.tsx`)
- Admin dashboard → Admin tools: renders (evidence: `client/app/dashboard/admin/page.tsx`)
- Admin tools → API client: calls (evidence: `client/app/dashboard/admin/components/AllocateTab.tsx`)
- Student dashboard → Auth state: reads (evidence: `client/app/dashboard/student/page.tsx`)
- Admin dashboard → Auth state: reads (evidence: `client/app/dashboard/admin/page.tsx`)
- API client → Express API: calls REST
- Express API → Auth routes: mounts (evidence: `server/src/app.ts`)
- Express API → Booking routes: mounts (evidence: `server/src/app.ts`)
- Express API → Admin routes: mounts (evidence: `server/src/app.ts`)
- Express API → Student routes: mounts (evidence: `server/src/app.ts`)
- Auth routes → Auth workflows: dispatches (evidence: `server/src/modules/auth/auth.routes.ts`)
- Auth routes → Rate limiting: applies (evidence: `server/src/modules/auth/auth.routes.ts`)
- Auth routes → Authentication and roles: applies (evidence: `server/src/modules/auth/auth.routes.ts`)
- Auth workflows → Token and password service: uses (evidence: `server/src/modules/auth/auth.controller.ts`)
- Auth workflows → PostgreSQL access: reads/writes (evidence: `server/src/modules/auth/auth.controller.ts`)
- Token and password service → Redis: uses (evidence: `server/src/modules/auth/auth.service.ts`)
- Admin routes → Admin management: dispatches (evidence: `server/src/modules/admin/admin.routes.ts`)
- Admin routes → Authentication and roles: applies (evidence: `server/src/modules/admin/admin.routes.ts`)
- Admin management → PostgreSQL access: reads/writes (evidence: `server/src/modules/admin/admin.controller.ts`)
- Student routes → Student services: dispatches (evidence: `server/src/modules/student/student.routes.ts`)
- Student routes → Authentication and roles: applies (evidence: `server/src/modules/student/student.routes.ts`)
- Student services → PostgreSQL access: reads/writes (evidence: `server/src/modules/student/student.controller.ts`)
- Booking routes → Booking controller: dispatches (evidence: `server/src/modules/allocation/allocation.routes.ts`)
- Booking routes → Authentication and roles: applies (evidence: `server/src/modules/allocation/allocation.routes.ts`)
- Booking routes → Audit logging: applies (evidence: `server/src/modules/allocation/allocation.routes.ts`)
- Booking routes → Rate limiting: applies (evidence: `server/src/modules/allocation/allocation.routes.ts`)
- Booking controller → Booking logic: calls (evidence: `server/src/modules/allocation/allocation.controller.ts`)
- Booking logic → PostgreSQL access: reads/writes (evidence: `server/src/modules/allocation/allocation.service.ts`)
- Booking logic → Redis: uses (evidence: `server/src/modules/allocation/allocation.service.ts`)
- Express API → PostgreSQL access: syncs windows (evidence: `server/src/app.ts`)
- Express API → Email worker: starts (evidence: `server/src/app.ts`)
- Error handling → Logger: logs errors (evidence: `server/src/middleware/errorHandler.middleware.ts`)
