# orei1i/khoan-projectwdp301 architecture

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

- Interactive diagram: https://gitdiagram.com/orei1i/khoan-projectwdp301
- Repository: https://github.com/orei1i/khoan-projectwdp301

## Overview

KhoAn is a multi-branch self-storage rental platform: customers discover units, reserve and pay, sign contracts, and manage their rental; branch staff and managers handle check-in through move-out, while operations and administrators govern the chain. Web and mobile clients use a shared REST API, with shared business rules across the applications. Edges reflect README-documented architecture and the supplied source excerpts/index; many feature internals were not sampled, so undocumented calls are omitted.

Main entry points: [`BE/src/routes.ts`](https://github.com/orei1i/khoan-projectwdp301/blob/master/BE/src/routes.ts) (REST API), [`BE/src/shared/db/models.ts`](https://github.com/orei1i/khoan-projectwdp301/blob/master/BE/src/shared/db/models.ts) (MongoDB models), [`Webapp/src/app/(public)/page.tsx`](https://github.com/orei1i/khoan-projectwdp301/blob/master/Webapp/src/app/(public)/page.tsx) (Web app), [`BE/src/features/payments/payments.routes.ts`](https://github.com/orei1i/khoan-projectwdp301/blob/master/BE/src/features/payments/payments.routes.ts) (Payments)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_clients["Customer apps"]
  node_web["Web app<br/>[page.tsx]"]
  node_mobile["Mobile app<br/>[App.tsx]"]
end

subgraph group_operations["Rental operations"]
  node_facility["Facility discovery"]
  node_reservation["Reservations"]
  node_payments["Payments<br/>[payments.routes.ts]"]
  node_contracts["Contracts"]
  node_checkin["Check-in and intake<br/>[intake.routes.ts]"]
  node_rentalcare["Rental services"]
  node_support["Support and claims<br/>[tickets.routes.ts]"]
end

subgraph group_governance["Staff and governance"]
  node_staffops["Branch workflows<br/>[page.tsx]"]
  node_management["Branch management<br/>[page.tsx]"]
  node_chainops["Chain operations<br/>[page.tsx]"]
  node_admin["Administration<br/>[page.tsx]"]
end

subgraph group_platform["API platform"]
  node_api["REST API<br/>[routes.ts]"]
  node_identity["Token and access control<br/>[authenticate.ts]"]
  node_models[("MongoDB models<br/>[models.ts]")]
end

subgraph group_shared["Shared domain"]
  node_rules["Shared business rules<br/>[entities.ts]"]
end

node_customer(("Customer"))
node_staff(("Branch staff"))
node_firebase{{"Firebase Auth"}}
node_database[("MongoDB Atlas")]
node_email{{"Email service"}}

node_customer -->|"uses"| node_web
node_customer -->|"uses"| node_mobile
node_staff -->|"uses"| node_web
node_web -->|"signs in"| node_firebase
node_mobile -->|"signs in"| node_firebase
node_web -->|"REST requests"| node_api
node_mobile -->|"REST requests"| node_api
node_api -->|"authenticates"| node_identity
node_identity -->|"verifies token"| node_firebase
node_identity -->|"loads profile"| node_models
node_api -->|"routes requests"| node_facility
node_api -->|"routes requests"| node_reservation
node_api -->|"routes requests"| node_payments
node_api -->|"routes requests"| node_contracts
node_api -->|"routes requests"| node_support
node_reservation -->|"reads and writes"| node_models
node_reservation -->|"starts settlement"| node_payments
node_reservation -->|"checks in"| node_checkin
node_contracts -->|"loads payment data"| node_payments
node_contracts -->|"delegates intake"| node_checkin
node_contracts -->|"delegates access"| node_rentalcare
node_payments -->|"records transactions"| node_models
node_payments -->|"notifies staff"| node_email
node_checkin -->|"updates intake"| node_models
node_support -->|"stores tickets"| node_models
node_models -->|"persists data"| node_database
node_staffops -->|"operates workflows"| node_api
node_management -->|"manages rentals"| node_api
node_chainops -->|"governs chain"| node_api
node_admin -->|"administers users"| node_api
node_web -->|"shares domain rules"| node_rules
node_mobile -->|"shares domain rules"| node_rules
node_api -->|"uses domain rules"| node_rules

click node_web "https://github.com/orei1i/khoan-projectwdp301/blob/master/Webapp/src/app/(public)/page.tsx"
click node_mobile "https://github.com/orei1i/khoan-projectwdp301/blob/master/Mobile/React-Native/App.tsx"
click node_facility "https://github.com/orei1i/khoan-projectwdp301/blob/master/BE/src/features/facilities/facilities.routes.ts"
click node_reservation "https://github.com/orei1i/khoan-projectwdp301/blob/master/BE/src/features/reservations/reservations.routes.ts"
click node_payments "https://github.com/orei1i/khoan-projectwdp301/blob/master/BE/src/features/payments/payments.routes.ts"
click node_contracts "https://github.com/orei1i/khoan-projectwdp301/blob/master/BE/src/features/contracts/contracts.routes.ts"
click node_checkin "https://github.com/orei1i/khoan-projectwdp301/blob/master/BE/src/features/intake/intake.routes.ts"
click node_rentalcare "https://github.com/orei1i/khoan-projectwdp301/blob/master/BE/src/features/contracts/contracts.routes.ts"
click node_support "https://github.com/orei1i/khoan-projectwdp301/blob/master/BE/src/features/tickets/tickets.routes.ts"
click node_staffops "https://github.com/orei1i/khoan-projectwdp301/blob/master/Webapp/src/app/staff/check-in/page.tsx"
click node_management "https://github.com/orei1i/khoan-projectwdp301/blob/master/Webapp/src/app/manager/contracts/page.tsx"
click node_chainops "https://github.com/orei1i/khoan-projectwdp301/blob/master/Webapp/src/app/ops/approvals/page.tsx"
click node_admin "https://github.com/orei1i/khoan-projectwdp301/blob/master/Webapp/src/app/admin/users/page.tsx"
click node_api "https://github.com/orei1i/khoan-projectwdp301/blob/master/BE/src/routes.ts"
click node_identity "https://github.com/orei1i/khoan-projectwdp301/blob/master/BE/src/shared/http/authenticate.ts"
click node_models "https://github.com/orei1i/khoan-projectwdp301/blob/master/BE/src/shared/db/models.ts"
click node_rules "https://github.com/orei1i/khoan-projectwdp301/blob/master/shared/src/entities.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,node_mobile toneBlue
class node_facility,node_reservation,node_payments,node_contracts,node_checkin,node_rentalcare,node_support,node_database toneAmber
class node_staffops,node_management,node_chainops,node_admin toneMint
class node_api,node_identity,node_models toneRose
class node_rules,node_customer,node_staff,node_firebase,node_email toneIndigo
```

## Components

### Customer apps

- [Web app](https://github.com/orei1i/khoan-projectwdp301/blob/master/Webapp/src/app/(public)/page.tsx): `Webapp/src/app/(public)/page.tsx`
- [Mobile app](https://github.com/orei1i/khoan-projectwdp301/blob/master/Mobile/React-Native/App.tsx): `Mobile/React-Native/App.tsx`

### Rental operations

- [Facility discovery](https://github.com/orei1i/khoan-projectwdp301/blob/master/BE/src/features/facilities/facilities.routes.ts): `BE/src/features/facilities/facilities.routes.ts`
- [Reservations](https://github.com/orei1i/khoan-projectwdp301/blob/master/BE/src/features/reservations/reservations.routes.ts): `BE/src/features/reservations/reservations.routes.ts`
- [Payments](https://github.com/orei1i/khoan-projectwdp301/blob/master/BE/src/features/payments/payments.routes.ts): `BE/src/features/payments/payments.routes.ts`
- [Contracts](https://github.com/orei1i/khoan-projectwdp301/blob/master/BE/src/features/contracts/contracts.routes.ts): `BE/src/features/contracts/contracts.routes.ts`
- [Check-in and intake](https://github.com/orei1i/khoan-projectwdp301/blob/master/BE/src/features/intake/intake.routes.ts): `BE/src/features/intake/intake.routes.ts`
- [Rental services](https://github.com/orei1i/khoan-projectwdp301/blob/master/BE/src/features/contracts/contracts.routes.ts): `BE/src/features/contracts/contracts.routes.ts`
- [Support and claims](https://github.com/orei1i/khoan-projectwdp301/blob/master/BE/src/features/tickets/tickets.routes.ts): `BE/src/features/tickets/tickets.routes.ts`

### Staff and governance

- [Branch workflows](https://github.com/orei1i/khoan-projectwdp301/blob/master/Webapp/src/app/staff/check-in/page.tsx): `Webapp/src/app/staff/check-in/page.tsx`
- [Branch management](https://github.com/orei1i/khoan-projectwdp301/blob/master/Webapp/src/app/manager/contracts/page.tsx): `Webapp/src/app/manager/contracts/page.tsx`
- [Chain operations](https://github.com/orei1i/khoan-projectwdp301/blob/master/Webapp/src/app/ops/approvals/page.tsx): `Webapp/src/app/ops/approvals/page.tsx`
- [Administration](https://github.com/orei1i/khoan-projectwdp301/blob/master/Webapp/src/app/admin/users/page.tsx): `Webapp/src/app/admin/users/page.tsx`

### API platform

- [REST API](https://github.com/orei1i/khoan-projectwdp301/blob/master/BE/src/routes.ts): `BE/src/routes.ts`
- [Token and access control](https://github.com/orei1i/khoan-projectwdp301/blob/master/BE/src/shared/http/authenticate.ts): `BE/src/shared/http/authenticate.ts`
- [MongoDB models](https://github.com/orei1i/khoan-projectwdp301/blob/master/BE/src/shared/db/models.ts): `BE/src/shared/db/models.ts`

### Shared domain

- [Shared business rules](https://github.com/orei1i/khoan-projectwdp301/blob/master/shared/src/entities.ts): `shared/src/entities.ts`

### Other components

- **Customer**
- **Branch staff**
- **Firebase Auth**
- **MongoDB Atlas**
- **Email service**

## Connections

- Customer → Web app: uses (evidence: `README.md`)
- Customer → Mobile app: uses (evidence: `README.md`)
- Branch staff → Web app: uses (evidence: `README.md`)
- Web app → Firebase Auth: signs in (evidence: `README.md`)
- Mobile app → Firebase Auth: signs in (evidence: `README.md`)
- Web app → REST API: REST requests (evidence: `README.md`)
- Mobile app → REST API: REST requests (evidence: `README.md`)
- REST API → Token and access control: authenticates (evidence: `BE/src/shared/http/authenticate.ts`)
- Token and access control → Firebase Auth: verifies token (evidence: `BE/src/shared/http/authenticate.ts`)
- Token and access control → MongoDB models: loads profile (evidence: `BE/src/shared/http/authenticate.ts`)
- REST API → Facility discovery: routes requests (evidence: `BE/src/routes.ts`)
- REST API → Reservations: routes requests (evidence: `BE/src/routes.ts`)
- REST API → Payments: routes requests (evidence: `BE/src/routes.ts`)
- REST API → Contracts: routes requests (evidence: `BE/src/routes.ts`)
- REST API → Support and claims: routes requests (evidence: `BE/src/routes.ts`)
- Reservations → MongoDB models: reads and writes (evidence: `BE/src/features/reservations/reservations.routes.ts`)
- Reservations → Payments: starts settlement (evidence: `BE/src/features/reservations/reservations.routes.ts`)
- Reservations → Check-in and intake: checks in (evidence: `BE/src/features/reservations/reservations.routes.ts`)
- Contracts → Payments: loads payment data (evidence: `BE/src/features/contracts/contracts.routes.ts`)
- Contracts → Check-in and intake: delegates intake (evidence: `BE/src/features/contracts/contracts.routes.ts`)
- Contracts → Rental services: delegates access (evidence: `BE/src/features/contracts/contracts.routes.ts`)
- Payments → MongoDB models: records transactions (evidence: `BE/src/features/payments/payments.routes.ts`)
- Payments → Email service: notifies staff
- Check-in and intake → MongoDB models: updates intake (evidence: `BE/src/features/intake/intake.routes.ts`)
- Support and claims → MongoDB models: stores tickets (evidence: `BE/src/shared/db/models.ts`)
- MongoDB models → MongoDB Atlas: persists data (evidence: `README.md`)
- Branch workflows → REST API: operates workflows (evidence: `README.md`)
- Branch management → REST API: manages rentals (evidence: `README.md`)
- Chain operations → REST API: governs chain (evidence: `README.md`)
- Administration → REST API: administers users (evidence: `README.md`)
- Web app → Shared business rules: shares domain rules (evidence: `README.md`)
- Mobile app → Shared business rules: shares domain rules (evidence: `README.md`)
- REST API → Shared business rules: uses domain rules (evidence: `README.md`)
