# avanibhide30/se-project-hms architecture

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

- Interactive diagram: https://gitdiagram.com/avanibhide30/se-project-hms
- Repository: https://github.com/avanibhide30/se-project-hms

## Overview

This is a role-based hostel management system: students apply for accommodation and manage rooms, fees, visitors, curfew, and leave; staff administer applications, allocations, accounts, security operations, notices, and reports. The frontend routes users to student or staff pages, makes authenticated API requests, and the Express backend dispatches those requests to domain routes backed by Prisma. The source index documents route registration and several route-to-storage dependencies; detailed calls within unsampled route modules are not asserted.

Main entry points: [`backend/src/index.ts`](https://github.com/avanibhide30/se-project-hms/blob/main/backend/src/index.ts) (Express API), [`backend/src/prisma.ts`](https://github.com/avanibhide30/se-project-hms/blob/main/backend/src/prisma.ts) (Prisma data access), [`frontend/src/App.tsx`](https://github.com/avanibhide30/se-project-hms/blob/main/frontend/src/App.tsx) (Role-based pages), [`backend/src/middleware/auth.ts`](https://github.com/avanibhide30/se-project-hms/blob/main/backend/src/middleware/auth.ts) (Authentication and roles)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Web application"]
  node_web_routes["Role-based pages<br/>[App.tsx]"]
  node_auth_context["Session context<br/>[AuthContext.tsx]"]
  node_student_pages["Student services"]
  node_staff_pages["Staff portal<br/>[StaffPages.tsx]"]
  node_api_client["API client<br/>[api.ts]"]
end

subgraph group_backend["API and access"]
  node_api_server["Express API<br/>[index.ts]"]
  node_auth_middleware["Authentication and roles<br/>[auth.ts]"]
  node_auth_routes["Login and identity<br/>[auth.ts]"]
  node_admin_routes["Administration<br/>[admin.ts]"]
  node_report_routes["Reports<br/>[reports.ts]"]
  node_audit["Audit logging<br/>[audit.ts]"]
  node_prisma["Prisma data access<br/>[prisma.ts]"]
  node_database[("Application database")]
end

subgraph group_residence["Residence operations"]
  node_application_routes["Applications<br/>[applications.ts]"]
  node_room_routes["Rooms<br/>[rooms.ts]"]
  node_allocation_routes["Bed allocations<br/>[allocations.ts]"]
end

subgraph group_services["Campus services"]
  node_fee_routes["Fees<br/>[fees.ts]"]
  node_payment_routes["Payments<br/>[payments.ts]"]
  node_visitor_routes["Visitors<br/>[visitors.ts]"]
  node_curfew_routes["Curfew<br/>[curfew.ts]"]
  node_outpass_routes["Outpasses and leave<br/>[outpasses.ts]"]
  node_notice_routes["Notices<br/>[notices.ts]"]
  node_notification_routes["Notifications<br/>[notifications.ts]"]
end

node_user(("Student or staff"))

node_user -->|"uses"| node_web_routes
node_web_routes -->|"checks session"| node_auth_context
node_web_routes -->|"routes students"| node_student_pages
node_web_routes -->|"routes staff"| node_staff_pages
node_student_pages -->|"requests data"| node_api_client
node_staff_pages -->|"requests data"| node_api_client
node_auth_context -->|"authenticates via"| node_api_client
node_api_client -->|"sends HTTP"| node_api_server
node_api_server -->|"dispatches"| node_auth_routes
node_api_server -->|"dispatches"| node_application_routes
node_api_server -->|"dispatches"| node_room_routes
node_api_server -->|"dispatches"| node_allocation_routes
node_api_server -->|"dispatches"| node_fee_routes
node_api_server -->|"dispatches"| node_payment_routes
node_api_server -->|"dispatches"| node_visitor_routes
node_api_server -->|"dispatches"| node_curfew_routes
node_api_server -->|"dispatches"| node_outpass_routes
node_api_server -->|"dispatches"| node_notice_routes
node_api_server -->|"dispatches"| node_notification_routes
node_api_server -->|"dispatches"| node_admin_routes
node_api_server -->|"dispatches"| node_report_routes
node_application_routes -->|"checks roles"| node_auth_middleware
node_auth_routes -->|"uses authentication"| node_auth_middleware
node_application_routes -->|"reads and writes"| node_prisma
node_room_routes -->|"reads and writes"| node_prisma
node_allocation_routes -->|"reads and writes"| node_prisma
node_fee_routes -->|"reads and writes"| node_prisma
node_payment_routes -->|"reads and writes"| node_prisma
node_visitor_routes -->|"reads and writes"| node_prisma
node_curfew_routes -->|"reads and writes"| node_prisma
node_outpass_routes -->|"reads and writes"| node_prisma
node_admin_routes -->|"reads and writes"| node_prisma
node_auth_middleware -->|"loads user"| node_prisma
node_auth_middleware -.->|"records actions"| node_audit
node_prisma -.->|"persists records"| node_database

click node_web_routes "https://github.com/avanibhide30/se-project-hms/blob/main/frontend/src/App.tsx"
click node_auth_context "https://github.com/avanibhide30/se-project-hms/blob/main/frontend/src/context/AuthContext.tsx"
click node_student_pages "https://github.com/avanibhide30/se-project-hms/tree/main/frontend/src/pages/student"
click node_staff_pages "https://github.com/avanibhide30/se-project-hms/blob/main/frontend/src/pages/staff/StaffPages.tsx"
click node_api_client "https://github.com/avanibhide30/se-project-hms/blob/main/frontend/src/services/api.ts"
click node_api_server "https://github.com/avanibhide30/se-project-hms/blob/main/backend/src/index.ts"
click node_auth_middleware "https://github.com/avanibhide30/se-project-hms/blob/main/backend/src/middleware/auth.ts"
click node_auth_routes "https://github.com/avanibhide30/se-project-hms/blob/main/backend/src/routes/auth.ts"
click node_application_routes "https://github.com/avanibhide30/se-project-hms/blob/main/backend/src/routes/applications.ts"
click node_room_routes "https://github.com/avanibhide30/se-project-hms/blob/main/backend/src/routes/rooms.ts"
click node_allocation_routes "https://github.com/avanibhide30/se-project-hms/blob/main/backend/src/routes/allocations.ts"
click node_fee_routes "https://github.com/avanibhide30/se-project-hms/blob/main/backend/src/routes/fees.ts"
click node_payment_routes "https://github.com/avanibhide30/se-project-hms/blob/main/backend/src/routes/payments.ts"
click node_visitor_routes "https://github.com/avanibhide30/se-project-hms/blob/main/backend/src/routes/visitors.ts"
click node_curfew_routes "https://github.com/avanibhide30/se-project-hms/blob/main/backend/src/routes/curfew.ts"
click node_outpass_routes "https://github.com/avanibhide30/se-project-hms/blob/main/backend/src/routes/outpasses.ts"
click node_notice_routes "https://github.com/avanibhide30/se-project-hms/blob/main/backend/src/routes/notices.ts"
click node_notification_routes "https://github.com/avanibhide30/se-project-hms/blob/main/backend/src/routes/notifications.ts"
click node_admin_routes "https://github.com/avanibhide30/se-project-hms/blob/main/backend/src/routes/admin.ts"
click node_report_routes "https://github.com/avanibhide30/se-project-hms/blob/main/backend/src/routes/reports.ts"
click node_audit "https://github.com/avanibhide30/se-project-hms/blob/main/backend/src/middleware/audit.ts"
click node_prisma "https://github.com/avanibhide30/se-project-hms/blob/main/backend/src/prisma.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_web_routes,node_auth_context,node_student_pages,node_staff_pages,node_api_client toneBlue
class node_api_server,node_auth_middleware,node_auth_routes,node_admin_routes,node_report_routes,node_audit,node_prisma,node_database toneAmber
class node_application_routes,node_room_routes,node_allocation_routes toneMint
class node_fee_routes,node_payment_routes,node_visitor_routes,node_curfew_routes,node_outpass_routes,node_notice_routes,node_notification_routes toneRose
class node_user toneIndigo
```

## Components

### Web application

- [Role-based pages](https://github.com/avanibhide30/se-project-hms/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [Session context](https://github.com/avanibhide30/se-project-hms/blob/main/frontend/src/context/AuthContext.tsx): `frontend/src/context/AuthContext.tsx`
- [Student services](https://github.com/avanibhide30/se-project-hms/tree/main/frontend/src/pages/student): `frontend/src/pages/student`
- [Staff portal](https://github.com/avanibhide30/se-project-hms/blob/main/frontend/src/pages/staff/StaffPages.tsx): `frontend/src/pages/staff/StaffPages.tsx`
- [API client](https://github.com/avanibhide30/se-project-hms/blob/main/frontend/src/services/api.ts): `frontend/src/services/api.ts`

### API and access

- [Express API](https://github.com/avanibhide30/se-project-hms/blob/main/backend/src/index.ts): `backend/src/index.ts`
- [Authentication and roles](https://github.com/avanibhide30/se-project-hms/blob/main/backend/src/middleware/auth.ts): `backend/src/middleware/auth.ts`
- [Login and identity](https://github.com/avanibhide30/se-project-hms/blob/main/backend/src/routes/auth.ts): `backend/src/routes/auth.ts`
- [Administration](https://github.com/avanibhide30/se-project-hms/blob/main/backend/src/routes/admin.ts): `backend/src/routes/admin.ts`
- [Reports](https://github.com/avanibhide30/se-project-hms/blob/main/backend/src/routes/reports.ts): `backend/src/routes/reports.ts`
- [Audit logging](https://github.com/avanibhide30/se-project-hms/blob/main/backend/src/middleware/audit.ts): `backend/src/middleware/audit.ts`
- [Prisma data access](https://github.com/avanibhide30/se-project-hms/blob/main/backend/src/prisma.ts): `backend/src/prisma.ts`
- **Application database**

### Residence operations

- [Applications](https://github.com/avanibhide30/se-project-hms/blob/main/backend/src/routes/applications.ts): `backend/src/routes/applications.ts`
- [Rooms](https://github.com/avanibhide30/se-project-hms/blob/main/backend/src/routes/rooms.ts): `backend/src/routes/rooms.ts`
- [Bed allocations](https://github.com/avanibhide30/se-project-hms/blob/main/backend/src/routes/allocations.ts): `backend/src/routes/allocations.ts`

### Campus services

- [Fees](https://github.com/avanibhide30/se-project-hms/blob/main/backend/src/routes/fees.ts): `backend/src/routes/fees.ts`
- [Payments](https://github.com/avanibhide30/se-project-hms/blob/main/backend/src/routes/payments.ts): `backend/src/routes/payments.ts`
- [Visitors](https://github.com/avanibhide30/se-project-hms/blob/main/backend/src/routes/visitors.ts): `backend/src/routes/visitors.ts`
- [Curfew](https://github.com/avanibhide30/se-project-hms/blob/main/backend/src/routes/curfew.ts): `backend/src/routes/curfew.ts`
- [Outpasses and leave](https://github.com/avanibhide30/se-project-hms/blob/main/backend/src/routes/outpasses.ts): `backend/src/routes/outpasses.ts`
- [Notices](https://github.com/avanibhide30/se-project-hms/blob/main/backend/src/routes/notices.ts): `backend/src/routes/notices.ts`
- [Notifications](https://github.com/avanibhide30/se-project-hms/blob/main/backend/src/routes/notifications.ts): `backend/src/routes/notifications.ts`

### Other components

- **Student or staff**

## Connections

- Student or staff → Role-based pages: uses (evidence: `frontend/src/App.tsx`)
- Role-based pages → Session context: checks session (evidence: `frontend/src/App.tsx`)
- Role-based pages → Student services: routes students (evidence: `frontend/src/App.tsx`)
- Role-based pages → Staff portal: routes staff (evidence: `frontend/src/App.tsx`)
- Student services → API client: requests data (evidence: `frontend/src/pages/student/ApplicationPage.tsx`)
- Staff portal → API client: requests data (evidence: `frontend/src/pages/staff/StaffPages.tsx`)
- Session context → API client: authenticates via (evidence: `frontend/src/context/AuthContext.tsx`)
- API client → Express API: sends HTTP (evidence: `frontend/src/services/api.ts`)
- Express API → Login and identity: dispatches (evidence: `backend/src/index.ts`)
- Express API → Applications: dispatches (evidence: `backend/src/index.ts`)
- Express API → Rooms: dispatches (evidence: `backend/src/index.ts`)
- Express API → Bed allocations: dispatches (evidence: `backend/src/index.ts`)
- Express API → Fees: dispatches (evidence: `backend/src/index.ts`)
- Express API → Payments: dispatches (evidence: `backend/src/index.ts`)
- Express API → Visitors: dispatches (evidence: `backend/src/index.ts`)
- Express API → Curfew: dispatches (evidence: `backend/src/index.ts`)
- Express API → Outpasses and leave: dispatches (evidence: `backend/src/index.ts`)
- Express API → Notices: dispatches (evidence: `backend/src/index.ts`)
- Express API → Notifications: dispatches (evidence: `backend/src/index.ts`)
- Express API → Administration: dispatches (evidence: `backend/src/index.ts`)
- Express API → Reports: dispatches (evidence: `backend/src/index.ts`)
- Applications → Authentication and roles: checks roles (evidence: `backend/src/routes/applications.ts`)
- Login and identity → Authentication and roles: uses authentication (evidence: `backend/src/routes/auth.ts`)
- Applications → Prisma data access: reads and writes (evidence: `backend/src/routes/applications.ts`)
- Rooms → Prisma data access: reads and writes (evidence: `backend/src/routes/rooms.ts`)
- Bed allocations → Prisma data access: reads and writes (evidence: `backend/src/routes/allocations.ts`)
- Fees → Prisma data access: reads and writes (evidence: `backend/src/routes/fees.ts`)
- Payments → Prisma data access: reads and writes (evidence: `backend/src/routes/payments.ts`)
- Visitors → Prisma data access: reads and writes (evidence: `backend/src/routes/visitors.ts`)
- Curfew → Prisma data access: reads and writes (evidence: `backend/src/routes/curfew.ts`)
- Outpasses and leave → Prisma data access: reads and writes (evidence: `backend/src/routes/outpasses.ts`)
- Administration → Prisma data access: reads and writes (evidence: `backend/src/routes/admin.ts`)
- Authentication and roles → Prisma data access: loads user (evidence: `backend/src/middleware/auth.ts`)
- Authentication and roles → Audit logging: records actions
- Prisma data access → Application database: persists records
