# abihajibbran1-lang/hostel-management-system architecture

> Architecture diagram of the GitHub repository abihajibbran1-lang/hostel-management-system, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-24). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/abihajibbran1-lang/hostel-management-system
- Repository: https://github.com/abihajibbran1-lang/hostel-management-system

## Overview

This is a Next.js hostel-management application whose implemented slices cover sign-in, resident complaints, personal schedules, and notifications. The user-facing workflow runs from a resident using a page or API request, through endpoint handlers and domain services, to repository-backed persistence; authentication middleware supports protected requests. The README also describes an independently run worker, but says it is only a five-minute polling foundation with no domain actions. Some page-to-component and UI-to-API wiring was not shown, so those links are omitted rather than inferred.

Main entry points: [`src/business/modules/schedules/personal-schedule-service.ts`](https://github.com/abihajibbran1-lang/hostel-management-system/blob/main/src/business/modules/schedules/personal-schedule-service.ts) (Schedule service), [`src/business/modules/complaints/complaint-service.ts`](https://github.com/abihajibbran1-lang/hostel-management-system/blob/main/src/business/modules/complaints/complaint-service.ts) (Complaint service), [`src/business/notifications/notification-service.ts`](https://github.com/abihajibbran1-lang/hostel-management-system/blob/main/src/business/notifications/notification-service.ts) (Notification service), [`src/data/database/prisma.ts`](https://github.com/abihajibbran1-lang/hostel-management-system/blob/main/src/data/database/prisma.ts) (Prisma client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_presentation["Resident interface"]
  node_complaints_page["Complaints page<br/>[page.tsx]"]
  node_complaint_ui["Complaint UI"]
  node_schedules_page["Schedule page<br/>[page.tsx]"]
  node_schedule_ui["Schedule UI"]
  node_notifications_page["Notifications page<br/>[page.tsx]"]
  node_notification_ui["Notification inbox UI"]
end

subgraph group_api["HTTP endpoints"]
  node_auth_login["Login handler<br/>[login-handler.ts]"]
  node_auth_logout["Logout handler<br/>[logout-handler.ts]"]
  node_middleware["Auth middleware<br/>[middleware.ts]"]
  node_complaint_collection["Complaint collection"]
  node_complaint_item["Complaint item"]
  node_complaint_auth["Complaint request auth"]
  node_schedule_collection["Schedule collection"]
  node_schedule_item["Schedule item"]
  node_schedule_auth["Schedule request auth"]
  node_notification_inbox["Notification inbox endpoint"]
  node_notification_read["Mark-read endpoint"]
end

subgraph group_business["Domain services"]
  node_auth_service["Authentication service<br/>[auth-service.ts]"]
  node_jwt["JWT service<br/>[jwt-service.ts]"]
  node_auth_cookie["Auth cookie<br/>[auth-cookie.ts]"]
  node_auth_authorization["Authorization"]
  node_complaint_service["Complaint service"]
  node_complaint_contract["Complaint contract"]
  node_schedule_service["Schedule service"]
  node_schedule_contract["Schedule contract"]
  node_schedule_time["Schedule time rules"]
  node_notification_service["Notification service"]
  node_notification_contract["Notification contract"]
end

subgraph group_data["Persistence"]
  node_auth_repo["Auth user repository"]
  node_complaint_repo["Complaint repository"]
  node_schedule_repo["Schedule repository"]
  node_notification_repo["Notification repository"]
  node_prisma_client["Prisma client<br/>data access"]
end

node_resident(("Resident"))

node_resident -.->|"uses"| node_complaints_page
node_resident -.->|"uses"| node_schedules_page
node_resident -.->|"uses"| node_notifications_page
node_auth_login -->|"authenticates"| node_auth_service
node_auth_login -->|"sets cookie"| node_auth_cookie
node_auth_login -->|"creates token"| node_jwt
node_auth_logout -->|"clears cookie"| node_auth_cookie
node_middleware -->|"reads cookie"| node_auth_cookie
node_middleware -->|"verifies token"| node_jwt
node_middleware -->|"checks account"| node_auth_repo
node_auth_service -->|"looks up users"| node_auth_repo
node_complaint_collection -->|"runs requests"| node_complaint_service
node_complaint_item -->|"runs requests"| node_complaint_service
node_complaint_collection -->|"checks identity"| node_complaint_auth
node_complaint_service -->|"reads and writes"| node_complaint_repo
node_complaint_service -->|"uses types"| node_complaint_contract
node_schedule_collection -->|"runs requests"| node_schedule_service
node_schedule_item -->|"runs requests"| node_schedule_service
node_schedule_collection -->|"checks identity"| node_schedule_auth
node_schedule_service -->|"reads and writes"| node_schedule_repo
node_schedule_service -->|"validates input"| node_schedule_contract
node_schedule_service -->|"calculates day bounds"| node_schedule_time
node_notification_inbox -->|"lists inbox"| node_notification_service
node_notification_read -->|"marks read"| node_notification_service
node_notification_service -->|"reads and writes"| node_notification_repo
node_notification_service -->|"validates dispatch"| node_notification_contract
node_auth_repo -->|"queries"| node_prisma_client
node_complaint_repo -->|"queries"| node_prisma_client
node_schedule_repo -->|"queries"| node_prisma_client
node_notification_repo -->|"queries"| node_prisma_client

click node_complaints_page "https://github.com/abihajibbran1-lang/hostel-management-system/blob/main/src/app/complaints/page.tsx"
click node_complaint_ui "https://github.com/abihajibbran1-lang/hostel-management-system/blob/main/src/components/complaints/complaint-submission.tsx"
click node_schedules_page "https://github.com/abihajibbran1-lang/hostel-management-system/blob/main/src/app/schedule/page.tsx"
click node_schedule_ui "https://github.com/abihajibbran1-lang/hostel-management-system/blob/main/src/components/schedules/personal-schedule.tsx"
click node_notifications_page "https://github.com/abihajibbran1-lang/hostel-management-system/blob/main/src/app/notifications/page.tsx"
click node_notification_ui "https://github.com/abihajibbran1-lang/hostel-management-system/blob/main/src/components/notifications/notification-inbox.tsx"
click node_auth_login "https://github.com/abihajibbran1-lang/hostel-management-system/blob/main/src/app/api/auth/login/login-handler.ts"
click node_auth_logout "https://github.com/abihajibbran1-lang/hostel-management-system/blob/main/src/app/api/auth/logout/logout-handler.ts"
click node_middleware "https://github.com/abihajibbran1-lang/hostel-management-system/blob/main/src/middleware.ts"
click node_complaint_collection "https://github.com/abihajibbran1-lang/hostel-management-system/blob/main/src/app/api/complaints/complaint-collection-handler.ts"
click node_complaint_item "https://github.com/abihajibbran1-lang/hostel-management-system/blob/main/src/app/api/complaints/%5Bid%5D/complaint-item-handler.ts"
click node_complaint_auth "https://github.com/abihajibbran1-lang/hostel-management-system/blob/main/src/app/api/complaints/complaint-request-auth.ts"
click node_schedule_collection "https://github.com/abihajibbran1-lang/hostel-management-system/blob/main/src/app/api/schedules/schedule-collection-handler.ts"
click node_schedule_item "https://github.com/abihajibbran1-lang/hostel-management-system/blob/main/src/app/api/schedules/%5Bid%5D/schedule-item-handler.ts"
click node_schedule_auth "https://github.com/abihajibbran1-lang/hostel-management-system/blob/main/src/app/api/schedules/schedule-request-auth.ts"
click node_notification_inbox "https://github.com/abihajibbran1-lang/hostel-management-system/blob/main/src/app/api/notifications/notification-inbox-handler.ts"
click node_notification_read "https://github.com/abihajibbran1-lang/hostel-management-system/blob/main/src/app/api/notifications/%5Bid%5D/read/mark-read-handler.ts"
click node_auth_service "https://github.com/abihajibbran1-lang/hostel-management-system/blob/main/src/business/modules/auth/auth-service.ts"
click node_jwt "https://github.com/abihajibbran1-lang/hostel-management-system/blob/main/src/business/modules/auth/jwt-service.ts"
click node_auth_cookie "https://github.com/abihajibbran1-lang/hostel-management-system/blob/main/src/business/modules/auth/auth-cookie.ts"
click node_auth_authorization "https://github.com/abihajibbran1-lang/hostel-management-system/blob/main/src/business/modules/auth/auth-authorization.ts"
click node_complaint_service "https://github.com/abihajibbran1-lang/hostel-management-system/blob/main/src/business/modules/complaints/complaint-service.ts"
click node_complaint_contract "https://github.com/abihajibbran1-lang/hostel-management-system/blob/main/src/business/modules/complaints/complaint-contract.ts"
click node_schedule_service "https://github.com/abihajibbran1-lang/hostel-management-system/blob/main/src/business/modules/schedules/personal-schedule-service.ts"
click node_schedule_contract "https://github.com/abihajibbran1-lang/hostel-management-system/blob/main/src/business/modules/schedules/personal-schedule-contract.ts"
click node_schedule_time "https://github.com/abihajibbran1-lang/hostel-management-system/blob/main/src/business/modules/schedules/personal-schedule-time.ts"
click node_notification_service "https://github.com/abihajibbran1-lang/hostel-management-system/blob/main/src/business/notifications/notification-service.ts"
click node_notification_contract "https://github.com/abihajibbran1-lang/hostel-management-system/blob/main/src/business/notifications/notification-contract.ts"
click node_auth_repo "https://github.com/abihajibbran1-lang/hostel-management-system/blob/main/src/data/repositories/auth/auth-user-repository.ts"
click node_complaint_repo "https://github.com/abihajibbran1-lang/hostel-management-system/blob/main/src/data/repositories/complaints/complaint-repository.ts"
click node_schedule_repo "https://github.com/abihajibbran1-lang/hostel-management-system/blob/main/src/data/repositories/schedules/personal-schedule-repository.ts"
click node_notification_repo "https://github.com/abihajibbran1-lang/hostel-management-system/blob/main/src/data/repositories/notifications/notification-repository.ts"
click node_prisma_client "https://github.com/abihajibbran1-lang/hostel-management-system/blob/main/src/data/database/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_complaints_page,node_complaint_ui,node_schedules_page,node_schedule_ui,node_notifications_page,node_notification_ui toneBlue
class node_auth_login,node_auth_logout,node_middleware,node_complaint_collection,node_complaint_item,node_complaint_auth,node_schedule_collection,node_schedule_item,node_schedule_auth,node_notification_inbox,node_notification_read toneAmber
class node_auth_service,node_jwt,node_auth_cookie,node_auth_authorization,node_complaint_service,node_complaint_contract,node_schedule_service,node_schedule_contract,node_schedule_time,node_notification_service,node_notification_contract toneMint
class node_auth_repo,node_complaint_repo,node_schedule_repo,node_notification_repo,node_prisma_client toneRose
class node_resident toneIndigo
```

## Components

### Resident interface

- [Complaints page](https://github.com/abihajibbran1-lang/hostel-management-system/blob/main/src/app/complaints/page.tsx): `src/app/complaints/page.tsx`
- [Complaint UI](https://github.com/abihajibbran1-lang/hostel-management-system/blob/main/src/components/complaints/complaint-submission.tsx): `src/components/complaints/complaint-submission.tsx`
- [Schedule page](https://github.com/abihajibbran1-lang/hostel-management-system/blob/main/src/app/schedule/page.tsx): `src/app/schedule/page.tsx`
- [Schedule UI](https://github.com/abihajibbran1-lang/hostel-management-system/blob/main/src/components/schedules/personal-schedule.tsx): `src/components/schedules/personal-schedule.tsx`
- [Notifications page](https://github.com/abihajibbran1-lang/hostel-management-system/blob/main/src/app/notifications/page.tsx): `src/app/notifications/page.tsx`
- [Notification inbox UI](https://github.com/abihajibbran1-lang/hostel-management-system/blob/main/src/components/notifications/notification-inbox.tsx): `src/components/notifications/notification-inbox.tsx`

### HTTP endpoints

- [Login handler](https://github.com/abihajibbran1-lang/hostel-management-system/blob/main/src/app/api/auth/login/login-handler.ts): `src/app/api/auth/login/login-handler.ts`
- [Logout handler](https://github.com/abihajibbran1-lang/hostel-management-system/blob/main/src/app/api/auth/logout/logout-handler.ts): `src/app/api/auth/logout/logout-handler.ts`
- [Auth middleware](https://github.com/abihajibbran1-lang/hostel-management-system/blob/main/src/middleware.ts): `src/middleware.ts`
- [Complaint collection](https://github.com/abihajibbran1-lang/hostel-management-system/blob/main/src/app/api/complaints/complaint-collection-handler.ts): `src/app/api/complaints/complaint-collection-handler.ts`
- [Complaint item](https://github.com/abihajibbran1-lang/hostel-management-system/blob/main/src/app/api/complaints/%5Bid%5D/complaint-item-handler.ts): `src/app/api/complaints/[id]/complaint-item-handler.ts`
- [Complaint request auth](https://github.com/abihajibbran1-lang/hostel-management-system/blob/main/src/app/api/complaints/complaint-request-auth.ts): `src/app/api/complaints/complaint-request-auth.ts`
- [Schedule collection](https://github.com/abihajibbran1-lang/hostel-management-system/blob/main/src/app/api/schedules/schedule-collection-handler.ts): `src/app/api/schedules/schedule-collection-handler.ts`
- [Schedule item](https://github.com/abihajibbran1-lang/hostel-management-system/blob/main/src/app/api/schedules/%5Bid%5D/schedule-item-handler.ts): `src/app/api/schedules/[id]/schedule-item-handler.ts`
- [Schedule request auth](https://github.com/abihajibbran1-lang/hostel-management-system/blob/main/src/app/api/schedules/schedule-request-auth.ts): `src/app/api/schedules/schedule-request-auth.ts`
- [Notification inbox endpoint](https://github.com/abihajibbran1-lang/hostel-management-system/blob/main/src/app/api/notifications/notification-inbox-handler.ts): `src/app/api/notifications/notification-inbox-handler.ts`
- [Mark-read endpoint](https://github.com/abihajibbran1-lang/hostel-management-system/blob/main/src/app/api/notifications/%5Bid%5D/read/mark-read-handler.ts): `src/app/api/notifications/[id]/read/mark-read-handler.ts`

### Domain services

- [Authentication service](https://github.com/abihajibbran1-lang/hostel-management-system/blob/main/src/business/modules/auth/auth-service.ts): `src/business/modules/auth/auth-service.ts`
- [JWT service](https://github.com/abihajibbran1-lang/hostel-management-system/blob/main/src/business/modules/auth/jwt-service.ts): `src/business/modules/auth/jwt-service.ts`
- [Auth cookie](https://github.com/abihajibbran1-lang/hostel-management-system/blob/main/src/business/modules/auth/auth-cookie.ts): `src/business/modules/auth/auth-cookie.ts`
- [Authorization](https://github.com/abihajibbran1-lang/hostel-management-system/blob/main/src/business/modules/auth/auth-authorization.ts): `src/business/modules/auth/auth-authorization.ts`
- [Complaint service](https://github.com/abihajibbran1-lang/hostel-management-system/blob/main/src/business/modules/complaints/complaint-service.ts): `src/business/modules/complaints/complaint-service.ts`
- [Complaint contract](https://github.com/abihajibbran1-lang/hostel-management-system/blob/main/src/business/modules/complaints/complaint-contract.ts): `src/business/modules/complaints/complaint-contract.ts`
- [Schedule service](https://github.com/abihajibbran1-lang/hostel-management-system/blob/main/src/business/modules/schedules/personal-schedule-service.ts): `src/business/modules/schedules/personal-schedule-service.ts`
- [Schedule contract](https://github.com/abihajibbran1-lang/hostel-management-system/blob/main/src/business/modules/schedules/personal-schedule-contract.ts): `src/business/modules/schedules/personal-schedule-contract.ts`
- [Schedule time rules](https://github.com/abihajibbran1-lang/hostel-management-system/blob/main/src/business/modules/schedules/personal-schedule-time.ts): `src/business/modules/schedules/personal-schedule-time.ts`
- [Notification service](https://github.com/abihajibbran1-lang/hostel-management-system/blob/main/src/business/notifications/notification-service.ts): `src/business/notifications/notification-service.ts`
- [Notification contract](https://github.com/abihajibbran1-lang/hostel-management-system/blob/main/src/business/notifications/notification-contract.ts): `src/business/notifications/notification-contract.ts`

### Persistence

- [Auth user repository](https://github.com/abihajibbran1-lang/hostel-management-system/blob/main/src/data/repositories/auth/auth-user-repository.ts): `src/data/repositories/auth/auth-user-repository.ts`
- [Complaint repository](https://github.com/abihajibbran1-lang/hostel-management-system/blob/main/src/data/repositories/complaints/complaint-repository.ts): `src/data/repositories/complaints/complaint-repository.ts`
- [Schedule repository](https://github.com/abihajibbran1-lang/hostel-management-system/blob/main/src/data/repositories/schedules/personal-schedule-repository.ts): `src/data/repositories/schedules/personal-schedule-repository.ts`
- [Notification repository](https://github.com/abihajibbran1-lang/hostel-management-system/blob/main/src/data/repositories/notifications/notification-repository.ts): `src/data/repositories/notifications/notification-repository.ts`
- [Prisma client](https://github.com/abihajibbran1-lang/hostel-management-system/blob/main/src/data/database/prisma.ts): data access · `src/data/database/prisma.ts`

### Other components

- **Resident**

## Connections

- Resident → Complaints page: uses
- Resident → Schedule page: uses
- Resident → Notifications page: uses
- Login handler → Authentication service: authenticates (evidence: `src/app/api/auth/login/login-handler.ts`)
- Login handler → Auth cookie: sets cookie (evidence: `src/app/api/auth/login/login-handler.ts`)
- Login handler → JWT service: creates token (evidence: `src/app/api/auth/login/login-handler.ts`)
- Logout handler → Auth cookie: clears cookie (evidence: `src/app/api/auth/logout/logout-handler.ts`)
- Auth middleware → Auth cookie: reads cookie (evidence: `src/middleware.ts`)
- Auth middleware → JWT service: verifies token (evidence: `src/middleware.ts`)
- Auth middleware → Auth user repository: checks account (evidence: `src/middleware.ts`)
- Authentication service → Auth user repository: looks up users (evidence: `src/business/modules/auth/auth-service.ts`)
- Complaint collection → Complaint service: runs requests (evidence: `src/app/api/complaints/complaint-collection-handler.ts`)
- Complaint item → Complaint service: runs requests (evidence: `src/app/api/complaints/[id]/complaint-item-handler.ts`)
- Complaint collection → Complaint request auth: checks identity (evidence: `src/app/api/complaints/complaint-collection-handler.ts`)
- Complaint service → Complaint repository: reads and writes (evidence: `src/business/modules/complaints/complaint-service.ts`)
- Complaint service → Complaint contract: uses types (evidence: `src/business/modules/complaints/complaint-service.ts`)
- Schedule collection → Schedule service: runs requests (evidence: `src/app/api/schedules/schedule-collection-handler.ts`)
- Schedule item → Schedule service: runs requests (evidence: `src/app/api/schedules/[id]/schedule-item-handler.ts`)
- Schedule collection → Schedule request auth: checks identity (evidence: `src/app/api/schedules/schedule-collection-handler.ts`)
- Schedule service → Schedule repository: reads and writes (evidence: `src/business/modules/schedules/personal-schedule-service.ts`)
- Schedule service → Schedule contract: validates input (evidence: `src/business/modules/schedules/personal-schedule-service.ts`)
- Schedule service → Schedule time rules: calculates day bounds (evidence: `src/business/modules/schedules/personal-schedule-service.ts`)
- Notification inbox endpoint → Notification service: lists inbox (evidence: `src/app/api/notifications/notification-inbox-handler.ts`)
- Mark-read endpoint → Notification service: marks read (evidence: `src/app/api/notifications/[id]/read/mark-read-handler.ts`)
- Notification service → Notification repository: reads and writes (evidence: `src/business/notifications/notification-service.ts`)
- Notification service → Notification contract: validates dispatch (evidence: `src/business/notifications/notification-service.ts`)
- Auth user repository → Prisma client: queries (evidence: `src/data/repositories/auth/auth-user-repository.ts`)
- Complaint repository → Prisma client: queries (evidence: `src/data/repositories/complaints/complaint-repository.ts`)
- Schedule repository → Prisma client: queries (evidence: `src/data/repositories/schedules/personal-schedule-repository.ts`)
- Notification repository → Prisma client: queries (evidence: `src/data/repositories/notifications/notification-repository.ts`)
