# kevinvargis/bottled-water-delivery-management-system architecture

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

- Interactive diagram: https://gitdiagram.com/kevinvargis/bottled-water-delivery-management-system
- Repository: https://github.com/kevinvargis/bottled-water-delivery-management-system

## Overview

#### Purpose and topology
This is a packaged-drinking-water delivery-management system with three deployable parts: a React web portal for company, manager, supervisor, and customer roles; an Expo/React Native delivery-team app; and a Node/Express API backed by modeled persistence. The root README describes the operational workflow; source is split under `src/Web-App`, `src/App`, and `src/server`.

#### Entry points and runtimes
- Web client: Create React App bootstrap at `src/Web-App/src/index.js`, application routing/composition in `src/Web-App/src/App.js`.
- Mobile client: Expo entry component `src/App/App.js`; screen-based React Native UI under `src/App/src/screens`.
- Backend: Node/Express process starts at `src/server/server.js`.
- Dependency manifests exist separately at `src/Web-App/package.json`, `src/App/package.json`, and `src/server/package.json`, indicating independently runnable frontend, mobile, and API projects.

#### Identity, roles, and access boundary
The system’s core hierarchy is company → managers → supervisors → customers/delivery staff. User/domain representation is centered in `src/server/models/User.js`, role-specific models such as `src/server/models/Company.js` and `src/server/models/Supervisor.js`, and user endpoints in `src/server/routes/api/users.js`.
Web authentication state is managed through Redux-like action/reducer/store layers: `src/Web-App/src/actions/authActions.js`, `src/Web-App/src/reducers/authReducer.js`, and `src/Web-App/src/store.js`. Protected web access is enforced at `src/Web-App/src/components/private-route/PrivateRoute.js`; bearer-token attachment is isolated in `src/Web-App/src/utils/setAuthToken.js`. Server authentication configuration is represented by `src/server/config/passport.js`.

#### Administrative web workflows
Role-specific web areas partition management responsibilities:
- Company creates managers and views its dashboard: `src/Web-App/src/components/company/CreateManager.js`, `src/Web-App/src/components/company/Dashboard.js`.
- Managers provision operational resources and staff—customers, drivers, delivery boys, supervisors, vehicles—through `src/Web-App/src/components/manager` (for example `CreateCustomer.js`, `CreateVehicle.js`).
- Supervisors create/assign routes and inspect inventory via `src/Web-App/src/components/supervisor/CreateRoute.js`, `AssignRoute.js`, and `Inventory.js`.
- Customers request cans, submit complaints, view subscriptions/QR codes through `src/Web-App/src/components/customer/RequestCans.js`, `RegisterComplaint.js`, and `ViewQr.js`.

#### Delivery execution and mobile flow
The Expo app serves delivery personnel rather than office roles. Its principal stages are sign-in, attendance/team participation, trip selection/viewing, QR scanning, delivery progress, and profile: `src/App/src/screens/SignInScreen.js`, `AttendanceScreen.js`, `TripScreen.js`, `ScanScreen.js`, and `ProgressScreen.js`. Shared mobile components include trip switching and delivery-card presentation in `src/App/src/components/SwitchTripView.js` and `DeliScreenCard.js`.
Operationally, driver and vehicle QR pairing creates a daily trip; delivery staff join a vehicle/trip; the team scans a customer QR and records filled-can delivery, empty-can pickup, and damage. This client workflow is a boundary to server-side trip, delivery, vehicle, and customer records.

#### Operational domain and persistence model
Mongoose-style server models define the system of record for fleet and fulfillment: `src/server/models/Vehicle.js`, `src/server/models/Route.js`, `src/server/models/Trip.js`, `src/server/models/Deliveries.js`, and `src/server/models/Inventory.js`. Trip lifecycle distinctions are explicitly modeled in `src/server/models/Initialtrip.js` and `src/server/models/Intermediatetrip.js`, likely supporting vehicle/team assignment changes during a day. Complaints and customer subscriptions/orders are represented by `src/server/models/Complaint.js` and `src/server/models/Kharidaar.js`.

