# 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
```