# devgabrielbrm/orizon-road-sentinel architecture

> Architecture diagram of the GitHub repository devgabrielbrm/orizon-road-sentinel, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/devgabrielbrm/orizon-road-sentinel
- Repository: https://github.com/devgabrielbrm/orizon-road-sentinel

## Overview

Orizon Road Sentinel is a trucker-focused operations cockpit for planning routes and freight, managing vehicle and trip records, tracking costs and receipts, and keeping documents and data available offline. The central workflow begins in the web cockpit, where a driver plans or records an operation; local ERP and calculation services support that work, while queued synchronization can reconcile records with Supabase. The tree also identifies authentication, compliance, maintenance, subscriptions, and payment functions. Several UI and integration links are based only on module references, so they are omitted or marked unverified rather than asserted as observed calls.

Main entry points: [`apps/web/src/App.tsx`](https://github.com/devgabrielbrm/orizon-road-sentinel/blob/main/apps/web/src/App.tsx) (Web cockpit), [`apps/web/src/lib/erpBridge.ts`](https://github.com/devgabrielbrm/orizon-road-sentinel/blob/main/apps/web/src/lib/erpBridge.ts) (ERP operations), [`apps/web/src/lib/sync-engine.ts`](https://github.com/devgabrielbrm/orizon-road-sentinel/blob/main/apps/web/src/lib/sync-engine.ts) (Sync queue), [`apps/web/src/lib/db.ts`](https://github.com/devgabrielbrm/orizon-road-sentinel/blob/main/apps/web/src/lib/db.ts) (Offline database)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_cockpit["Driver cockpit"]
  node_app["Web cockpit<br/>[App.tsx]"]
  node_login["Login screen<br/>[HudLoginScreen.tsx]"]
end

subgraph group_operations["Road operations"]
  node_route_ui["Route planner"]
  node_route_api["Route services<br/>[roadApis.ts]"]
  node_freight_ui["Freight board"]
  node_truck_ui["Truck selector"]
  node_weather_ui["Route weather"]
  node_sentinel_data["Cockpit data<br/>[sentinelData.ts]"]
  node_freight_function["Live freight function<br/>[index.ts]"]
end

subgraph group_records["ERP and records"]
  node_erp_view["ERP and vault"]
  node_erp_bridge["ERP operations<br/>[erpBridge.ts]"]
  node_maintenance["Predictive maintenance"]
  node_local_db[("Offline database<br/>[db.ts]")]
  node_hud_bridge["Cockpit persistence<br/>[hudDexieBridge.ts]"]
end

subgraph group_platform["Access and sync"]
  node_sync["Sync queue<br/>[sync-engine.ts]"]
  node_supabase["Supabase client<br/>[supabase.ts]"]
  node_auth["Authentication<br/>[AuthCabine.tsx]"]
  node_plans["Plan access<br/>[usePlanoAcesso.ts]"]
  node_subscription_ui["Plan upgrades"]
  node_payment_functions["Payment functions<br/>[index.ts]"]
  node_payment_webhook["Payment webhook<br/>[index.ts]"]
end

subgraph group_compute["Shared computation"]
  node_math["Freight calculations<br/>[formulas.ts]"]
  node_rounding["Decimal rounding<br/>[rounding.ts]"]
  node_erp_math["ERP calculations<br/>[erp.ts]"]
  node_shared_types["Domain types<br/>[domain.types.ts]"]
end

node_driver(("Driver"))

node_driver -.->|"uses"| node_app
node_app -->|"loads ERP data"| node_erp_bridge
node_app -->|"processes queue"| node_sync
node_app -.->|"presents"| node_login
node_app -.->|"presents"| node_route_ui
node_app -.->|"presents"| node_freight_ui
node_app -.->|"presents"| node_truck_ui
node_app -.->|"presents"| node_weather_ui
node_sentinel_data -->|"calculates route"| node_route_api
node_freight_ui -.->|"requests live freight"| node_freight_function
node_freight_ui -.->|"uses autocomplete"| node_route_ui
node_truck_ui -.->|"uses road data"| node_route_api
node_erp_view -->|"records ERP changes"| node_erp_bridge
node_maintenance -.->|"uses ERP operations"| node_erp_bridge
node_maintenance -.->|"reads records"| node_local_db
node_erp_bridge -->|"writes records"| node_local_db
node_erp_bridge -->|"queues updates"| node_sync
node_hud_bridge -->|"persists cockpit data"| node_local_db
node_hud_bridge -->|"queues and hydrates"| node_sync
node_sync -->|"reads and writes"| node_local_db
node_sync -->|"syncs cloud records"| node_supabase
node_auth -.->|"authenticates"| node_supabase
node_plans -->|"reads subscription"| node_supabase
node_subscription_ui -.->|"uses plan data"| node_supabase
node_payment_functions -.->|"payment lifecycle"| node_payment_webhook
node_math -->|"uses decimal helpers"| node_rounding
node_erp_math -->|"uses decimal helpers"| node_rounding

click node_app "https://github.com/devgabrielbrm/orizon-road-sentinel/blob/main/apps/web/src/App.tsx"
click node_login "https://github.com/devgabrielbrm/orizon-road-sentinel/blob/main/apps/web/src/components/HudLoginScreen.tsx"
click node_route_ui "https://github.com/devgabrielbrm/orizon-road-sentinel/blob/main/apps/web/src/components/CidadeAutocompleteHUD.tsx"
click node_route_api "https://github.com/devgabrielbrm/orizon-road-sentinel/blob/main/apps/web/src/lib/roadApis.ts"
click node_freight_ui "https://github.com/devgabrielbrm/orizon-road-sentinel/blob/main/apps/web/src/components/FretebrasMuralHUD.tsx"
click node_truck_ui "https://github.com/devgabrielbrm/orizon-road-sentinel/blob/main/apps/web/src/components/FipeTruckSelectorHUD.tsx"
click node_weather_ui "https://github.com/devgabrielbrm/orizon-road-sentinel/blob/main/apps/web/src/components/ClimaRotaCardHUD.tsx"
click node_sentinel_data "https://github.com/devgabrielbrm/orizon-road-sentinel/blob/main/apps/web/src/data/sentinelData.ts"
click node_erp_view "https://github.com/devgabrielbrm/orizon-road-sentinel/blob/main/apps/web/src/components/OperacaoErpCofreView.tsx"
click node_erp_bridge "https://github.com/devgabrielbrm/orizon-road-sentinel/blob/main/apps/web/src/lib/erpBridge.ts"
click node_maintenance "https://github.com/devgabrielbrm/orizon-road-sentinel/blob/main/apps/web/src/components/ManutencaoPreditivaCardHUD.tsx"
click node_local_db "https://github.com/devgabrielbrm/orizon-road-sentinel/blob/main/apps/web/src/lib/db.ts"
click node_hud_bridge "https://github.com/devgabrielbrm/orizon-road-sentinel/blob/main/apps/web/src/lib/hudDexieBridge.ts"
click node_sync "https://github.com/devgabrielbrm/orizon-road-sentinel/blob/main/apps/web/src/lib/sync-engine.ts"
click node_supabase "https://github.com/devgabrielbrm/orizon-road-sentinel/blob/main/apps/web/src/lib/supabase.ts"
click node_auth "https://github.com/devgabrielbrm/orizon-road-sentinel/blob/main/apps/web/src/components/AuthCabine.tsx"
click node_plans "https://github.com/devgabrielbrm/orizon-road-sentinel/blob/main/apps/web/src/hooks/usePlanoAcesso.ts"
click node_subscription_ui "https://github.com/devgabrielbrm/orizon-road-sentinel/blob/main/apps/web/src/components/ModalPlanosUpgradeHUD.tsx"
click node_payment_functions "https://github.com/devgabrielbrm/orizon-road-sentinel/blob/main/supabase/functions/checkout-assinatura/index.ts"
click node_payment_webhook "https://github.com/devgabrielbrm/orizon-road-sentinel/blob/main/supabase/functions/webhook-pagamento/index.ts"
click node_freight_function "https://github.com/devgabrielbrm/orizon-road-sentinel/blob/main/supabase/functions/fretebras-live/index.ts"
click node_math "https://github.com/devgabrielbrm/orizon-road-sentinel/blob/main/packages/math-engine/src/formulas.ts"
click node_rounding "https://github.com/devgabrielbrm/orizon-road-sentinel/blob/main/packages/math-engine/src/rounding.ts"
click node_erp_math "https://github.com/devgabrielbrm/orizon-road-sentinel/blob/main/packages/math-engine/src/erp.ts"
click node_shared_types "https://github.com/devgabrielbrm/orizon-road-sentinel/blob/main/packages/shared-types/src/domain.types.ts"

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_app,node_login toneBlue
class node_route_ui,node_route_api,node_freight_ui,node_truck_ui,node_weather_ui,node_sentinel_data,node_freight_function toneAmber
class node_erp_view,node_erp_bridge,node_maintenance,node_local_db,node_hud_bridge toneMint
class node_sync,node_supabase,node_auth,node_plans,node_subscription_ui,node_payment_functions,node_payment_webhook toneRose
class node_math,node_rounding,node_erp_math,node_shared_types,node_driver toneIndigo
```

## Components

### Driver cockpit

- [Web cockpit](https://github.com/devgabrielbrm/orizon-road-sentinel/blob/main/apps/web/src/App.tsx): `apps/web/src/App.tsx`
- [Login screen](https://github.com/devgabrielbrm/orizon-road-sentinel/blob/main/apps/web/src/components/HudLoginScreen.tsx): `apps/web/src/components/HudLoginScreen.tsx`

### Road operations

- [Route planner](https://github.com/devgabrielbrm/orizon-road-sentinel/blob/main/apps/web/src/components/CidadeAutocompleteHUD.tsx): `apps/web/src/components/CidadeAutocompleteHUD.tsx`
- [Route services](https://github.com/devgabrielbrm/orizon-road-sentinel/blob/main/apps/web/src/lib/roadApis.ts): `apps/web/src/lib/roadApis.ts`
- [Freight board](https://github.com/devgabrielbrm/orizon-road-sentinel/blob/main/apps/web/src/components/FretebrasMuralHUD.tsx): `apps/web/src/components/FretebrasMuralHUD.tsx`
- [Truck selector](https://github.com/devgabrielbrm/orizon-road-sentinel/blob/main/apps/web/src/components/FipeTruckSelectorHUD.tsx): `apps/web/src/components/FipeTruckSelectorHUD.tsx`
- [Route weather](https://github.com/devgabrielbrm/orizon-road-sentinel/blob/main/apps/web/src/components/ClimaRotaCardHUD.tsx): `apps/web/src/components/ClimaRotaCardHUD.tsx`
- [Cockpit data](https://github.com/devgabrielbrm/orizon-road-sentinel/blob/main/apps/web/src/data/sentinelData.ts): `apps/web/src/data/sentinelData.ts`
- [Live freight function](https://github.com/devgabrielbrm/orizon-road-sentinel/blob/main/supabase/functions/fretebras-live/index.ts): `supabase/functions/fretebras-live/index.ts`

### ERP and records

- [ERP and vault](https://github.com/devgabrielbrm/orizon-road-sentinel/blob/main/apps/web/src/components/OperacaoErpCofreView.tsx): `apps/web/src/components/OperacaoErpCofreView.tsx`
- [ERP operations](https://github.com/devgabrielbrm/orizon-road-sentinel/blob/main/apps/web/src/lib/erpBridge.ts): `apps/web/src/lib/erpBridge.ts`
- [Predictive maintenance](https://github.com/devgabrielbrm/orizon-road-sentinel/blob/main/apps/web/src/components/ManutencaoPreditivaCardHUD.tsx): `apps/web/src/components/ManutencaoPreditivaCardHUD.tsx`
- [Offline database](https://github.com/devgabrielbrm/orizon-road-sentinel/blob/main/apps/web/src/lib/db.ts): `apps/web/src/lib/db.ts`
- [Cockpit persistence](https://github.com/devgabrielbrm/orizon-road-sentinel/blob/main/apps/web/src/lib/hudDexieBridge.ts): `apps/web/src/lib/hudDexieBridge.ts`

### Access and sync

- [Sync queue](https://github.com/devgabrielbrm/orizon-road-sentinel/blob/main/apps/web/src/lib/sync-engine.ts): `apps/web/src/lib/sync-engine.ts`
- [Supabase client](https://github.com/devgabrielbrm/orizon-road-sentinel/blob/main/apps/web/src/lib/supabase.ts): `apps/web/src/lib/supabase.ts`
- [Authentication](https://github.com/devgabrielbrm/orizon-road-sentinel/blob/main/apps/web/src/components/AuthCabine.tsx): `apps/web/src/components/AuthCabine.tsx`
- [Plan access](https://github.com/devgabrielbrm/orizon-road-sentinel/blob/main/apps/web/src/hooks/usePlanoAcesso.ts): `apps/web/src/hooks/usePlanoAcesso.ts`
- [Plan upgrades](https://github.com/devgabrielbrm/orizon-road-sentinel/blob/main/apps/web/src/components/ModalPlanosUpgradeHUD.tsx): `apps/web/src/components/ModalPlanosUpgradeHUD.tsx`
- [Payment functions](https://github.com/devgabrielbrm/orizon-road-sentinel/blob/main/supabase/functions/checkout-assinatura/index.ts): `supabase/functions/checkout-assinatura/index.ts`
- [Payment webhook](https://github.com/devgabrielbrm/orizon-road-sentinel/blob/main/supabase/functions/webhook-pagamento/index.ts): `supabase/functions/webhook-pagamento/index.ts`

### Shared computation

- [Freight calculations](https://github.com/devgabrielbrm/orizon-road-sentinel/blob/main/packages/math-engine/src/formulas.ts): `packages/math-engine/src/formulas.ts`
- [Decimal rounding](https://github.com/devgabrielbrm/orizon-road-sentinel/blob/main/packages/math-engine/src/rounding.ts): `packages/math-engine/src/rounding.ts`
- [ERP calculations](https://github.com/devgabrielbrm/orizon-road-sentinel/blob/main/packages/math-engine/src/erp.ts): `packages/math-engine/src/erp.ts`
- [Domain types](https://github.com/devgabrielbrm/orizon-road-sentinel/blob/main/packages/shared-types/src/domain.types.ts): `packages/shared-types/src/domain.types.ts`

### Other components

- **Driver**

## Connections

- Driver → Web cockpit: uses
- Web cockpit → ERP operations: loads ERP data (evidence: `apps/web/src/App.tsx`)
- Web cockpit → Sync queue: processes queue (evidence: `apps/web/src/App.tsx`)
- Web cockpit → Login screen: presents (evidence: `apps/web/src/App.tsx`)
- Web cockpit → Route planner: presents (evidence: `apps/web/src/App.tsx`)
- Web cockpit → Freight board: presents (evidence: `apps/web/src/App.tsx`)
- Web cockpit → Truck selector: presents (evidence: `apps/web/src/App.tsx`)
- Web cockpit → Route weather: presents (evidence: `apps/web/src/App.tsx`)
- Cockpit data → Route services: calculates route (evidence: `apps/web/src/data/sentinelData.ts`)
- Freight board → Live freight function: requests live freight
- Freight board → Route planner: uses autocomplete (evidence: `apps/web/src/components/FretebrasMuralHUD.tsx`)
- Truck selector → Route services: uses road data (evidence: `apps/web/src/components/FipeTruckSelectorHUD.tsx`)
- ERP and vault → ERP operations: records ERP changes (evidence: `apps/web/src/components/OperacaoErpCofreView.tsx`)
- Predictive maintenance → ERP operations: uses ERP operations (evidence: `apps/web/src/components/ManutencaoPreditivaCardHUD.tsx`)
- Predictive maintenance → Offline database: reads records (evidence: `apps/web/src/components/ManutencaoPreditivaCardHUD.tsx`)
- ERP operations → Offline database: writes records (evidence: `apps/web/src/lib/erpBridge.ts`)
- ERP operations → Sync queue: queues updates (evidence: `apps/web/src/lib/erpBridge.ts`)
- Cockpit persistence → Offline database: persists cockpit data (evidence: `apps/web/src/lib/hudDexieBridge.ts`)
- Cockpit persistence → Sync queue: queues and hydrates (evidence: `apps/web/src/lib/hudDexieBridge.ts`)
- Sync queue → Offline database: reads and writes (evidence: `apps/web/src/lib/sync-engine.ts`)
- Sync queue → Supabase client: syncs cloud records (evidence: `apps/web/src/lib/sync-engine.ts`)
- Authentication → Supabase client: authenticates (evidence: `apps/web/src/components/AuthCabine.tsx`)
- Plan access → Supabase client: reads subscription (evidence: `apps/web/src/hooks/usePlanoAcesso.ts`)
- Plan upgrades → Supabase client: uses plan data (evidence: `apps/web/src/components/ModalPlanosUpgradeHUD.tsx`)
- Payment functions → Payment webhook: payment lifecycle
- Freight calculations → Decimal rounding: uses decimal helpers (evidence: `packages/math-engine/src/formulas.ts`)
- ERP calculations → Decimal rounding: uses decimal helpers (evidence: `packages/math-engine/src/erp.ts`)
