# Smart City Digital Twin Martinique β€” Diagramme des Flux de DonnΓ©es **DerniΓ¨re mise Γ  jour :** 05 Mai 2026 **Projet :** Smart City Digital Twin Martinique --- ## Architecture Globale ```mermaid graph TB subgraph Simulateur["πŸ–₯️ Simulateur (Host Python)"] SIM[Smart City Simulator
10 capteurs
Intervalle: configurable] end subgraph MQTT_Brokers["πŸ“‘ MQTT Brokers"] EMQ[EMQX
port 11883] MOS[Mosquitto
port 1883] BUN[BunkerM
port 1900
MQTTS/TLS] end subgraph Stream["⚑ Event Streaming"] PUL[Pulsar
port 6650
Topics: smartcity-*] RED[Redpanda
port 8082 REST
Topics: traffic, air-quality, ...] end subgraph CB["πŸ”— Context Brokers"] ORI[Orion-LD
NGSI-LD
port 1026] STE[Stellio
NGSI-LD
port 8080] FRO[FROST-Server
SensorThings
port 8080] end subgraph Storage["πŸ’Ύ Stockage & MΓ©triques"] INF[InfluxDB
Bucket: iot_data
port 8086] PRO[Prometheus
Scrape: /metrics
port 9090] GEO[GeoServer
WMS/WFS/WMTS
port 8080] end subgraph IoT_Platform["🏒 Plateforme IoT"] ORM[OpenRemote Manager
MQTT Agent
port 8080] KC[Keycloak
port 8080] end subgraph VIZ["πŸ“Š Visualisation"] GRA[Grafana
Dashboards
port 3000] MAP[MapStore
WMS/WFS
port 8080] end subgraph Distribution["πŸ”„ Distribution Service"] DIST[Pulsar Distribution
Pulsar β†’ Brokers] end subgraph Consumer["πŸ“₯ Redpanda Consumer"] RCONS[Redpanda β†’ InfluxDB
REST β†’ InfluxDB] end %% ── Flux Simulateur ────────────────────────────────────────────────── SIM -->|"1️⃣ MQTT publish
city/sensors/{type}/{id}"| EMQ SIM -->|"1️⃣ MQTT publish"| MOS SIM -->|"1️⃣ MQTT publish"| BUN SIM -->|"2️⃣ HTTP POST
NGSI-LD"| ORI SIM -->|"2️⃣ HTTP POST
NGSI-LD"| STE SIM -->|"2️⃣ HTTP POST
SensorThings"| FRO SIM -->|"3️⃣ Pulsar client
pulsar://localhost:6650"| PUL SIM -->|"4️⃣ HTTP REST Proxy
localhost:8082/topics/"| RED SIM -->|"5️⃣ InfluxDB v2 API
async non-bloquant"| INF %% ── Flux Distribution (Pulsar β†’ Brokers) ────────────────────────────── PUL -->|"Consomme
smartcity-*"| DIST DIST -->|"Republish
MQTT"| EMQ DIST -->|"Republish
MQTT"| MOS DIST -->|"Republish
NGSI-LD"| ORI DIST -->|"Republish
NGSI-LD"| STE DIST -->|"Republish
SensorThings"| FRO %% ── Flux Redpanda β†’ InfluxDB ────────────────────────────────────────── RED -->|"REST poll
topics/{name}/offsets"| RCONS RCONS -->|"Line Protocol
Write API"| INF %% ── OpenRemote MQTT Agent ────────────────────────────────────────────── EMQ -->|"6️⃣ Subscribe
city/sensors/#"| ORM MOS -->|"6️⃣ Subscribe"| ORM BUN -->|"6️⃣ Subscribe"| ORM %% ── MΓ©triques Prometheus ──────────────────────────────────────────────── SIM -->|"7️⃣ /metrics
port 8001"| PRO EMQ -->|"/api/v5/metrics"| PRO STE -->|"/actuator/prometheus"| PRO FRO -->|"/metrics"| PRO INF -->|"/metrics"| PRO RED -->|"/public_metrics"| PRO ORM -->|"/actuator/prometheus"| PRO GRA -->|"/metrics"| PRO %% ── Visualisation ───────────────────────────────────────────────────── INF -->|"Datasources
Flux IoT"| GRA ORI -->|"NGSI-LD
Datasource"| GRA STE -->|"NGSI-LD
Datasource"| GRA FRO -->|"SensorThings
Datasource"| GRA GEO -->|"WMS/WMTS"| MAP ORM -->|MapSettings
Martinique| MAP ORM -->|"Live assets
REST"| GRA ``` --- ## Flux DΓ©taillΓ©s ### 1️⃣ Flux MQTT β€” Brokers | Broker | Port | Protocol | Topics | |--------|------|----------|--------| | EMQX | 11883 | MQTT | `city/sensors/{type}/{id}` | | Mosquitto | 1883 | MQTT | `city/sensors/{type}/{id}` | | BunkerM | 1900 | MQTTS (TLS) | `city/sensors/{type}/{id}` | Le simulateur publie simultanΓ©ment sur les 3 brokers. ### 2️⃣ Flux HTTP REST β€” Context Brokers | Broker | Format | Port | Topics | |--------|--------|------|--------| | Orion-LD | NGSI-LD | 1026 | EntitΓ©s par type | | Stellio | NGSI-LD | 8080 | EntitΓ©s par type | | FROST-Server | SensorThings | 8080 | Things β†’ Datastreams β†’ Observations | ### 3️⃣ Flux Pulsar β€” Event Streaming - **Topics** : `persistent://public/default/smartcity-traffic`, `smartcity-airquality`, `smartcity-parking`, `smartcity-noise`, `smartcity-weather`, `smartcity-light` - **Port binaire** : `6650` (connectable depuis le host) - **Distribution** : Le service `pulsar-distribution` consomme ces topics et republie vers les brokers MQTT et context brokers ### 4️⃣ Flux Redpanda β€” Kafka-compatible REST - **REST Proxy** : `http://localhost:8082` - **Topics** : `traffic`, `air-quality`, `parking`, `noise`, `weather`, `air-quality` - **Payload** : Base64(JSON) dans `{"records": [{"value": ""}]}` - **Consumer** : `redpanda/consumer.py` β€” poll toutes les 10s et Γ©crit dans InfluxDB ### 5️⃣ Flux InfluxDB β€” Temps RΓ©el - **API** : `http://localhost:8086/api/v2/write` - **Bucket** : `iot_data` - **Org** : `digitribe` - **Mode** : Asynchrone (thread daemon) pour ne pas bloquer le publish MQTT ### 6️⃣ OpenRemote β€” MQTT Agent L'agent MQTT d'OpenRemote souscrit aux topics `city/sensors/#` sur les brokers MQTT (EMQX, Mosquitto, BunkerM). Les payloads sont automatiquement parsΓ©s et les attributs des assets sont mis Γ  jour. **Configuration via Manager UI** (`https://openremote.digitribe.fr/manager/`) : 1. Se connecter avec `admin/Digitribe972` 2. Choisir le realm `smartcity` 3. **Assets β†’ Agents β†’ + Add Agent** 4. Type : **MQTT Agent** 5. Configurer : - **MQTT Broker URI** : `tcp://emqx_emqx_1:1883` (rΓ©seau smartcity-shared) - **Topic Filter** : `city/sensors/#` - **QoS** : 1 - **Enabled** : βœ… ### 7️⃣ Flux Prometheus β€” MΓ©triques | Service | Endpoint `/metrics` | Scrape | |---------|---------------------|--------| | Simulator | `localhost:8001` | βœ… | | EMQX | `emqx_emqx_1:8081/api/v5/metrics` | βœ… | | Stellio | `stellio-api-gateway:8080/actuator/prometheus` | βœ… | | FROST | `frost_http-web-1:8080/metrics` | βœ… | | InfluxDB | `smart-city-influxdb:8086/metrics` | βœ… | | Redpanda | `smart-city-redpanda-console:8080/public_metrics` | βœ… | | OpenRemote | `openremote-manager-1:8080/actuator/prometheus` | βœ… | | Grafana | `smart-city-grafana:3000/metrics` | βœ… | --- ## Tableau RΓ©capitulatif | Composant | Technologie | Port | Statut | |-----------|-------------|------|--------| | Simulator | Python + paho-mqtt | Host:8001 (metrics) | βœ… Actif | | EMQX | MQTT Broker | 11883 | βœ… ConnectΓ© | | Mosquitto | MQTT Broker | 1883 | βœ… ConnectΓ© | | BunkerM | MQTTS Broker | 1900 | βœ… ConnectΓ© | | Orion-LD | NGSI-LD Broker | 1026 | βœ… DonnΓ©es | | Stellio | NGSI-LD Broker | 8080 | βœ… DonnΓ©es | | FROST-Server | SensorThings API | 8080 | βœ… DonnΓ©es | | OpenRemote | IoT Platform | 8080 | βœ… UI OK | | InfluxDB | Time Series DB | 8086 | βœ… Bucket iot_data | | Redpanda | Kafka-compatible | 8082 REST | βœ… Topics actifs | | Pulsar | Event Streaming | 6650 | βœ… ConnectΓ© | | Prometheus | Metrics | 9090 (conf) | ⏳ Container arrΓͺtΓ© | | Grafana | Visualisation | 3000 | βœ… Dashboards | | GeoServer | Geo Data | 8080 | βœ… REST OK | | MapStore | Cartographie | 8080 | βœ… WMS/WMTS | --- ## Commandes Utiles ```bash # RedΓ©marrer le service de distribution Pulsar cd ~/smart-city-digital-twin-martinique docker build -t smart-city-pulsar-distribution:latest -f pulsar/Dockerfile pulsar/ docker compose -f docker-compose.yml -f docker-compose.distribution.yml up -d pulsar-distribution # RedΓ©marrer Prometheus (prometheus-brokers) cd ~/smart-city-digital-twin-martinique docker compose up -d prometheus-brokers # Lancer le consumer Redpanda (host) cd ~/smart-city-digital-twin-martinique python3 redpanda/consumer.py # VΓ©rifier les topics Redpanda curl -s http://localhost:8082/topics # VΓ©rifier les mΓ©triques simulator curl -s http://localhost:8001/metrics | grep "^simulator_" # Logs distribution service docker logs -f smart-city-pulsar-distribution ```