#### API boundary and input control
REST endpoints are organized by principal actor at `src/server/routes/api/customers.js`, `src/server/routes/api/drivers.js`, `src/server/routes/api/managers.js`, `src/server/routes/api/supervisors.js`, and `src/server/routes/api/boys.js`. Validation is separated before domain handling, notably `src/server/validation/login.js`, `src/server/validation/routecreation.js`, and `src/server/validation/inventoryupdate.js`. Credentials/configuration are isolated in `src/server/config/keys.js`; its contents and the actual database/provider are not visible from the supplied tree.

Main entry points: [`src/server/routes/api/customers.js`](https://github.com/kevinvargis/bottled-water-delivery-management-system/blob/main/src/server/routes/api/customers.js) (Actor REST endpoints), [`src/server/server.js`](https://github.com/kevinvargis/bottled-water-delivery-management-system/blob/main/src/server/server.js) (Express server), [`src/Web-App/src/App.js`](https://github.com/kevinvargis/bottled-water-delivery-management-system/blob/main/src/Web-App/src/App.js) (Role-based portal), [`src/server/models/Trip.js`](https://github.com/kevinvargis/bottled-water-delivery-management-system/blob/main/src/server/models/Trip.js) (Trip lifecycle)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web Portal"]
  node_web_bootstrap["Web bootstrap<br/>Create React App<br/>[index.js]"]
  node_web_app["Role-based portal<br/>React router<br/>[App.js]"]
  node_web_auth["Auth state<br/>Redux auth<br/>[authActions.js]"]
  node_web_private_routes["Protected routes<br/>React guard<br/>[PrivateRoute.js]"]
  node_web_admin_workflows["Administrative workflows<br/>React components"]
end

subgraph group_mobile["Delivery App"]
  node_mobile_entry["Mobile entry<br/>Expo React Native<br/>[App.js]"]
  node_mobile_delivery_flow["Delivery workflow<br/>React Native screens<br/>[ScanScreen.js]"]
end

subgraph group_api["Node API"]
  node_api_server["Express server<br/>Node runtime<br/>[server.js]"]
  node_api_auth["Authentication<br/>Passport config<br/>[passport.js]"]
  node_api_routes["Actor REST endpoints<br/>Express routes<br/>[customers.js]"]
  node_api_validation["Request validation<br/>Validation layer<br/>[login.js]"]
  node_users_roles["Users and hierarchy<br/>Mongoose models<br/>[User.js]"]
  node_fleet_routes["Fleet and routes<br/>Mongoose models<br/>[Vehicle.js]"]
  node_trip_lifecycle["Trip lifecycle<br/>Mongoose models<br/>[Trip.js]"]
  node_fulfillment_inventory["Deliveries and inventory<br/>Mongoose models<br/>[Deliveries.js]"]
  node_customer_service["Customer service records<br/>Mongoose models<br/>[Kharidaar.js]"]
end

node_web_bootstrap -->|"mounts"| node_web_app
node_web_app -->|"guards role areas"| node_web_private_routes
node_web_auth -->|"supplies session"| node_web_private_routes
node_web_app -->|"sign-in actions"| node_web_auth
node_web_private_routes -->|"permits access"| node_web_admin_workflows
node_web_admin_workflows -->|"REST requests"| node_api_server
node_mobile_entry -->|"renders screens"| node_mobile_delivery_flow
node_mobile_delivery_flow -->|"trip and scan updates"| node_api_server
node_api_server -->|"authenticates"| node_api_auth
node_api_server -->|"dispatches"| node_api_routes
node_api_routes -->|"validates input"| node_api_validation
node_api_routes -->|"manages identities"| node_users_roles
node_api_routes -->|"manages fleet"| node_fleet_routes
node_api_routes -->|"creates and joins trips"| node_trip_lifecycle
node_api_routes -->|"records fulfillment"| node_fulfillment_inventory
node_api_routes -->|"handles orders and complaints"| node_customer_service
node_trip_lifecycle -->|"assigns vehicle and route"| node_fleet_routes
node_trip_lifecycle -->|"drives delivery records"| node_fulfillment_inventory
node_users_roles -->|"relates customers"| node_customer_service

click node_web_bootstrap "https://github.com/kevinvargis/bottled-water-delivery-management-system/blob/main/src/Web-App/src/index.js"
click node_web_app "https://github.com/kevinvargis/bottled-water-delivery-management-system/blob/main/src/Web-App/src/App.js"
click node_web_auth "https://github.com/kevinvargis/bottled-water-delivery-management-system/blob/main/src/Web-App/src/actions/authActions.js"
click node_web_private_routes "https://github.com/kevinvargis/bottled-water-delivery-management-system/blob/main/src/Web-App/src/components/private-route/PrivateRoute.js"
click node_web_admin_workflows "https://github.com/kevinvargis/bottled-water-delivery-management-system/tree/main/src/Web-App/src/components/manager"
click node_mobile_entry "https://github.com/kevinvargis/bottled-water-delivery-management-system/blob/main/src/App/App.js"
click node_mobile_delivery_flow "https://github.com/kevinvargis/bottled-water-delivery-management-system/blob/main/src/App/src/screens/ScanScreen.js"
click node_api_server "https://github.com/kevinvargis/bottled-water-delivery-management-system/blob/main/src/server/server.js"
click node_api_auth "https://github.com/kevinvargis/bottled-water-delivery-management-system/blob/main/src/server/config/passport.js"
click node_api_routes "https://github.com/kevinvargis/bottled-water-delivery-management-system/blob/main/src/server/routes/api/customers.js"
click node_api_validation "https://github.com/kevinvargis/bottled-water-delivery-management-system/blob/main/src/server/validation/login.js"
click node_users_roles "https://github.com/kevinvargis/bottled-water-delivery-management-system/blob/main/src/server/models/User.js"
click node_fleet_routes "https://github.com/kevinvargis/bottled-water-delivery-management-system/blob/main/src/server/models/Vehicle.js"
click node_trip_lifecycle "https://github.com/kevinvargis/bottled-water-delivery-management-system/blob/main/src/server/models/Trip.js"
click node_fulfillment_inventory "https://github.com/kevinvargis/bottled-water-delivery-management-system/blob/main/src/server/models/Deliveries.js"
click node_customer_service "https://github.com/kevinvargis/bottled-water-delivery-management-system/blob/main/src/server/models/Kharidaar.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_web_bootstrap,node_web_app,node_web_auth,node_web_private_routes,node_web_admin_workflows toneBlue
class node_mobile_entry,node_mobile_delivery_flow toneAmber
class node_api_server,node_api_auth,node_api_routes,node_api_validation,node_users_roles,node_fleet_routes,node_trip_lifecycle,node_fulfillment_inventory,node_customer_service toneMint
```

## Components

### Web Portal

React administration portal for office and customer roles.

- [Web bootstrap](https://github.com/kevinvargis/bottled-water-delivery-management-system/blob/main/src/Web-App/src/index.js): Create React App · `src/Web-App/src/index.js`
- [Role-based portal](https://github.com/kevinvargis/bottled-water-delivery-management-system/blob/main/src/Web-App/src/App.js): React router · Composes company, manager, supervisor, and customer areas. · `src/Web-App/src/App.js`
- [Auth state](https://github.com/kevinvargis/bottled-water-delivery-management-system/blob/main/src/Web-App/src/actions/authActions.js): Redux auth · Stores web authentication state and token handling. · `src/Web-App/src/actions/authActions.js`
- [Protected routes](https://github.com/kevinvargis/bottled-water-delivery-management-system/blob/main/src/Web-App/src/components/private-route/PrivateRoute.js): React guard · `src/Web-App/src/components/private-route/PrivateRoute.js`
- [Administrative workflows](https://github.com/kevinvargis/bottled-water-delivery-management-system/tree/main/src/Web-App/src/components/manager): React components · Company, manager, supervisor, and customer operations. · `src/Web-App/src/components/manager`

### Delivery App

Expo app used by delivery teams.

- [Mobile entry](https://github.com/kevinvargis/bottled-water-delivery-management-system/blob/main/src/App/App.js): Expo React Native · `src/App/App.js`
- [Delivery workflow](https://github.com/kevinvargis/bottled-water-delivery-management-system/blob/main/src/App/src/screens/ScanScreen.js): React Native screens · Sign-in, attendance, trips, QR scan, and delivery progress. · `src/App/src/screens/ScanScreen.js`

### Node API

Express API and modeled operational system of record.

- [Express server](https://github.com/kevinvargis/bottled-water-delivery-management-system/blob/main/src/server/server.js): Node runtime · `src/server/server.js`
- [Authentication](https://github.com/kevinvargis/bottled-water-delivery-management-system/blob/main/src/server/config/passport.js): Passport config · Authenticates bearer-token requests. · `src/server/config/passport.js`
- [Actor REST endpoints](https://github.com/kevinvargis/bottled-water-delivery-management-system/blob/main/src/server/routes/api/customers.js): Express routes · Customer, driver, manager, supervisor, and delivery-staff APIs. · `src/server/routes/api/customers.js`
- [Request validation](https://github.com/kevinvargis/bottled-water-delivery-management-system/blob/main/src/server/validation/login.js): Validation layer · Validates login, route creation, and inventory updates before handling. · `src/server/validation/login.js`
- [Users and hierarchy](https://github.com/kevinvargis/bottled-water-delivery-management-system/blob/main/src/server/models/User.js): Mongoose models · Company-to-manager-to-supervisor-to-customer/staff role model. · `src/server/models/User.js`
- [Fleet and routes](https://github.com/kevinvargis/bottled-water-delivery-management-system/blob/main/src/server/models/Vehicle.js): Mongoose models · Vehicles and delivery routes. · `src/server/models/Vehicle.js`
- [Trip lifecycle](https://github.com/kevinvargis/bottled-water-delivery-management-system/blob/main/src/server/models/Trip.js): Mongoose models · Daily trips, including initial and intermediate assignment stages. · `src/server/models/Trip.js`
- [Deliveries and inventory](https://github.com/kevinvargis/bottled-water-delivery-management-system/blob/main/src/server/models/Deliveries.js): Mongoose models · Tracks can delivery, empty pickup, damage, and stock. · `src/server/models/Deliveries.js`
- [Customer service records](https://github.com/kevinvargis/bottled-water-delivery-management-system/blob/main/src/server/models/Kharidaar.js): Mongoose models · Subscriptions/orders and complaints. · `src/server/models/Kharidaar.js`

## Connections

- Web bootstrap → Role-based portal: mounts
- Role-based portal → Protected routes: guards role areas
- Auth state → Protected routes: supplies session
- Role-based portal → Auth state: sign-in actions
- Protected routes → Administrative workflows: permits access
- Administrative workflows → Express server: REST requests
- Mobile entry → Delivery workflow: renders screens
- Delivery workflow → Express server: trip and scan updates
- Express server → Authentication: authenticates
- Express server → Actor REST endpoints: dispatches
- Actor REST endpoints → Request validation: validates input
- Actor REST endpoints → Users and hierarchy: manages identities
- Actor REST endpoints → Fleet and routes: manages fleet
- Actor REST endpoints → Trip lifecycle: creates and joins trips
- Actor REST endpoints → Deliveries and inventory: records fulfillment
- Actor REST endpoints → Customer service records: handles orders and complaints
- Trip lifecycle → Fleet and routes: assigns vehicle and route
- Trip lifecycle → Deliveries and inventory: drives delivery records
- Users and hierarchy → Customer service records: relates customers
