# smhaider-zaidi/assetflow architecture

> Architecture diagram of the GitHub repository smhaider-zaidi/assetflow, 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/smhaider-zaidi/assetflow
- Repository: https://github.com/smhaider-zaidi/assetflow

## Overview

AssetFlow is a multi-tenant asset and resource booking application with employee, organization-admin, and superadmin workflows. Employees browse resources, request time slots, and manage bookings; admins manage inventory, categories, users, and audit records; superadmins review system-wide and organization-level data. Express routes dispatch to controllers, which use shared query functions backed by MySQL. The excerpts establish these core relationships; other unsampled routes and integrations are not inferred.

Main entry points: [`server.js`](https://github.com/smhaider-zaidi/assetflow/blob/main/server.js) (Express Server), [`models/dbQueries.js`](https://github.com/smhaider-zaidi/assetflow/blob/main/models/dbQueries.js) (Database Queries), [`controllers/adminController.js`](https://github.com/smhaider-zaidi/assetflow/blob/main/controllers/adminController.js) (Admin Operations), [`routes/bookingRoutes.js`](https://github.com/smhaider-zaidi/assetflow/blob/main/routes/bookingRoutes.js) (Employee Routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web Entry &amp; Identity"]
  node_server["Express Server<br/>[server.js]"]
  node_auth_routes["Identity Routes<br/>[authRoutes.js]"]
  node_auth_controller["Login &amp; Registration<br/>[authController.js]"]
  node_auth_middleware["Role Guards<br/>[auth.js]"]
end

subgraph group_employee["Employee Booking"]
  node_booking_routes["Employee Routes<br/>[bookingRoutes.js]"]
  node_booking_controller["Booking Workflow"]
  node_employee_views["Employee Screens"]
end

subgraph group_admin["Organization Administration"]
  node_admin_routes["Admin Routes<br/>[adminRoutes.js]"]
  node_admin_controller["Admin Operations<br/>[adminController.js]"]
  node_admin_views["Admin Screens"]
  node_invite_mailer["Invite Mailer<br/>[mailer.js]"]
end

subgraph group_oversight["System Oversight"]
  node_super_routes["Superadmin Routes<br/>[superRoutes.js]"]
  node_super_controller["Organization Oversight<br/>[superController.js]"]
  node_super_views["Superadmin Screens"]
end

subgraph group_data["Persistence &amp; Services"]
  node_queries["Database Queries<br/>[dbQueries.js]"]
  node_pool["MySQL Pool<br/>[db.js]"]
  node_mysql[("MySQL Database")]
end

node_user(("User"))

node_user -->|"sends requests"| node_server
node_server -->|"mounts at root"| node_auth_routes
node_server -->|"mounts employee routes"| node_booking_routes
node_server -->|"mounts admin routes"| node_admin_routes
node_server -->|"mounts superadmin routes"| node_super_routes
node_auth_routes -->|"dispatches to"| node_auth_controller
node_auth_controller -->|"reads and registers"| node_queries
node_booking_routes -->|"checks roles"| node_auth_middleware
node_booking_routes -->|"dispatches to"| node_booking_controller
node_booking_controller -->|"reads and updates"| node_queries
node_booking_controller -->|"renders screens"| node_employee_views
node_admin_routes -->|"checks admin role"| node_auth_middleware
node_admin_routes -->|"dispatches to"| node_admin_controller
node_admin_controller -->|"manages tenant data"| node_queries
node_admin_controller -->|"sends invitations"| node_invite_mailer
node_admin_controller -->|"renders screens"| node_admin_views
node_super_routes -->|"checks superadmin role"| node_auth_middleware
node_super_routes -->|"dispatches to"| node_super_controller
node_super_controller -->|"reads system data"| node_queries
node_super_controller -->|"renders screens"| node_super_views
node_queries -->|"executes SQL through"| node_pool
node_pool -->|"connects to"| node_mysql

click node_server "https://github.com/smhaider-zaidi/assetflow/blob/main/server.js"
click node_auth_routes "https://github.com/smhaider-zaidi/assetflow/blob/main/routes/authRoutes.js"
click node_auth_controller "https://github.com/smhaider-zaidi/assetflow/blob/main/controllers/authController.js"
click node_auth_middleware "https://github.com/smhaider-zaidi/assetflow/blob/main/middleware/auth.js"
click node_booking_routes "https://github.com/smhaider-zaidi/assetflow/blob/main/routes/bookingRoutes.js"
click node_booking_controller "https://github.com/smhaider-zaidi/assetflow/blob/main/controllers/bookingController.js"
click node_employee_views "https://github.com/smhaider-zaidi/assetflow/tree/main/views/employee"
click node_admin_routes "https://github.com/smhaider-zaidi/assetflow/blob/main/routes/adminRoutes.js"
click node_admin_controller "https://github.com/smhaider-zaidi/assetflow/blob/main/controllers/adminController.js"
click node_admin_views "https://github.com/smhaider-zaidi/assetflow/tree/main/views/admin"
click node_invite_mailer "https://github.com/smhaider-zaidi/assetflow/blob/main/utils/mailer.js"
click node_super_routes "https://github.com/smhaider-zaidi/assetflow/blob/main/routes/superRoutes.js"
click node_super_controller "https://github.com/smhaider-zaidi/assetflow/blob/main/controllers/superController.js"
click node_super_views "https://github.com/smhaider-zaidi/assetflow/tree/main/views/superadmin"
click node_queries "https://github.com/smhaider-zaidi/assetflow/blob/main/models/dbQueries.js"
click node_pool "https://github.com/smhaider-zaidi/assetflow/blob/main/config/db.js"

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_server,node_auth_routes,node_auth_controller,node_auth_middleware,node_user toneBlue
class node_booking_routes,node_booking_controller,node_employee_views toneAmber
class node_admin_routes,node_admin_controller,node_admin_views,node_invite_mailer toneMint
class node_super_routes,node_super_controller,node_super_views toneRose
class node_queries,node_pool,node_mysql toneIndigo
```

## Components

### Web Entry & Identity

- [Express Server](https://github.com/smhaider-zaidi/assetflow/blob/main/server.js): `server.js`
- [Identity Routes](https://github.com/smhaider-zaidi/assetflow/blob/main/routes/authRoutes.js): `routes/authRoutes.js`
- [Login & Registration](https://github.com/smhaider-zaidi/assetflow/blob/main/controllers/authController.js): `controllers/authController.js`
- [Role Guards](https://github.com/smhaider-zaidi/assetflow/blob/main/middleware/auth.js): `middleware/auth.js`

### Employee Booking

- [Employee Routes](https://github.com/smhaider-zaidi/assetflow/blob/main/routes/bookingRoutes.js): `routes/bookingRoutes.js`
- [Booking Workflow](https://github.com/smhaider-zaidi/assetflow/blob/main/controllers/bookingController.js): `controllers/bookingController.js`
- [Employee Screens](https://github.com/smhaider-zaidi/assetflow/tree/main/views/employee): `views/employee`

### Organization Administration

- [Admin Routes](https://github.com/smhaider-zaidi/assetflow/blob/main/routes/adminRoutes.js): `routes/adminRoutes.js`
- [Admin Operations](https://github.com/smhaider-zaidi/assetflow/blob/main/controllers/adminController.js): `controllers/adminController.js`
- [Admin Screens](https://github.com/smhaider-zaidi/assetflow/tree/main/views/admin): `views/admin`
- [Invite Mailer](https://github.com/smhaider-zaidi/assetflow/blob/main/utils/mailer.js): `utils/mailer.js`

### System Oversight

- [Superadmin Routes](https://github.com/smhaider-zaidi/assetflow/blob/main/routes/superRoutes.js): `routes/superRoutes.js`
- [Organization Oversight](https://github.com/smhaider-zaidi/assetflow/blob/main/controllers/superController.js): `controllers/superController.js`
- [Superadmin Screens](https://github.com/smhaider-zaidi/assetflow/tree/main/views/superadmin): `views/superadmin`

### Persistence & Services

- [Database Queries](https://github.com/smhaider-zaidi/assetflow/blob/main/models/dbQueries.js): `models/dbQueries.js`
- [MySQL Pool](https://github.com/smhaider-zaidi/assetflow/blob/main/config/db.js): `config/db.js`
- **MySQL Database**

### Other components

- **User**

## Connections

- User → Express Server: sends requests (evidence: `server.js`)
- Express Server → Identity Routes: mounts at root (evidence: `server.js`)
- Express Server → Employee Routes: mounts employee routes (evidence: `server.js`)
- Express Server → Admin Routes: mounts admin routes (evidence: `server.js`)
- Express Server → Superadmin Routes: mounts superadmin routes (evidence: `server.js`)
- Identity Routes → Login & Registration: dispatches to (evidence: `routes/authRoutes.js`)
- Login & Registration → Database Queries: reads and registers (evidence: `controllers/authController.js`)
- Employee Routes → Role Guards: checks roles (evidence: `routes/bookingRoutes.js`)
- Employee Routes → Booking Workflow: dispatches to (evidence: `routes/bookingRoutes.js`)
- Booking Workflow → Database Queries: reads and updates (evidence: `controllers/bookingController.js`)
- Booking Workflow → Employee Screens: renders screens (evidence: `controllers/bookingController.js`)
- Admin Routes → Role Guards: checks admin role (evidence: `routes/adminRoutes.js`)
- Admin Routes → Admin Operations: dispatches to (evidence: `routes/adminRoutes.js`)
- Admin Operations → Database Queries: manages tenant data (evidence: `controllers/adminController.js`)
- Admin Operations → Invite Mailer: sends invitations (evidence: `controllers/adminController.js`)
- Admin Operations → Admin Screens: renders screens (evidence: `controllers/adminController.js`)
- Superadmin Routes → Role Guards: checks superadmin role (evidence: `routes/superRoutes.js`)
- Superadmin Routes → Organization Oversight: dispatches to (evidence: `routes/superRoutes.js`)
- Organization Oversight → Database Queries: reads system data (evidence: `controllers/superController.js`)
- Organization Oversight → Superadmin Screens: renders screens (evidence: `controllers/superController.js`)
- Database Queries → MySQL Pool: executes SQL through (evidence: `models/dbQueries.js`)
- MySQL Pool → MySQL Database: connects to (evidence: `config/db.js`)
