# wreyyz/facility-management architecture

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

- Interactive diagram: https://gitdiagram.com/wreyyz/facility-management
- Repository: https://github.com/wreyyz/facility-management

## Overview

Facility Management is a standalone project lifecycle and administration web application. Its principal workflow moves a request through PPC intake, engineering/tender preparation, procurement and staged payments, project execution, then operations handover, warranty and retention. Dashboard, inbox, project search, vendor evaluation and administration support that workflow. API excerpts show database access and selected helper calls; broader stage relationships are documented in the README, so those links are labeled as documented rather than inferred from unsampled page code.

Main entry points: [`src/server/db.ts`](https://github.com/wreyyz/facility-management/blob/main/src/server/db.ts) (MySQL via Prisma), [`src/app/api/engineering/route.ts`](https://github.com/wreyyz/facility-management/blob/main/src/app/api/engineering/route.ts) (Engineering API), [`src/app/api/ppc/route.ts`](https://github.com/wreyyz/facility-management/blob/main/src/app/api/ppc/route.ts) (PPC API), [`src/app/api/auth/login/route.ts`](https://github.com/wreyyz/facility-management/blob/main/src/app/api/auth/login/route.ts) (Authentication API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_lifecycle["Project Lifecycle"]
  node_ppc["PPC Intake<br/>[page.tsx]"]
  node_ppc_api["PPC API<br/>[route.ts]"]
  node_engineering["Engineering &amp; Tender<br/>[page.tsx]"]
  node_engineering_api["Engineering API<br/>[route.ts]"]
  node_procurement["Procurement &amp; Bids<br/>[page.tsx]"]
  node_procurement_api["Procurement API<br/>[route.ts]"]
  node_execution["Project Execution<br/>[page.tsx]"]
  node_execution_api["Execution API<br/>[route.ts]"]
  node_operations["Handover &amp; Warranty<br/>[page.tsx]"]
  node_operations_api["Operations API<br/>[route.ts]"]
end

subgraph group_oversight["Monitoring &amp; Evaluation"]
  node_vendors["Vendor Ranking<br/>[page.tsx]"]
  node_dashboard["Dashboard &amp; Flow<br/>[page.tsx]"]
  node_dashboard_api["Dashboard Metrics API<br/>[route.ts]"]
  node_inbox["Tasks &amp; Inbox<br/>[page.tsx]"]
  node_project_search["Project Search &amp; Reports<br/>[page.tsx]"]
end

subgraph group_identity["Access &amp; Administration"]
  node_auth_api["Authentication API<br/>[route.ts]"]
  node_auth["Session &amp; RBAC<br/>[auth.ts]"]
  node_admin["User &amp; Audit Admin<br/>[route.ts]"]
end

subgraph group_platform["Application Platform"]
  node_workdays["Working-Day Calculator<br/>[working-days.ts]"]
  node_sequences["Document Sequences<br/>[sequences.ts]"]
  node_importer["Legacy Sheets Import<br/>[import-sheets.ts]"]
  node_database[("MySQL via Prisma<br/>[db.ts]")]
end

node_user(("Staff User"))

node_user -->|"starts request"| node_ppc
node_ppc -.->|"submits intake"| node_ppc_api
node_ppc_api -->|"generates number"| node_sequences
node_ppc_api -->|"reads/writes"| node_database
node_engineering -.->|"manages tender"| node_engineering_api
node_engineering_api -->|"calculates days"| node_workdays
node_engineering_api -->|"generates number"| node_sequences
node_engineering_api -->|"reads/writes"| node_database
node_procurement -.->|"evaluates bids"| node_procurement_api
node_procurement_api -->|"reads/writes"| node_database
node_vendors -.->|"supports evaluation"| node_procurement
node_execution -.->|"updates progress"| node_execution_api
node_execution_api -->|"reads/writes"| node_database
node_operations -.->|"records handover"| node_operations_api
node_operations_api -->|"reads/writes"| node_database
node_user -->|"monitors projects"| node_dashboard
node_dashboard -.->|"requests metrics"| node_dashboard_api
node_dashboard_api -->|"queries metrics"| node_database
node_inbox -->|"loads notifications"| node_database
node_project_search -->|"searches records"| node_database
node_auth_api -->|"creates session"| node_auth
node_auth_api -->|"checks account"| node_database
node_admin -->|"checks access"| node_auth
node_admin -->|"manages users"| node_database
node_importer -->|"imports records"| node_database

click node_ppc "https://github.com/wreyyz/facility-management/blob/main/src/app/(app)/ppc/page.tsx"
click node_ppc_api "https://github.com/wreyyz/facility-management/blob/main/src/app/api/ppc/route.ts"
click node_engineering "https://github.com/wreyyz/facility-management/blob/main/src/app/(app)/engineering/page.tsx"
click node_engineering_api "https://github.com/wreyyz/facility-management/blob/main/src/app/api/engineering/route.ts"
click node_workdays "https://github.com/wreyyz/facility-management/blob/main/src/lib/working-days.ts"
click node_sequences "https://github.com/wreyyz/facility-management/blob/main/src/server/sequences.ts"
click node_procurement "https://github.com/wreyyz/facility-management/blob/main/src/app/(app)/procurement/page.tsx"
click node_procurement_api "https://github.com/wreyyz/facility-management/blob/main/src/app/api/procurement/route.ts"
click node_vendors "https://github.com/wreyyz/facility-management/blob/main/src/app/(app)/vendors/page.tsx"
click node_execution "https://github.com/wreyyz/facility-management/blob/main/src/app/(app)/project/page.tsx"
click node_execution_api "https://github.com/wreyyz/facility-management/blob/main/src/app/api/project-execution/route.ts"
click node_operations "https://github.com/wreyyz/facility-management/blob/main/src/app/(app)/operations/page.tsx"
click node_operations_api "https://github.com/wreyyz/facility-management/blob/main/src/app/api/operations/route.ts"
click node_dashboard "https://github.com/wreyyz/facility-management/blob/main/src/app/(app)/dashboard/page.tsx"
click node_dashboard_api "https://github.com/wreyyz/facility-management/blob/main/src/app/api/dashboard/route.ts"
click node_inbox "https://github.com/wreyyz/facility-management/blob/main/src/app/(app)/inbox/page.tsx"
click node_project_search "https://github.com/wreyyz/facility-management/blob/main/src/app/(app)/projects/page.tsx"
click node_auth_api "https://github.com/wreyyz/facility-management/blob/main/src/app/api/auth/login/route.ts"
click node_auth "https://github.com/wreyyz/facility-management/blob/main/src/server/auth.ts"
click node_admin "https://github.com/wreyyz/facility-management/blob/main/src/app/api/admin/users/route.ts"
click node_importer "https://github.com/wreyyz/facility-management/blob/main/scripts/import-sheets.ts"
click node_database "https://github.com/wreyyz/facility-management/blob/main/src/server/db.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_ppc,node_ppc_api,node_engineering,node_engineering_api,node_procurement,node_procurement_api,node_execution,node_execution_api,node_operations,node_operations_api,node_user toneBlue
class node_vendors,node_dashboard,node_dashboard_api,node_inbox,node_project_search toneAmber
class node_auth_api,node_auth,node_admin toneMint
class node_workdays,node_sequences,node_importer,node_database toneRose
```

## Components

### Project Lifecycle

- [PPC Intake](https://github.com/wreyyz/facility-management/blob/main/src/app/(app)/ppc/page.tsx): `src/app/(app)/ppc/page.tsx`
- [PPC API](https://github.com/wreyyz/facility-management/blob/main/src/app/api/ppc/route.ts): `src/app/api/ppc/route.ts`
- [Engineering & Tender](https://github.com/wreyyz/facility-management/blob/main/src/app/(app)/engineering/page.tsx): `src/app/(app)/engineering/page.tsx`
- [Engineering API](https://github.com/wreyyz/facility-management/blob/main/src/app/api/engineering/route.ts): `src/app/api/engineering/route.ts`
- [Procurement & Bids](https://github.com/wreyyz/facility-management/blob/main/src/app/(app)/procurement/page.tsx): `src/app/(app)/procurement/page.tsx`
- [Procurement API](https://github.com/wreyyz/facility-management/blob/main/src/app/api/procurement/route.ts): `src/app/api/procurement/route.ts`
- [Project Execution](https://github.com/wreyyz/facility-management/blob/main/src/app/(app)/project/page.tsx): `src/app/(app)/project/page.tsx`
- [Execution API](https://github.com/wreyyz/facility-management/blob/main/src/app/api/project-execution/route.ts): `src/app/api/project-execution/route.ts`
- [Handover & Warranty](https://github.com/wreyyz/facility-management/blob/main/src/app/(app)/operations/page.tsx): `src/app/(app)/operations/page.tsx`
- [Operations API](https://github.com/wreyyz/facility-management/blob/main/src/app/api/operations/route.ts): `src/app/api/operations/route.ts`

### Monitoring & Evaluation

- [Vendor Ranking](https://github.com/wreyyz/facility-management/blob/main/src/app/(app)/vendors/page.tsx): `src/app/(app)/vendors/page.tsx`
- [Dashboard & Flow](https://github.com/wreyyz/facility-management/blob/main/src/app/(app)/dashboard/page.tsx): `src/app/(app)/dashboard/page.tsx`
- [Dashboard Metrics API](https://github.com/wreyyz/facility-management/blob/main/src/app/api/dashboard/route.ts): `src/app/api/dashboard/route.ts`
- [Tasks & Inbox](https://github.com/wreyyz/facility-management/blob/main/src/app/(app)/inbox/page.tsx): `src/app/(app)/inbox/page.tsx`
- [Project Search & Reports](https://github.com/wreyyz/facility-management/blob/main/src/app/(app)/projects/page.tsx): `src/app/(app)/projects/page.tsx`

### Access & Administration

- [Authentication API](https://github.com/wreyyz/facility-management/blob/main/src/app/api/auth/login/route.ts): `src/app/api/auth/login/route.ts`
- [Session & RBAC](https://github.com/wreyyz/facility-management/blob/main/src/server/auth.ts): `src/server/auth.ts`
- [User & Audit Admin](https://github.com/wreyyz/facility-management/blob/main/src/app/api/admin/users/route.ts): `src/app/api/admin/users/route.ts`

### Application Platform

- [Working-Day Calculator](https://github.com/wreyyz/facility-management/blob/main/src/lib/working-days.ts): `src/lib/working-days.ts`
- [Document Sequences](https://github.com/wreyyz/facility-management/blob/main/src/server/sequences.ts): `src/server/sequences.ts`
- [Legacy Sheets Import](https://github.com/wreyyz/facility-management/blob/main/scripts/import-sheets.ts): `scripts/import-sheets.ts`
- [MySQL via Prisma](https://github.com/wreyyz/facility-management/blob/main/src/server/db.ts): `src/server/db.ts`

### Other components

- **Staff User**

## Connections

- Staff User → PPC Intake: starts request (evidence: `README.md`)
- PPC Intake → PPC API: submits intake
- PPC API → Document Sequences: generates number (evidence: `src/app/api/ppc/route.ts`)
- PPC API → MySQL via Prisma: reads/writes (evidence: `src/app/api/ppc/route.ts`)
- Engineering & Tender → Engineering API: manages tender
- Engineering API → Working-Day Calculator: calculates days (evidence: `src/app/api/engineering/route.ts`)
- Engineering API → Document Sequences: generates number (evidence: `src/app/api/engineering/route.ts`)
- Engineering API → MySQL via Prisma: reads/writes (evidence: `src/app/api/engineering/route.ts`)
- Procurement & Bids → Procurement API: evaluates bids
- Procurement API → MySQL via Prisma: reads/writes (evidence: `src/app/api/procurement/route.ts`)
- Vendor Ranking → Procurement & Bids: supports evaluation
- Project Execution → Execution API: updates progress
- Execution API → MySQL via Prisma: reads/writes (evidence: `src/app/api/project-execution/route.ts`)
- Handover & Warranty → Operations API: records handover
- Operations API → MySQL via Prisma: reads/writes (evidence: `src/app/api/operations/route.ts`)
- Staff User → Dashboard & Flow: monitors projects (evidence: `README.md`)
- Dashboard & Flow → Dashboard Metrics API: requests metrics
- Dashboard Metrics API → MySQL via Prisma: queries metrics (evidence: `src/app/api/dashboard/route.ts`)
- Tasks & Inbox → MySQL via Prisma: loads notifications
- Project Search & Reports → MySQL via Prisma: searches records
- Authentication API → Session & RBAC: creates session (evidence: `src/app/api/auth/login/route.ts`)
- Authentication API → MySQL via Prisma: checks account (evidence: `src/app/api/auth/login/route.ts`)
- User & Audit Admin → Session & RBAC: checks access (evidence: `src/app/api/admin/users/route.ts`)
- User & Audit Admin → MySQL via Prisma: manages users (evidence: `src/app/api/admin/users/route.ts`)
- Legacy Sheets Import → MySQL via Prisma: imports records (evidence: `scripts/import-sheets.ts`)
