# neel281998/construction-management-backend architecture

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

- Interactive diagram: https://gitdiagram.com/neel281998/construction-management-backend
- Repository: https://github.com/neel281998/construction-management-backend

## Overview

This is a construction-management backend API: authenticated users manage construction sites and work progress, inventory and plant materials, fuel, vehicles, and operational records. Requests enter through the server and route handlers, which apply authentication/permissions and work with MongoDB-backed models. The file tree and SOURCE INDEX show broad domain coverage, but the README provides no capability details; some domain links below reflect route imports listed by the index rather than inspected handler behavior.

Main entry points: [`api/index.js`](https://github.com/neel281998/construction-management-backend/blob/main/api/index.js) (Route index), [`middleware/auth.js`](https://github.com/neel281998/construction-management-backend/blob/main/middleware/auth.js) (Authentication and permissions), [`routes/sites.js`](https://github.com/neel281998/construction-management-backend/blob/main/routes/sites.js) (Construction sites), [`routes/auth.js`](https://github.com/neel281998/construction-management-backend/blob/main/routes/auth.js) (Authentication)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_access["Access and API"]
  node_server["API server<br/>[server.js]"]
  node_api["Route index<br/>[index.js]"]
  node_authroutes["Authentication<br/>[auth.js]"]
  node_authmw["Authentication and permissions<br/>[auth.js]"]
  node_users[("User accounts<br/>[User.js]")]
end

subgraph group_construction["Construction Operations"]
  node_sites["Construction sites<br/>[sites.js]"]
  node_site_model[("Site records<br/>[Site.js]")]
  node_steps["Work steps<br/>[steps.js]"]
  node_step_model[("Step progress<br/>[Step.js]")]
  node_site_reports["Site reports"]
end

subgraph group_supplies["Supply Operations"]
  node_inventory["Materials inventory<br/>[inventory.js]"]
  node_inventory_model[("Inventory records<br/>[Inventory.js]")]
  node_storage["Storage sites<br/>[storageSites.js]"]
  node_storage_model[("Storage records<br/>[StorageSite.js]")]
  node_dispatch["Inventory dispatch"]
  node_plant_inventory["Plant inventory<br/>[plantInventory.js]"]
  node_plant_inventory_model[("Plant stock records<br/>[PlantInventory.js]")]
  node_plant_output["Plant output delivery"]
end

subgraph group_fleet["Fleet and Fuel"]
  node_fuel["Fuel management<br/>[fuelManagement.js]"]
  node_fuel_storage["Fuel storage<br/>[fuelStorage.js]"]
  node_vehicles["Vehicle management<br/>[vehicles.js]"]
  node_vehicle_model[("Vehicle records<br/>[Vehicle.js]")]
  node_vehicle_analytics["Vehicle analytics"]
end

subgraph group_support["Operational Support"]
  node_activity["Activity logging<br/>[activityLogger.js]"]
  node_alerts["Alerts and notifications<br/>[alerts.js]"]
  node_attendance["Attendance<br/>[attendance.js]"]
end

node_server -.->|"loads"| node_api
node_api -->|"imports"| node_authroutes
node_api -->|"imports"| node_sites
node_api -->|"imports"| node_inventory
node_api -->|"imports"| node_dispatch
node_api -->|"imports"| node_plant_inventory
node_api -->|"imports"| node_plant_output
node_api -->|"imports"| node_fuel
node_api -->|"imports"| node_fuel_storage
node_api -->|"imports"| node_vehicles
node_api -->|"imports"| node_vehicle_analytics
node_api -->|"imports"| node_alerts
node_api -->|"imports"| node_attendance
node_authroutes -->|"queries"| node_users
node_authroutes -->|"uses"| node_authmw
node_authmw -->|"loads user"| node_users
node_sites -->|"queries"| node_site_model
node_sites -->|"queries"| node_step_model
node_steps -->|"imports"| node_step_model
node_site_reports -->|"queries"| node_step_model
node_site_reports -->|"queries"| node_site_model
node_inventory -->|"imports"| node_inventory_model
node_storage -->|"queries"| node_storage_model
node_dispatch -->|"imports"| node_inventory_model
node_dispatch -->|"imports"| node_storage_model
node_plant_inventory -->|"imports"| node_plant_inventory_model
node_plant_output -->|"imports"| node_plant_inventory_model
node_fuel_storage -->|"checks access"| node_authmw
node_vehicles -->|"imports"| node_vehicle_model
node_vehicle_analytics -->|"imports"| node_vehicle_model
node_fuel -->|"uses"| node_activity
node_sites -->|"uses"| node_activity
node_alerts -->|"uses"| node_authmw
node_attendance -->|"uses"| node_authmw

click node_server "https://github.com/neel281998/construction-management-backend/blob/main/server.js"
click node_api "https://github.com/neel281998/construction-management-backend/blob/main/api/index.js"
click node_authroutes "https://github.com/neel281998/construction-management-backend/blob/main/routes/auth.js"
click node_authmw "https://github.com/neel281998/construction-management-backend/blob/main/middleware/auth.js"
click node_users "https://github.com/neel281998/construction-management-backend/blob/main/models/User.js"
click node_sites "https://github.com/neel281998/construction-management-backend/blob/main/routes/sites.js"
click node_site_model "https://github.com/neel281998/construction-management-backend/blob/main/models/Site.js"
click node_steps "https://github.com/neel281998/construction-management-backend/blob/main/routes/steps.js"
click node_step_model "https://github.com/neel281998/construction-management-backend/blob/main/models/Step.js"
click node_site_reports "https://github.com/neel281998/construction-management-backend/blob/main/routes/constructionSiteReport.js"
click node_inventory "https://github.com/neel281998/construction-management-backend/blob/main/routes/inventory.js"
click node_inventory_model "https://github.com/neel281998/construction-management-backend/blob/main/models/Inventory.js"
click node_storage "https://github.com/neel281998/construction-management-backend/blob/main/routes/storageSites.js"
click node_storage_model "https://github.com/neel281998/construction-management-backend/blob/main/models/StorageSite.js"
click node_dispatch "https://github.com/neel281998/construction-management-backend/blob/main/routes/inventoryDispatch.js"
click node_plant_inventory "https://github.com/neel281998/construction-management-backend/blob/main/routes/plantInventory.js"
click node_plant_inventory_model "https://github.com/neel281998/construction-management-backend/blob/main/models/PlantInventory.js"
click node_plant_output "https://github.com/neel281998/construction-management-backend/blob/main/routes/plantOutputDispatch.js"
click node_fuel "https://github.com/neel281998/construction-management-backend/blob/main/routes/fuelManagement.js"
click node_fuel_storage "https://github.com/neel281998/construction-management-backend/blob/main/routes/fuelStorage.js"
click node_vehicles "https://github.com/neel281998/construction-management-backend/blob/main/routes/vehicles.js"
click node_vehicle_model "https://github.com/neel281998/construction-management-backend/blob/main/models/Vehicle.js"
click node_vehicle_analytics "https://github.com/neel281998/construction-management-backend/blob/main/routes/vehicleAnalytics.js"
click node_activity "https://github.com/neel281998/construction-management-backend/blob/main/utils/activityLogger.js"
click node_alerts "https://github.com/neel281998/construction-management-backend/blob/main/routes/alerts.js"
click node_attendance "https://github.com/neel281998/construction-management-backend/blob/main/routes/attendance.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_api,node_authroutes,node_authmw,node_users toneBlue
class node_sites,node_site_model,node_steps,node_step_model,node_site_reports toneAmber
class node_inventory,node_inventory_model,node_storage,node_storage_model,node_dispatch,node_plant_inventory,node_plant_inventory_model,node_plant_output toneMint
class node_fuel,node_fuel_storage,node_vehicles,node_vehicle_model,node_vehicle_analytics toneRose
class node_activity,node_alerts,node_attendance toneIndigo
```

## Components

### Access and API

- [API server](https://github.com/neel281998/construction-management-backend/blob/main/server.js): `server.js`
- [Route index](https://github.com/neel281998/construction-management-backend/blob/main/api/index.js): `api/index.js`
- [Authentication](https://github.com/neel281998/construction-management-backend/blob/main/routes/auth.js): `routes/auth.js`
- [Authentication and permissions](https://github.com/neel281998/construction-management-backend/blob/main/middleware/auth.js): `middleware/auth.js`
- [User accounts](https://github.com/neel281998/construction-management-backend/blob/main/models/User.js): `models/User.js`

### Construction Operations

- [Construction sites](https://github.com/neel281998/construction-management-backend/blob/main/routes/sites.js): `routes/sites.js`
- [Site records](https://github.com/neel281998/construction-management-backend/blob/main/models/Site.js): `models/Site.js`
- [Work steps](https://github.com/neel281998/construction-management-backend/blob/main/routes/steps.js): `routes/steps.js`
- [Step progress](https://github.com/neel281998/construction-management-backend/blob/main/models/Step.js): `models/Step.js`
- [Site reports](https://github.com/neel281998/construction-management-backend/blob/main/routes/constructionSiteReport.js): `routes/constructionSiteReport.js`

### Supply Operations

- [Materials inventory](https://github.com/neel281998/construction-management-backend/blob/main/routes/inventory.js): `routes/inventory.js`
- [Inventory records](https://github.com/neel281998/construction-management-backend/blob/main/models/Inventory.js): `models/Inventory.js`
- [Storage sites](https://github.com/neel281998/construction-management-backend/blob/main/routes/storageSites.js): `routes/storageSites.js`
- [Storage records](https://github.com/neel281998/construction-management-backend/blob/main/models/StorageSite.js): `models/StorageSite.js`
- [Inventory dispatch](https://github.com/neel281998/construction-management-backend/blob/main/routes/inventoryDispatch.js): `routes/inventoryDispatch.js`
- [Plant inventory](https://github.com/neel281998/construction-management-backend/blob/main/routes/plantInventory.js): `routes/plantInventory.js`
- [Plant stock records](https://github.com/neel281998/construction-management-backend/blob/main/models/PlantInventory.js): `models/PlantInventory.js`
- [Plant output delivery](https://github.com/neel281998/construction-management-backend/blob/main/routes/plantOutputDispatch.js): `routes/plantOutputDispatch.js`

### Fleet and Fuel

- [Fuel management](https://github.com/neel281998/construction-management-backend/blob/main/routes/fuelManagement.js): `routes/fuelManagement.js`
- [Fuel storage](https://github.com/neel281998/construction-management-backend/blob/main/routes/fuelStorage.js): `routes/fuelStorage.js`
- [Vehicle management](https://github.com/neel281998/construction-management-backend/blob/main/routes/vehicles.js): `routes/vehicles.js`
- [Vehicle records](https://github.com/neel281998/construction-management-backend/blob/main/models/Vehicle.js): `models/Vehicle.js`
- [Vehicle analytics](https://github.com/neel281998/construction-management-backend/blob/main/routes/vehicleAnalytics.js): `routes/vehicleAnalytics.js`

### Operational Support

- [Activity logging](https://github.com/neel281998/construction-management-backend/blob/main/utils/activityLogger.js): `utils/activityLogger.js`
- [Alerts and notifications](https://github.com/neel281998/construction-management-backend/blob/main/routes/alerts.js): `routes/alerts.js`
- [Attendance](https://github.com/neel281998/construction-management-backend/blob/main/routes/attendance.js): `routes/attendance.js`

## Connections

- API server → Route index: loads
- Route index → Authentication: imports (evidence: `api/index.js`)
- Route index → Construction sites: imports (evidence: `api/index.js`)
- Route index → Materials inventory: imports (evidence: `api/index.js`)
- Route index → Inventory dispatch: imports (evidence: `api/index.js`)
- Route index → Plant inventory: imports (evidence: `api/index.js`)
- Route index → Plant output delivery: imports (evidence: `api/index.js`)
- Route index → Fuel management: imports (evidence: `api/index.js`)
- Route index → Fuel storage: imports (evidence: `api/index.js`)
- Route index → Vehicle management: imports (evidence: `api/index.js`)
- Route index → Vehicle analytics: imports (evidence: `api/index.js`)
- Route index → Alerts and notifications: imports (evidence: `api/index.js`)
- Route index → Attendance: imports (evidence: `api/index.js`)
- Authentication → User accounts: queries (evidence: `routes/auth.js`)
- Authentication → Authentication and permissions: uses (evidence: `routes/auth.js`)
- Authentication and permissions → User accounts: loads user (evidence: `middleware/auth.js`)
- Construction sites → Site records: queries (evidence: `routes/sites.js`)
- Construction sites → Step progress: queries (evidence: `routes/sites.js`)
- Work steps → Step progress: imports
- Site reports → Step progress: queries (evidence: `routes/constructionSiteReport.js`)
- Site reports → Site records: queries (evidence: `routes/constructionSiteReport.js`)
- Materials inventory → Inventory records: imports (evidence: `routes/inventory.js`)
- Storage sites → Storage records: queries (evidence: `routes/storageSites.js`)
- Inventory dispatch → Inventory records: imports (evidence: `routes/inventoryDispatch.js`)
- Inventory dispatch → Storage records: imports (evidence: `routes/inventoryDispatch.js`)
- Plant inventory → Plant stock records: imports (evidence: `routes/plantInventory.js`)
- Plant output delivery → Plant stock records: imports (evidence: `routes/plantOutputDispatch.js`)
- Fuel storage → Authentication and permissions: checks access (evidence: `routes/fuelStorage.js`)
- Vehicle management → Vehicle records: imports
- Vehicle analytics → Vehicle records: imports
- Fuel management → Activity logging: uses (evidence: `routes/fuelManagement.js`)
- Construction sites → Activity logging: uses (evidence: `routes/sites.js`)
- Alerts and notifications → Authentication and permissions: uses (evidence: `routes/alerts.js`)
- Attendance → Authentication and permissions: uses (evidence: `routes/attendance.js`)
