# jrsantiagoo/enroute-v2 architecture

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

- Interactive diagram: https://gitdiagram.com/jrsantiagoo/enroute-v2
- Repository: https://github.com/jrsantiagoo/enroute-v2

## Overview

EnRoute is a logistics operations application for managers. The principal workflow is planning routes, assigning trips to drivers and vehicles, then monitoring orders, fleet efficiency, and operational performance through assignment views and a dashboard. Route planning also supports saved and suggested routes; the README documents OSRM-based routing and map rendering. The graph includes the documented product areas and the evidenced Express request path. Several frontend-to-backend calls and unsampled service implementations are not shown, so those connections are omitted or marked unverified.

Main entry points: [`server/src/app.js`](https://github.com/jrsantiagoo/enroute-v2/blob/main/server/src/app.js) (Express API), [`client/app/(protected)/route-tool/page.tsx`](https://github.com/jrsantiagoo/enroute-v2/blob/main/client/app/(protected)/route-tool/page.tsx) (Route Tool), [`client/components/routing/SavedRoutesTable.tsx`](https://github.com/jrsantiagoo/enroute-v2/blob/main/client/components/routing/SavedRoutesTable.tsx) (Saved Routes), [`client/components/routing/SuggestRoutesModal.tsx`](https://github.com/jrsantiagoo/enroute-v2/blob/main/client/components/routing/SuggestRoutesModal.tsx) (Route Suggestions)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_planning["Route Planning"]
  node_route_tool["Route Tool<br/>[page.tsx]"]
  node_saved_routes["Saved Routes"]
  node_route_suggestions["Route Suggestions"]
  node_route_storage[("Saved Route Storage<br/>[storageHelper.ts]")]
  node_routing_engine["Routing Engine<br/>[routingService.ts]"]
end

subgraph group_operations["Trip Operations"]
  node_assignment["Trip Assignment<br/>[page.tsx]"]
  node_fleet_page["Fleet Management<br/>[page.tsx]"]
end

subgraph group_insight["Monitoring"]
  node_orders_dashboard["Order Tracking<br/>[orders-table.tsx]"]
  node_dashboard["Operations Dashboard<br/>[page.tsx]"]
end

subgraph group_frontend["Manager Interface"]
  node_auth["Authentication<br/>[auth-shell.tsx]"]
  node_client_routes["Route API Client<br/>[routes.ts]"]
end

subgraph group_backend["API and Services"]
  node_api_app["Express API<br/>[app.js]"]
  node_trip_routes["Trip Endpoints<br/>[trip-routes.js]"]
  node_trip_controller["Trip Handlers<br/>[trip-controller.js]"]
  node_trip_service["Trip Logic<br/>[trip-service.js]"]
  node_order_routes["Order Endpoints<br/>[order-routes.js]"]
  node_order_controller["Order Handlers"]
  node_order_service["Order Logic<br/>[order-service.js]"]
  node_vehicle_controller["Vehicle Handlers"]
  node_vehicle_service["Vehicle Logic<br/>[vehicle-service.js]"]
  node_database[("PostgreSQL Database")]
  node_supabase["Supabase Auth"]
end

node_manager(("Logistics Manager"))
node_osrm["OSRM Service"]

node_manager -->|"plans routes"| node_route_tool
node_manager -->|"assigns trips"| node_assignment
node_manager -->|"manages fleet"| node_fleet_page
node_manager -->|"monitors operations"| node_dashboard
node_manager -->|"tracks orders"| node_orders_dashboard
node_route_tool -.->|"manages routes"| node_saved_routes
node_route_tool -.->|"requests suggestions"| node_route_suggestions
node_route_suggestions -->|"generates routes"| node_routing_engine
node_saved_routes -.->|"persists routes"| node_route_storage
node_routing_engine -.->|"requests routing"| node_osrm
node_client_routes -.->|"calls route API"| node_api_app
node_api_app -->|"mounts endpoints"| node_trip_routes
node_trip_routes -->|"dispatches requests"| node_trip_controller
node_trip_controller -->|"delegates trip logic"| node_trip_service
node_api_app -->|"mounts endpoints"| node_order_routes
node_order_routes -->|"dispatches requests"| node_order_controller
node_order_controller -->|"delegates order logic"| node_order_service
node_vehicle_controller -->|"delegates vehicle logic"| node_vehicle_service
node_auth -.->|"uses authentication"| node_supabase
node_api_app -.->|"authenticates requests"| node_supabase
node_trip_service -.->|"reads and writes"| node_database
node_order_service -.->|"reads and writes"| node_database
node_vehicle_service -.->|"reads and writes"| node_database

click node_route_tool "https://github.com/jrsantiagoo/enroute-v2/blob/main/client/app/(protected)/route-tool/page.tsx"
click node_saved_routes "https://github.com/jrsantiagoo/enroute-v2/blob/main/client/components/routing/SavedRoutesTable.tsx"
click node_route_suggestions "https://github.com/jrsantiagoo/enroute-v2/blob/main/client/components/routing/SuggestRoutesModal.tsx"
click node_route_storage "https://github.com/jrsantiagoo/enroute-v2/blob/main/client/lib/routing/storageHelper.ts"
click node_routing_engine "https://github.com/jrsantiagoo/enroute-v2/blob/main/client/lib/routing/routingService.ts"
click node_assignment "https://github.com/jrsantiagoo/enroute-v2/blob/main/client/app/(protected)/assignment/page.tsx"
click node_fleet_page "https://github.com/jrsantiagoo/enroute-v2/blob/main/client/app/(protected)/fleet-management/page.tsx"
click node_orders_dashboard "https://github.com/jrsantiagoo/enroute-v2/blob/main/client/components/dashboard/orders-table.tsx"
click node_dashboard "https://github.com/jrsantiagoo/enroute-v2/blob/main/client/app/(protected)/dashboard/page.tsx"
click node_auth "https://github.com/jrsantiagoo/enroute-v2/blob/main/client/components/auth/auth-shell.tsx"
click node_client_routes "https://github.com/jrsantiagoo/enroute-v2/blob/main/client/lib/api/routes.ts"
click node_api_app "https://github.com/jrsantiagoo/enroute-v2/blob/main/server/src/app.js"
click node_trip_routes "https://github.com/jrsantiagoo/enroute-v2/blob/main/server/src/routes/trip-routes.js"
click node_trip_controller "https://github.com/jrsantiagoo/enroute-v2/blob/main/server/src/controllers/trip-controller.js"
click node_trip_service "https://github.com/jrsantiagoo/enroute-v2/blob/main/server/src/services/trip-service.js"
click node_order_routes "https://github.com/jrsantiagoo/enroute-v2/blob/main/server/src/routes/order-routes.js"
click node_order_controller "https://github.com/jrsantiagoo/enroute-v2/blob/main/server/src/controllers/order-controller.js"
click node_order_service "https://github.com/jrsantiagoo/enroute-v2/blob/main/server/src/services/order-service.js"
click node_vehicle_controller "https://github.com/jrsantiagoo/enroute-v2/blob/main/server/src/controllers/vehicle-controller.js"
click node_vehicle_service "https://github.com/jrsantiagoo/enroute-v2/blob/main/server/src/services/vehicle-service.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_route_tool,node_saved_routes,node_route_suggestions,node_route_storage,node_routing_engine toneBlue
class node_assignment,node_fleet_page toneAmber
class node_orders_dashboard,node_dashboard toneMint
class node_auth,node_client_routes toneRose
class node_api_app,node_trip_routes,node_trip_controller,node_trip_service,node_order_routes,node_order_controller,node_order_service,node_vehicle_controller,node_vehicle_service,node_database,node_supabase,node_manager,node_osrm toneIndigo
```

## Components

### Route Planning

- [Route Tool](https://github.com/jrsantiagoo/enroute-v2/blob/main/client/app/(protected)/route-tool/page.tsx): `client/app/(protected)/route-tool/page.tsx`
- [Saved Routes](https://github.com/jrsantiagoo/enroute-v2/blob/main/client/components/routing/SavedRoutesTable.tsx): `client/components/routing/SavedRoutesTable.tsx`
- [Route Suggestions](https://github.com/jrsantiagoo/enroute-v2/blob/main/client/components/routing/SuggestRoutesModal.tsx): `client/components/routing/SuggestRoutesModal.tsx`
- [Saved Route Storage](https://github.com/jrsantiagoo/enroute-v2/blob/main/client/lib/routing/storageHelper.ts): `client/lib/routing/storageHelper.ts`
- [Routing Engine](https://github.com/jrsantiagoo/enroute-v2/blob/main/client/lib/routing/routingService.ts): `client/lib/routing/routingService.ts`

### Trip Operations

- [Trip Assignment](https://github.com/jrsantiagoo/enroute-v2/blob/main/client/app/(protected)/assignment/page.tsx): `client/app/(protected)/assignment/page.tsx`
- [Fleet Management](https://github.com/jrsantiagoo/enroute-v2/blob/main/client/app/(protected)/fleet-management/page.tsx): `client/app/(protected)/fleet-management/page.tsx`

### Monitoring

- [Order Tracking](https://github.com/jrsantiagoo/enroute-v2/blob/main/client/components/dashboard/orders-table.tsx): `client/components/dashboard/orders-table.tsx`
- [Operations Dashboard](https://github.com/jrsantiagoo/enroute-v2/blob/main/client/app/(protected)/dashboard/page.tsx): `client/app/(protected)/dashboard/page.tsx`

### Manager Interface

- [Authentication](https://github.com/jrsantiagoo/enroute-v2/blob/main/client/components/auth/auth-shell.tsx): `client/components/auth/auth-shell.tsx`
- [Route API Client](https://github.com/jrsantiagoo/enroute-v2/blob/main/client/lib/api/routes.ts): `client/lib/api/routes.ts`

### API and Services

- [Express API](https://github.com/jrsantiagoo/enroute-v2/blob/main/server/src/app.js): `server/src/app.js`
- [Trip Endpoints](https://github.com/jrsantiagoo/enroute-v2/blob/main/server/src/routes/trip-routes.js): `server/src/routes/trip-routes.js`
- [Trip Handlers](https://github.com/jrsantiagoo/enroute-v2/blob/main/server/src/controllers/trip-controller.js): `server/src/controllers/trip-controller.js`
- [Trip Logic](https://github.com/jrsantiagoo/enroute-v2/blob/main/server/src/services/trip-service.js): `server/src/services/trip-service.js`
- [Order Endpoints](https://github.com/jrsantiagoo/enroute-v2/blob/main/server/src/routes/order-routes.js): `server/src/routes/order-routes.js`
- [Order Handlers](https://github.com/jrsantiagoo/enroute-v2/blob/main/server/src/controllers/order-controller.js): `server/src/controllers/order-controller.js`
- [Order Logic](https://github.com/jrsantiagoo/enroute-v2/blob/main/server/src/services/order-service.js): `server/src/services/order-service.js`
- [Vehicle Handlers](https://github.com/jrsantiagoo/enroute-v2/blob/main/server/src/controllers/vehicle-controller.js): `server/src/controllers/vehicle-controller.js`
- [Vehicle Logic](https://github.com/jrsantiagoo/enroute-v2/blob/main/server/src/services/vehicle-service.js): `server/src/services/vehicle-service.js`
- **PostgreSQL Database**
- **Supabase Auth**

### Other components

- **Logistics Manager**
- **OSRM Service**

## Connections

- Logistics Manager → Route Tool: plans routes (evidence: `README.md`)
- Logistics Manager → Trip Assignment: assigns trips (evidence: `README.md`)
- Logistics Manager → Fleet Management: manages fleet (evidence: `README.md`)
- Logistics Manager → Operations Dashboard: monitors operations (evidence: `README.md`)
- Logistics Manager → Order Tracking: tracks orders (evidence: `README.md`)
- Route Tool → Saved Routes: manages routes
- Route Tool → Route Suggestions: requests suggestions
- Route Suggestions → Routing Engine: generates routes (evidence: `client/components/routing/SuggestRoutesModal.tsx`)
- Saved Routes → Saved Route Storage: persists routes
- Routing Engine → OSRM Service: requests routing (evidence: `README.md`)
- Route API Client → Express API: calls route API
- Express API → Trip Endpoints: mounts endpoints (evidence: `server/src/app.js`)
- Trip Endpoints → Trip Handlers: dispatches requests (evidence: `server/src/routes/trip-routes.js`)
- Trip Handlers → Trip Logic: delegates trip logic (evidence: `server/src/controllers/trip-controller.js`)
- Express API → Order Endpoints: mounts endpoints (evidence: `server/src/app.js`)
- Order Endpoints → Order Handlers: dispatches requests (evidence: `server/src/routes/order-routes.js`)
- Order Handlers → Order Logic: delegates order logic (evidence: `server/src/controllers/order-controller.js`)
- Vehicle Handlers → Vehicle Logic: delegates vehicle logic (evidence: `server/src/controllers/vehicle-controller.js`)
- Authentication → Supabase Auth: uses authentication
- Express API → Supabase Auth: authenticates requests
- Trip Logic → PostgreSQL Database: reads and writes
- Order Logic → PostgreSQL Database: reads and writes
- Vehicle Logic → PostgreSQL Database: reads and writes
