# thazbi/vehical-health-and-telemetry architecture

> Architecture diagram of the GitHub repository thazbi/vehical-health-and-telemetry, 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/thazbi/vehical-health-and-telemetry
- Repository: https://github.com/thazbi/vehical-health-and-telemetry

## Overview

SAJIVITA is a three-service vehicle monitoring platform: users register vehicles and configure per-vehicle limits, submit validated telemetry, then separately request alert evaluation. Vehicle and telemetry records and alert state are in memory. The README also documents a local dashboard and an optional Prometheus/Grafana/Loki/Alloy monitoring stack. Source excerpts show the service handlers, stores, and alert rules; monitoring integrations are included only at the README-documented level.

Main entry points: [`services/vehicle_service/app/main.py`](https://github.com/thazbi/vehical-health-and-telemetry/blob/main/services/vehicle_service/app/main.py) (Vehicle API), [`services/telemetry_service/app/main.py`](https://github.com/thazbi/vehical-health-and-telemetry/blob/main/services/telemetry_service/app/main.py) (Telemetry API), [`services/alert_service/app/main.py`](https://github.com/thazbi/vehical-health-and-telemetry/blob/main/services/alert_service/app/main.py) (Alert API), [`scripts/demo_host.py`](https://github.com/thazbi/vehical-health-and-telemetry/blob/main/scripts/demo_host.py) (Local demo host)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_registry["Vehicle registry"]
  node_vehicle_api["Vehicle API<br/>[main.py]"]
  node_vehicle_store[("Vehicle registry<br/>[store.py]")]
  node_vehicle_models["Vehicle preferences<br/>[vehicle.py]"]
end

subgraph group_ingestion["Telemetry ingestion"]
  node_telemetry_api["Telemetry API<br/>[main.py]"]
  node_telemetry_models["Telemetry validation<br/>[telemetry.py]"]
  node_telemetry_store[("Telemetry history<br/>[store.py]")]
  node_telemetry_vehicle_client["Vehicle lookup client<br/>[vehicle_client.py]"]
end

subgraph group_alerting["Alert evaluation"]
  node_alert_api["Alert API<br/>[main.py]"]
  node_alert_models["Alert event models<br/>[alert.py]"]
  node_alert_vehicle_client["Preference client<br/>[vehicle_client.py]"]
  node_alert_rules["Threshold rules<br/>[rules.py]"]
  node_alert_store[("Alert lifecycle state<br/>[store.py]")]
end

subgraph group_operations["Observability"]
  node_vehicle_metrics["Vehicle metrics<br/>[metrics.py]"]
  node_vehicle_logs["Vehicle logging<br/>[logging_config.py]"]
  node_telemetry_metrics["Telemetry metrics<br/>[metrics.py]"]
  node_telemetry_logs["Telemetry logging<br/>[logging_config.py]"]
  node_alert_metrics["Alert metrics<br/>[metrics.py]"]
  node_alert_logs["Alert logging<br/>[logging_config.py]"]
  node_prometheus["Prometheus"]
  node_grafana["Grafana dashboards"]
  node_loki_alloy["Loki and Alloy"]
end

node_user(("User or dashboard"))
node_demo["Local demo host<br/>[demo_host.py]"]

node_user -->|"uses demo"| node_demo
node_demo -->|"registers vehicles"| node_vehicle_api
node_demo -->|"sets preferences"| node_vehicle_api
node_demo -->|"submits readings"| node_telemetry_api
node_demo -->|"requests evaluation"| node_alert_api
node_vehicle_api -->|"reads and writes"| node_vehicle_store
node_vehicle_store -->|"stores records"| node_vehicle_models
node_telemetry_api -->|"validates input"| node_telemetry_models
node_telemetry_api -->|"checks vehicle"| node_telemetry_vehicle_client
node_telemetry_vehicle_client -->|"fetches vehicle"| node_vehicle_api
node_telemetry_api -->|"stores and lists"| node_telemetry_store
node_telemetry_store -->|"stores records"| node_telemetry_models
node_alert_api -->|"accepts event"| node_alert_models
node_alert_api -->|"gets preferences"| node_alert_vehicle_client
node_alert_vehicle_client -->|"fetches preferences"| node_vehicle_api
node_alert_api -->|"evaluates and queries"| node_alert_store
node_alert_store -->|"evaluates thresholds"| node_alert_rules
node_alert_store -->|"tracks alert state"| node_alert_models
node_vehicle_api -->|"updates metrics"| node_vehicle_metrics
node_vehicle_api -->|"logs requests"| node_vehicle_logs
node_telemetry_api -->|"updates metrics"| node_telemetry_metrics
node_telemetry_api -->|"logs requests"| node_telemetry_logs
node_alert_api -->|"updates metrics"| node_alert_metrics
node_alert_api -->|"logs requests"| node_alert_logs
node_prometheus -.->|"scrapes metrics"| node_vehicle_api
node_prometheus -.->|"scrapes metrics"| node_telemetry_api
node_prometheus -.->|"scrapes metrics"| node_alert_api
node_grafana -.->|"uses datasource"| node_prometheus
node_loki_alloy -.->|"supplies logs"| node_grafana

click node_demo "https://github.com/thazbi/vehical-health-and-telemetry/blob/main/scripts/demo_host.py"
click node_vehicle_api "https://github.com/thazbi/vehical-health-and-telemetry/blob/main/services/vehicle_service/app/main.py"
click node_vehicle_store "https://github.com/thazbi/vehical-health-and-telemetry/blob/main/services/vehicle_service/app/core/store.py"
click node_vehicle_models "https://github.com/thazbi/vehical-health-and-telemetry/blob/main/services/vehicle_service/app/models/vehicle.py"
click node_telemetry_api "https://github.com/thazbi/vehical-health-and-telemetry/blob/main/services/telemetry_service/app/main.py"
click node_telemetry_models "https://github.com/thazbi/vehical-health-and-telemetry/blob/main/services/telemetry_service/app/models/telemetry.py"
click node_telemetry_store "https://github.com/thazbi/vehical-health-and-telemetry/blob/main/services/telemetry_service/app/core/store.py"
click node_telemetry_vehicle_client "https://github.com/thazbi/vehical-health-and-telemetry/blob/main/services/telemetry_service/app/services/vehicle_client.py"
click node_alert_api "https://github.com/thazbi/vehical-health-and-telemetry/blob/main/services/alert_service/app/main.py"
click node_alert_models "https://github.com/thazbi/vehical-health-and-telemetry/blob/main/services/alert_service/app/models/alert.py"
click node_alert_vehicle_client "https://github.com/thazbi/vehical-health-and-telemetry/blob/main/services/alert_service/app/services/vehicle_client.py"
click node_alert_rules "https://github.com/thazbi/vehical-health-and-telemetry/blob/main/services/alert_service/app/services/rules.py"
click node_alert_store "https://github.com/thazbi/vehical-health-and-telemetry/blob/main/services/alert_service/app/core/store.py"
click node_vehicle_metrics "https://github.com/thazbi/vehical-health-and-telemetry/blob/main/services/vehicle_service/app/core/metrics.py"
click node_vehicle_logs "https://github.com/thazbi/vehical-health-and-telemetry/blob/main/services/vehicle_service/app/core/logging_config.py"
click node_telemetry_metrics "https://github.com/thazbi/vehical-health-and-telemetry/blob/main/services/telemetry_service/app/core/metrics.py"
click node_telemetry_logs "https://github.com/thazbi/vehical-health-and-telemetry/blob/main/services/telemetry_service/app/core/logging_config.py"
click node_alert_metrics "https://github.com/thazbi/vehical-health-and-telemetry/blob/main/services/alert_service/app/core/metrics.py"
click node_alert_logs "https://github.com/thazbi/vehical-health-and-telemetry/blob/main/services/alert_service/app/core/logging_config.py"

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_vehicle_api,node_vehicle_store,node_vehicle_models,node_user toneBlue
class node_telemetry_api,node_telemetry_models,node_telemetry_store,node_telemetry_vehicle_client toneAmber
class node_alert_api,node_alert_models,node_alert_vehicle_client,node_alert_rules,node_alert_store toneMint
class node_vehicle_metrics,node_vehicle_logs,node_telemetry_metrics,node_telemetry_logs,node_alert_metrics,node_alert_logs,node_prometheus,node_grafana,node_loki_alloy toneRose
class node_demo toneTeal
```

## Components

### Vehicle registry

- [Vehicle API](https://github.com/thazbi/vehical-health-and-telemetry/blob/main/services/vehicle_service/app/main.py): `services/vehicle_service/app/main.py`
- [Vehicle registry](https://github.com/thazbi/vehical-health-and-telemetry/blob/main/services/vehicle_service/app/core/store.py): `services/vehicle_service/app/core/store.py`
- [Vehicle preferences](https://github.com/thazbi/vehical-health-and-telemetry/blob/main/services/vehicle_service/app/models/vehicle.py): `services/vehicle_service/app/models/vehicle.py`

### Telemetry ingestion

- [Telemetry API](https://github.com/thazbi/vehical-health-and-telemetry/blob/main/services/telemetry_service/app/main.py): `services/telemetry_service/app/main.py`
- [Telemetry validation](https://github.com/thazbi/vehical-health-and-telemetry/blob/main/services/telemetry_service/app/models/telemetry.py): `services/telemetry_service/app/models/telemetry.py`
- [Telemetry history](https://github.com/thazbi/vehical-health-and-telemetry/blob/main/services/telemetry_service/app/core/store.py): `services/telemetry_service/app/core/store.py`
- [Vehicle lookup client](https://github.com/thazbi/vehical-health-and-telemetry/blob/main/services/telemetry_service/app/services/vehicle_client.py): `services/telemetry_service/app/services/vehicle_client.py`

### Alert evaluation

- [Alert API](https://github.com/thazbi/vehical-health-and-telemetry/blob/main/services/alert_service/app/main.py): `services/alert_service/app/main.py`
- [Alert event models](https://github.com/thazbi/vehical-health-and-telemetry/blob/main/services/alert_service/app/models/alert.py): `services/alert_service/app/models/alert.py`
- [Preference client](https://github.com/thazbi/vehical-health-and-telemetry/blob/main/services/alert_service/app/services/vehicle_client.py): `services/alert_service/app/services/vehicle_client.py`
- [Threshold rules](https://github.com/thazbi/vehical-health-and-telemetry/blob/main/services/alert_service/app/services/rules.py): `services/alert_service/app/services/rules.py`
- [Alert lifecycle state](https://github.com/thazbi/vehical-health-and-telemetry/blob/main/services/alert_service/app/core/store.py): `services/alert_service/app/core/store.py`

### Observability

- [Vehicle metrics](https://github.com/thazbi/vehical-health-and-telemetry/blob/main/services/vehicle_service/app/core/metrics.py): `services/vehicle_service/app/core/metrics.py`
- [Vehicle logging](https://github.com/thazbi/vehical-health-and-telemetry/blob/main/services/vehicle_service/app/core/logging_config.py): `services/vehicle_service/app/core/logging_config.py`
- [Telemetry metrics](https://github.com/thazbi/vehical-health-and-telemetry/blob/main/services/telemetry_service/app/core/metrics.py): `services/telemetry_service/app/core/metrics.py`
- [Telemetry logging](https://github.com/thazbi/vehical-health-and-telemetry/blob/main/services/telemetry_service/app/core/logging_config.py): `services/telemetry_service/app/core/logging_config.py`
- [Alert metrics](https://github.com/thazbi/vehical-health-and-telemetry/blob/main/services/alert_service/app/core/metrics.py): `services/alert_service/app/core/metrics.py`
- [Alert logging](https://github.com/thazbi/vehical-health-and-telemetry/blob/main/services/alert_service/app/core/logging_config.py): `services/alert_service/app/core/logging_config.py`
- **Prometheus**
- **Grafana dashboards**
- **Loki and Alloy**

### Other components

- **User or dashboard**
- [Local demo host](https://github.com/thazbi/vehical-health-and-telemetry/blob/main/scripts/demo_host.py): `scripts/demo_host.py`

## Connections

- User or dashboard → Local demo host: uses demo
- Local demo host → Vehicle API: registers vehicles
- Local demo host → Vehicle API: sets preferences
- Local demo host → Telemetry API: submits readings
- Local demo host → Alert API: requests evaluation
- Vehicle API → Vehicle registry: reads and writes (evidence: `services/vehicle_service/app/main.py`)
- Vehicle registry → Vehicle preferences: stores records (evidence: `services/vehicle_service/app/core/store.py`)
- Telemetry API → Telemetry validation: validates input (evidence: `services/telemetry_service/app/main.py`)
- Telemetry API → Vehicle lookup client: checks vehicle (evidence: `services/telemetry_service/app/main.py`)
- Vehicle lookup client → Vehicle API: fetches vehicle (evidence: `services/telemetry_service/app/services/vehicle_client.py`)
- Telemetry API → Telemetry history: stores and lists (evidence: `services/telemetry_service/app/main.py`)
- Telemetry history → Telemetry validation: stores records (evidence: `services/telemetry_service/app/core/store.py`)
- Alert API → Alert event models: accepts event (evidence: `services/alert_service/app/main.py`)
- Alert API → Preference client: gets preferences (evidence: `services/alert_service/app/main.py`)
- Preference client → Vehicle API: fetches preferences
- Alert API → Alert lifecycle state: evaluates and queries (evidence: `services/alert_service/app/main.py`)
- Alert lifecycle state → Threshold rules: evaluates thresholds (evidence: `services/alert_service/app/core/store.py`)
- Alert lifecycle state → Alert event models: tracks alert state (evidence: `services/alert_service/app/core/store.py`)
- Vehicle API → Vehicle metrics: updates metrics (evidence: `services/vehicle_service/app/main.py`)
- Vehicle API → Vehicle logging: logs requests (evidence: `services/vehicle_service/app/main.py`)
- Telemetry API → Telemetry metrics: updates metrics (evidence: `services/telemetry_service/app/main.py`)
- Telemetry API → Telemetry logging: logs requests (evidence: `services/telemetry_service/app/main.py`)
- Alert API → Alert metrics: updates metrics (evidence: `services/alert_service/app/main.py`)
- Alert API → Alert logging: logs requests (evidence: `services/alert_service/app/main.py`)
- Prometheus → Vehicle API: scrapes metrics
- Prometheus → Telemetry API: scrapes metrics
- Prometheus → Alert API: scrapes metrics
- Grafana dashboards → Prometheus: uses datasource
- Loki and Alloy → Grafana dashboards: supplies logs
