# aljayvee/capstone_system_project architecture

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

- Interactive diagram: https://gitdiagram.com/aljayvee/capstone_system_project
- Repository: https://github.com/aljayvee/capstone_system_project

## Overview

SUGO On-The-Go is an operations portal for delivery logistics, with owner administration and dispatcher fulfillment as its main workflows. Users sign in, enter a role-protected portal, and manage fleet/business operations or triage errands through dispatch, customer chat, and settlement. The graph preserves major README capabilities even where their implementation was not sampled; those subsystem paths point to existing directories. Edges use route/source evidence or documented capabilities, so some internal feature-to-feature calls are intentionally omitted.

Main entry points: [`src/portals/owner/OwnerPortal.tsx`](https://github.com/aljayvee/capstone_system_project/blob/main/src/portals/owner/OwnerPortal.tsx) (Owner portal), [`src/portals/dispatcher`](https://github.com/aljayvee/capstone_system_project/tree/main/src/portals/dispatcher) (Errand triage), [`src/components/LoginPage.tsx`](https://github.com/aljayvee/capstone_system_project/blob/main/src/components/LoginPage.tsx) (Sign-in), [`src/services/apiService.ts`](https://github.com/aljayvee/capstone_system_project/blob/main/src/services/apiService.ts) (API methods)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_access["Access and sessions"]
  node_login["Sign-in<br/>[LoginPage.tsx]"]
  node_auth["Auth session<br/>[AuthContext.tsx]"]
  node_routes["Role routes<br/>[routes.tsx]"]
end

subgraph group_dispatch["Dispatcher fulfillment"]
  node_dispatcher["Dispatcher portal"]
  node_dispatch_ops["Errand triage"]
  node_order_chat["Order chat"]
  node_route_planning["Store pinning<br/>[useStorePins.ts]"]
  node_exceptions["Exception review"]
  node_settlement["Cash reconciliation"]
end

subgraph group_owner["Owner administration"]
  node_owner["Owner portal<br/>[OwnerPortal.tsx]"]
  node_dashboard["Business dashboard"]
  node_reports["Financial reports"]
  node_staff["Staff management"]
  node_fleet["Rider fleet"]
  node_tracking["Live tracking"]
  node_merchants["Merchant categories"]
  node_rates["Service rates"]
  node_places["Places directory"]
end

subgraph group_platform["Shared services"]
  node_api["API methods<br/>[apiService.ts]"]
  node_http["HTTP client<br/>[apiClient.ts]"]
  node_realtime["Realtime session<br/>[realtimeSession.ts]"]
  node_firebase[("Firebase database<br/>[config.ts]")]
  node_fleet_presence["Fleet presence feed"]
end

subgraph group_backend["Backend and data"]
  node_backend_api["Backend API<br/>[server.js]"]
  node_database[("SQL database<br/>[db.js]")]
end

node_operator(("Staff user"))

node_operator -->|"signs in"| node_login
node_login -->|"establishes session"| node_auth
node_login -->|"requests login"| node_api
node_auth -->|"refreshes token"| node_http
node_auth -->|"starts session"| node_realtime
node_routes -->|"routes guests"| node_login
node_routes -->|"protects owner route"| node_owner
node_routes -->|"protects dispatcher route"| node_dispatcher
node_dispatcher -.->|"coordinates dispatch"| node_dispatch_ops
node_dispatch_ops -.->|"opens errand chat"| node_order_chat
node_order_chat -->|"pins stores"| node_route_planning
node_dispatch_ops -.->|"triages exceptions"| node_exceptions
node_dispatch_ops -.->|"reconciles cash"| node_settlement
node_dispatcher -.->|"loads operations data"| node_api
node_owner -.->|"presents metrics"| node_dashboard
node_owner -.->|"opens reports"| node_reports
node_owner -.->|"manages users"| node_staff
node_owner -.->|"manages riders"| node_fleet
node_owner -.->|"tracks fleet"| node_tracking
node_owner -.->|"configures categories"| node_merchants
node_owner -->|"configures rates"| node_rates
node_owner -->|"opens directory"| node_places
node_owner -->|"loads fleet presence"| node_fleet_presence
node_fleet_presence -->|"reads telemetry"| node_firebase
node_fleet_presence -->|"loads rider roster"| node_api
node_api -->|"sends requests"| node_http
node_realtime -->|"requests auth token"| node_http
node_http -.->|"calls API"| node_backend_api
node_backend_api -->|"queries SQL"| node_database

click node_login "https://github.com/aljayvee/capstone_system_project/blob/main/src/components/LoginPage.tsx"
click node_auth "https://github.com/aljayvee/capstone_system_project/blob/main/src/context/AuthContext.tsx"
click node_routes "https://github.com/aljayvee/capstone_system_project/blob/main/src/app/routes.tsx"
click node_dispatcher "https://github.com/aljayvee/capstone_system_project/blob/main/src/portals/dispatcher/DispatcherPortal.tsx"
click node_dispatch_ops "https://github.com/aljayvee/capstone_system_project/tree/main/src/portals/dispatcher"
click node_order_chat "https://github.com/aljayvee/capstone_system_project/tree/main/src/portals/dispatcher/components/order-chat"
click node_route_planning "https://github.com/aljayvee/capstone_system_project/blob/main/src/portals/dispatcher/components/order-chat/hooks/useStorePins.ts"
click node_exceptions "https://github.com/aljayvee/capstone_system_project/tree/main/src/portals/dispatcher/components"
click node_settlement "https://github.com/aljayvee/capstone_system_project/tree/main/src/portals/owner/modules/reports"
click node_owner "https://github.com/aljayvee/capstone_system_project/blob/main/src/portals/owner/OwnerPortal.tsx"
click node_dashboard "https://github.com/aljayvee/capstone_system_project/tree/main/src/portals/owner/modules/dashboard"
click node_reports "https://github.com/aljayvee/capstone_system_project/tree/main/src/portals/owner/modules/reports"
click node_staff "https://github.com/aljayvee/capstone_system_project/tree/main/src/portals/owner/modules/users"
click node_fleet "https://github.com/aljayvee/capstone_system_project/tree/main/src/portals/owner/modules/riders"
click node_tracking "https://github.com/aljayvee/capstone_system_project/tree/main/src/portals/owner/modules/tracking"
click node_merchants "https://github.com/aljayvee/capstone_system_project/tree/main/src/portals/owner/modules/merchants"
click node_rates "https://github.com/aljayvee/capstone_system_project/blob/main/src/portals/owner/modules/rates/ServiceRatesModule.tsx"
click node_places "https://github.com/aljayvee/capstone_system_project/blob/main/src/portals/owner/screens/PlacesDirectoryScreen.tsx"
click node_api "https://github.com/aljayvee/capstone_system_project/blob/main/src/services/apiService.ts"
click node_http "https://github.com/aljayvee/capstone_system_project/blob/main/src/services/apiClient.ts"
click node_realtime "https://github.com/aljayvee/capstone_system_project/blob/main/src/firebase/realtimeSession.ts"
click node_firebase "https://github.com/aljayvee/capstone_system_project/blob/main/src/firebase/config.ts"
click node_fleet_presence "https://github.com/aljayvee/capstone_system_project/blob/main/src/hooks/useRiderFleetPresence.ts"
click node_backend_api "https://github.com/aljayvee/capstone_system_project/blob/main/Backend/src/server.js"
click node_database "https://github.com/aljayvee/capstone_system_project/blob/main/Backend/src/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_login,node_auth,node_routes,node_operator toneBlue
class node_dispatcher,node_dispatch_ops,node_order_chat,node_route_planning,node_exceptions,node_settlement toneAmber
class node_owner,node_dashboard,node_reports,node_staff,node_fleet,node_tracking,node_merchants,node_rates,node_places toneMint
class node_api,node_http,node_realtime,node_firebase,node_fleet_presence toneRose
class node_backend_api,node_database toneIndigo
```

## Components

### Access and sessions

- [Sign-in](https://github.com/aljayvee/capstone_system_project/blob/main/src/components/LoginPage.tsx): `src/components/LoginPage.tsx`
- [Auth session](https://github.com/aljayvee/capstone_system_project/blob/main/src/context/AuthContext.tsx): `src/context/AuthContext.tsx`
- [Role routes](https://github.com/aljayvee/capstone_system_project/blob/main/src/app/routes.tsx): `src/app/routes.tsx`

### Dispatcher fulfillment

- [Dispatcher portal](https://github.com/aljayvee/capstone_system_project/blob/main/src/portals/dispatcher/DispatcherPortal.tsx): `src/portals/dispatcher/DispatcherPortal.tsx`
- [Errand triage](https://github.com/aljayvee/capstone_system_project/tree/main/src/portals/dispatcher): `src/portals/dispatcher`
- [Order chat](https://github.com/aljayvee/capstone_system_project/tree/main/src/portals/dispatcher/components/order-chat): `src/portals/dispatcher/components/order-chat`
- [Store pinning](https://github.com/aljayvee/capstone_system_project/blob/main/src/portals/dispatcher/components/order-chat/hooks/useStorePins.ts): `src/portals/dispatcher/components/order-chat/hooks/useStorePins.ts`
- [Exception review](https://github.com/aljayvee/capstone_system_project/tree/main/src/portals/dispatcher/components): `src/portals/dispatcher/components`
- [Cash reconciliation](https://github.com/aljayvee/capstone_system_project/tree/main/src/portals/owner/modules/reports): `src/portals/owner/modules/reports`

### Owner administration

- [Owner portal](https://github.com/aljayvee/capstone_system_project/blob/main/src/portals/owner/OwnerPortal.tsx): `src/portals/owner/OwnerPortal.tsx`
- [Business dashboard](https://github.com/aljayvee/capstone_system_project/tree/main/src/portals/owner/modules/dashboard): `src/portals/owner/modules/dashboard`
- [Financial reports](https://github.com/aljayvee/capstone_system_project/tree/main/src/portals/owner/modules/reports): `src/portals/owner/modules/reports`
- [Staff management](https://github.com/aljayvee/capstone_system_project/tree/main/src/portals/owner/modules/users): `src/portals/owner/modules/users`
- [Rider fleet](https://github.com/aljayvee/capstone_system_project/tree/main/src/portals/owner/modules/riders): `src/portals/owner/modules/riders`
- [Live tracking](https://github.com/aljayvee/capstone_system_project/tree/main/src/portals/owner/modules/tracking): `src/portals/owner/modules/tracking`
- [Merchant categories](https://github.com/aljayvee/capstone_system_project/tree/main/src/portals/owner/modules/merchants): `src/portals/owner/modules/merchants`
- [Service rates](https://github.com/aljayvee/capstone_system_project/blob/main/src/portals/owner/modules/rates/ServiceRatesModule.tsx): `src/portals/owner/modules/rates/ServiceRatesModule.tsx`
- [Places directory](https://github.com/aljayvee/capstone_system_project/blob/main/src/portals/owner/screens/PlacesDirectoryScreen.tsx): `src/portals/owner/screens/PlacesDirectoryScreen.tsx`

### Shared services

- [API methods](https://github.com/aljayvee/capstone_system_project/blob/main/src/services/apiService.ts): `src/services/apiService.ts`
- [HTTP client](https://github.com/aljayvee/capstone_system_project/blob/main/src/services/apiClient.ts): `src/services/apiClient.ts`
- [Realtime session](https://github.com/aljayvee/capstone_system_project/blob/main/src/firebase/realtimeSession.ts): `src/firebase/realtimeSession.ts`
- [Firebase database](https://github.com/aljayvee/capstone_system_project/blob/main/src/firebase/config.ts): `src/firebase/config.ts`
- [Fleet presence feed](https://github.com/aljayvee/capstone_system_project/blob/main/src/hooks/useRiderFleetPresence.ts): `src/hooks/useRiderFleetPresence.ts`

### Backend and data

- [Backend API](https://github.com/aljayvee/capstone_system_project/blob/main/Backend/src/server.js): `Backend/src/server.js`
- [SQL database](https://github.com/aljayvee/capstone_system_project/blob/main/Backend/src/db.js): `Backend/src/db.js`

### Other components

- **Staff user**

## Connections

- Staff user → Sign-in: signs in
- Sign-in → Auth session: establishes session (evidence: `src/components/LoginPage.tsx`)
- Sign-in → API methods: requests login (evidence: `src/services/apiService.ts`)
- Auth session → HTTP client: refreshes token (evidence: `src/context/AuthContext.tsx`)
- Auth session → Realtime session: starts session (evidence: `src/context/AuthContext.tsx`)
- Role routes → Sign-in: routes guests (evidence: `src/app/routes.tsx`)
- Role routes → Owner portal: protects owner route (evidence: `src/app/routes.tsx`)
- Role routes → Dispatcher portal: protects dispatcher route (evidence: `src/app/routes.tsx`)
- Dispatcher portal → Errand triage: coordinates dispatch (evidence: `README.md`)
- Errand triage → Order chat: opens errand chat (evidence: `README.md`)
- Order chat → Store pinning: pins stores (evidence: `src/portals/dispatcher/components/order-chat/hooks/useStorePins.ts`)
- Errand triage → Exception review: triages exceptions (evidence: `README.md`)
- Errand triage → Cash reconciliation: reconciles cash (evidence: `README.md`)
- Dispatcher portal → API methods: loads operations data (evidence: `README.md`)
- Owner portal → Business dashboard: presents metrics (evidence: `README.md`)
- Owner portal → Financial reports: opens reports (evidence: `README.md`)
- Owner portal → Staff management: manages users (evidence: `README.md`)
- Owner portal → Rider fleet: manages riders (evidence: `README.md`)
- Owner portal → Live tracking: tracks fleet (evidence: `README.md`)
- Owner portal → Merchant categories: configures categories (evidence: `README.md`)
- Owner portal → Service rates: configures rates (evidence: `src/portals/owner/modules/rates/ServiceRatesModule.tsx`)
- Owner portal → Places directory: opens directory (evidence: `src/app/routes.tsx`)
- Owner portal → Fleet presence feed: loads fleet presence (evidence: `src/hooks/useRiderFleetPresence.ts`)
- Fleet presence feed → Firebase database: reads telemetry (evidence: `src/hooks/useRiderFleetPresence.ts`)
- Fleet presence feed → API methods: loads rider roster (evidence: `src/hooks/useRiderFleetPresence.ts`)
- API methods → HTTP client: sends requests (evidence: `src/services/apiService.ts`)
- Realtime session → HTTP client: requests auth token (evidence: `src/firebase/realtimeSession.ts`)
- HTTP client → Backend API: calls API (evidence: `README.md`)
- Backend API → SQL database: queries SQL (evidence: `Backend/src/server.js`)
