# fsouida1-ux/real-time-delivery-and-fleet-monitoring-plateform architecture

> Architecture diagram of the GitHub repository fsouida1-ux/real-time-delivery-and-fleet-monitoring-plateform, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-11). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/fsouida1-ux/real-time-delivery-and-fleet-monitoring-plateform
- Repository: https://github.com/fsouida1-ux/real-time-delivery-and-fleet-monitoring-plateform

## Overview

This is a real-time delivery and fleet-monitoring platform. Order and GPS simulators generate events; order changes enter an outbox, while GPS events publish directly to Kafka. A consumer validates, deduplicates, cleans, and transactionally stores events; a separate periodic service computes metrics and alerts. SQL reporting views feed Metabase. The graph follows README capabilities and shown source calls; database and reporting internals are represented at subsystem level where their SQL was not excerpted.

Main entry points: [`infrastructure/postgres/001_tables.sql`](https://github.com/fsouida1-ux/real-time-delivery-and-fleet-monitoring-plateform/blob/main/infrastructure/postgres/001_tables.sql) (PostgreSQL), [`services/processing-consumer/src/consumer.py`](https://github.com/fsouida1-ux/real-time-delivery-and-fleet-monitoring-plateform/blob/main/services/processing-consumer/src/consumer.py) (Processing consumer), [`shared/python/delivery_shared/config.py`](https://github.com/fsouida1-ux/real-time-delivery-and-fleet-monitoring-plateform/blob/main/shared/python/delivery_shared/config.py) (Shared configuration), [`services/db-producer/src/producer.py`](https://github.com/fsouida1-ux/real-time-delivery-and-fleet-monitoring-plateform/blob/main/services/db-producer/src/producer.py) (DB producer)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_sources["Event sources"]
  node_order_sim["Order simulator<br/>[main.py]"]
  node_gps_sim["GPS simulator<br/>[main.py]"]
end

subgraph group_streaming["Event streaming"]
  node_outbox["Outbox trigger"]
  node_db_producer["DB producer<br/>[producer.py]"]
  node_kafka["Kafka topics"]
end

subgraph group_analytics["Processing and analytics"]
  node_consumer["Processing consumer<br/>[consumer.py]"]
  node_validation["GPS validation<br/>[validation.py]"]
  node_cleaning["GPS cleaning<br/>[cleaning.py]"]
  node_aggregator["Metrics aggregator<br/>[main.py]"]
  node_db_access["Aggregator DB access<br/>[db.py]"]
  node_config["Shared configuration<br/>[config.py]"]
end

subgraph group_reporting["Storage and reporting"]
  node_postgres[("PostgreSQL<br/>[001_tables.sql]")]
  node_views[("Reporting views")]
  node_metabase["Metabase dashboard"]
end

node_order_sim -->|"updates orders"| node_postgres
node_postgres -->|"triggers outbox"| node_outbox
node_db_producer -->|"polls outbox"| node_postgres
node_db_producer -->|"publishes orders"| node_kafka
node_gps_sim -->|"publishes GPS"| node_kafka
node_consumer -->|"consumes topics"| node_kafka
node_consumer -->|"validates GPS"| node_validation
node_consumer -->|"cleans GPS"| node_cleaning
node_consumer -->|"writes transactionally"| node_postgres
node_aggregator -->|"opens connection"| node_db_access
node_db_access -->|"connects to"| node_postgres
node_aggregator -->|"aggregates and scans"| node_postgres
node_postgres -->|"feeds reporting"| node_views
node_views -->|"drives dashboard"| node_metabase
node_db_producer -->|"reads settings"| node_config
node_gps_sim -->|"reads settings"| node_config
node_consumer -->|"reads settings"| node_config
node_aggregator -->|"reads thresholds"| node_config

click node_order_sim "https://github.com/fsouida1-ux/real-time-delivery-and-fleet-monitoring-plateform/blob/main/services/order-simulator/src/main.py"
click node_gps_sim "https://github.com/fsouida1-ux/real-time-delivery-and-fleet-monitoring-plateform/blob/main/services/gps-simulator/src/main.py"
click node_postgres "https://github.com/fsouida1-ux/real-time-delivery-and-fleet-monitoring-plateform/blob/main/infrastructure/postgres/001_tables.sql"
click node_outbox "https://github.com/fsouida1-ux/real-time-delivery-and-fleet-monitoring-plateform/blob/main/infrastructure/postgres/010_create_orders_outbox_trigger.sql"
click node_db_producer "https://github.com/fsouida1-ux/real-time-delivery-and-fleet-monitoring-plateform/blob/main/services/db-producer/src/producer.py"
click node_consumer "https://github.com/fsouida1-ux/real-time-delivery-and-fleet-monitoring-plateform/blob/main/services/processing-consumer/src/consumer.py"
click node_validation "https://github.com/fsouida1-ux/real-time-delivery-and-fleet-monitoring-plateform/blob/main/services/processing-consumer/src/validation.py"
click node_cleaning "https://github.com/fsouida1-ux/real-time-delivery-and-fleet-monitoring-plateform/blob/main/services/processing-consumer/src/cleaning.py"
click node_aggregator "https://github.com/fsouida1-ux/real-time-delivery-and-fleet-monitoring-plateform/blob/main/services/metrics-aggregator/src/main.py"
click node_db_access "https://github.com/fsouida1-ux/real-time-delivery-and-fleet-monitoring-plateform/blob/main/services/metrics-aggregator/src/db.py"
click node_config "https://github.com/fsouida1-ux/real-time-delivery-and-fleet-monitoring-plateform/blob/main/shared/python/delivery_shared/config.py"
click node_views "https://github.com/fsouida1-ux/real-time-delivery-and-fleet-monitoring-plateform/blob/main/reporting/views/001_create_reporting_views.sql"

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_order_sim,node_gps_sim toneBlue
class node_outbox,node_db_producer,node_kafka toneAmber
class node_consumer,node_validation,node_cleaning,node_aggregator,node_db_access,node_config toneMint
class node_postgres,node_views,node_metabase toneRose
```

## Components

### Event sources

- [Order simulator](https://github.com/fsouida1-ux/real-time-delivery-and-fleet-monitoring-plateform/blob/main/services/order-simulator/src/main.py): `services/order-simulator/src/main.py`
- [GPS simulator](https://github.com/fsouida1-ux/real-time-delivery-and-fleet-monitoring-plateform/blob/main/services/gps-simulator/src/main.py): `services/gps-simulator/src/main.py`

### Event streaming

- [Outbox trigger](https://github.com/fsouida1-ux/real-time-delivery-and-fleet-monitoring-plateform/blob/main/infrastructure/postgres/010_create_orders_outbox_trigger.sql): `infrastructure/postgres/010_create_orders_outbox_trigger.sql`
- [DB producer](https://github.com/fsouida1-ux/real-time-delivery-and-fleet-monitoring-plateform/blob/main/services/db-producer/src/producer.py): `services/db-producer/src/producer.py`
- **Kafka topics**

### Processing and analytics

- [Processing consumer](https://github.com/fsouida1-ux/real-time-delivery-and-fleet-monitoring-plateform/blob/main/services/processing-consumer/src/consumer.py): `services/processing-consumer/src/consumer.py`
- [GPS validation](https://github.com/fsouida1-ux/real-time-delivery-and-fleet-monitoring-plateform/blob/main/services/processing-consumer/src/validation.py): `services/processing-consumer/src/validation.py`
- [GPS cleaning](https://github.com/fsouida1-ux/real-time-delivery-and-fleet-monitoring-plateform/blob/main/services/processing-consumer/src/cleaning.py): `services/processing-consumer/src/cleaning.py`
- [Metrics aggregator](https://github.com/fsouida1-ux/real-time-delivery-and-fleet-monitoring-plateform/blob/main/services/metrics-aggregator/src/main.py): `services/metrics-aggregator/src/main.py`
- [Aggregator DB access](https://github.com/fsouida1-ux/real-time-delivery-and-fleet-monitoring-plateform/blob/main/services/metrics-aggregator/src/db.py): `services/metrics-aggregator/src/db.py`
- [Shared configuration](https://github.com/fsouida1-ux/real-time-delivery-and-fleet-monitoring-plateform/blob/main/shared/python/delivery_shared/config.py): `shared/python/delivery_shared/config.py`

### Storage and reporting

- [PostgreSQL](https://github.com/fsouida1-ux/real-time-delivery-and-fleet-monitoring-plateform/blob/main/infrastructure/postgres/001_tables.sql): `infrastructure/postgres/001_tables.sql`
- [Reporting views](https://github.com/fsouida1-ux/real-time-delivery-and-fleet-monitoring-plateform/blob/main/reporting/views/001_create_reporting_views.sql): `reporting/views/001_create_reporting_views.sql`
- **Metabase dashboard**

## Connections

- Order simulator → PostgreSQL: updates orders (evidence: `services/order-simulator/src/main.py`)
- PostgreSQL → Outbox trigger: triggers outbox (evidence: `README.md`)
- DB producer → PostgreSQL: polls outbox (evidence: `services/db-producer/src/producer.py`)
- DB producer → Kafka topics: publishes orders (evidence: `services/db-producer/src/producer.py`)
- GPS simulator → Kafka topics: publishes GPS (evidence: `services/gps-simulator/src/main.py`)
- Processing consumer → Kafka topics: consumes topics (evidence: `services/processing-consumer/src/consumer.py`)
- Processing consumer → GPS validation: validates GPS (evidence: `services/processing-consumer/src/consumer.py`)
- Processing consumer → GPS cleaning: cleans GPS (evidence: `services/processing-consumer/src/consumer.py`)
- Processing consumer → PostgreSQL: writes transactionally (evidence: `services/processing-consumer/src/consumer.py`)
- Metrics aggregator → Aggregator DB access: opens connection (evidence: `services/metrics-aggregator/src/main.py`)
- Aggregator DB access → PostgreSQL: connects to (evidence: `services/metrics-aggregator/src/db.py`)
- Metrics aggregator → PostgreSQL: aggregates and scans (evidence: `services/metrics-aggregator/src/main.py`)
- PostgreSQL → Reporting views: feeds reporting (evidence: `README.md`)
- Reporting views → Metabase dashboard: drives dashboard (evidence: `README.md`)
- DB producer → Shared configuration: reads settings (evidence: `services/db-producer/src/producer.py`)
- GPS simulator → Shared configuration: reads settings (evidence: `services/gps-simulator/src/main.py`)
- Processing consumer → Shared configuration: reads settings (evidence: `services/processing-consumer/src/consumer.py`)
- Metrics aggregator → Shared configuration: reads thresholds (evidence: `services/metrics-aggregator/src/main.py`)
