# Smart City Digital Twin - Architecture Docker (LoRaWAN Added)
**Date** : 12 mai 2026  
**Projet** : `smart-city-digital-twin-martinique`  
**Auteur** : Éric FELIXINE (via Hermes Agent)

---

## 1. Vue d'ensemble
Cette cartographie présente l'architecture Docker complète du jumeau numérique Smart City (Martinique), incluant les conteneurs, images, réseaux et ports exposés. **Mise à jour 2026-05-12** : ajout de ChirpStack et The Things Stack pour la connectivité LoRaWAN.

---

## 2. Flux de données principal

### Pipeline Orion-LD (Fonctionnel ✅)
```
Simulator → MQTT Brokers (Mosquitto/EMQX/BunkerM) → IoT Agents → Orion-LD → QuantumLeap → CrateDB (standard) → Grafana
```

### Pipeline Stellio (En cours de debug ⚠️)
```
Simulator → MQTT Brokers → IoT Agents → Stellio Context Broker → QuantumLeap-Stellio → CrateDB-Stellio → Grafana
```

### Pipeline LoRaWAN ChirpStack (Nouveau 🆕)
```
Gateway LoRaWAN (UDP 1700) → ChirpStack Gateway Bridge → ChirpStack → MQTT (Mosquitto interne) → EMQX → IoT Agents → Orion-LD → ...
```

### Pipeline LoRaWAN The Things Stack (Nouveau 🆕)
```
Gateway LoRaWAN (UDP 1700) → TTS Stack → MQTT/REST API → EMQX → IoT Agents → Orion-LD → ...
```

### Pipeline OpenRemote (En cours ⚠️)
```
Simulator → REST API (PUT assets avec location) → OpenRemote Manager → Map Martinique
Simulator → MQTT (Artemis broker) → OpenRemote Agents → Asset values
```

---

## 3. Liste des Conteneurs Actifs (Projet Smart City)

| Conteneur | Image | Réseaux | Ports |
|-----------|-------|----------|-------|
| `smart-city-simulator` | `smart-city-simulator:latest` | `smartcity-shared`, `traefik-public` | `1883/tcp` |
| `smart-city-mosquitto` | `eclipse-mosquitto:latest` | `smartcity-shared`, `traefik-public` | `1883:1883`, `9001:9001` |
| `smart-city-emqx` | `emqx/emqx:latest` | `smartcity-shared`, `traefik-public` | `11883:1883`, `18081:8081` |
| `smart-city-iot-agent-mosquitto` | `fiware/iotagent-json:latest` | `smartcity-shared` | `4041:4041` |
| `smart-city-iot-agent-emqx` | `fiware/iotagent-json:latest` | `smartcity-shared` | `4042:4041` |
| `smart-city-iot-agent-bunkerm` | `fiware/iotagent-json:latest` | `smartcity-shared` | `4043:4041` |
| **`smart-city-orion-ld`** | `quay.io/fiware/orion-ld` | `smartcity-shared`, `traefik-public` | `1026:1026` |
| **`smart-city-quantumleap`** | `fiware/quantum-leap:latest` | `smartcity-shared`, `traefik-public` | `8668:8668` |
| **`smart-city-cratedb`** | `crate:5.5` | `smartcity-shared` | `4200:4200`, `5432:5432` |
| **`stellio-api-gateway`** | `stellio/stellio-api-gateway:latest-dev` | `stellio-context-broker_default`, `traefik-public`, `smartcity-shared` | `8080:8080` |
| **`stellio-subscription-service`** | `stellio/stellio-subscription-service:latest-dev` | `stellio-context-broker_default`, `smartcity-shared` | `8084:8084` |
| **`stellio-search-service`** | `stellio/stellio-search-service:latest-dev` | `stellio-context-broker_default`, `traefik-public` | `8083:8083` |
| **`stellio-kafka`** | `confluentinc/cp-kafka:8.1.0` | `stellio-context-broker_default` | `9092:9092` |
| **`stellio-postgres`** | `stellio/stellio-timescale-postgis:16-2.24.0-3.6` | `stellio-context-broker_default` | `5432:5432` |
| **`smart-city-quantumleap-stellio`** | `fiware/quantum-leap:latest` | `smartcity-shared`, `traefik-public` | `8669:8668` |
| **`smart-city-cratedb-stellio`** | `crate:latest` | `smartcity-shared` | `4200:4200` |
| `smart-city-redis` | `redis:7-alpine` | `smartcity-shared` | `6379:6379` |
| `smart-city-grafana` | `grafana/grafana:latest` | `smartcity-shared`, `traefik-public` | `3000:3000` |
|| `openremote-manager-1` | `openremote/manager:latest` | `openremote_default`, `smartcity-shared` | `8080:8080`, `8443:8443` |
|| `openremote-keycloak-1` | `openremote/keycloak:latest` | `openremote_default`, `smartcity-shared` | `8080:8080`, `8443:8443` |
|| `traefik` | `traefik:v3.0` | `traefik-public`, `openremote_default` | `80:80`, `443:443` |
|| **ChirpStack LoRaWAN** | | | |
|| `chirpstack-chirpstack-1` | `chirpstack/chirpstack:4` | `chirpstack-internal`, `traefik-public`, `smartcity-shared` | `8080:8080` |
|| `chirpstack-gateway-bridge-1` | `chirpstack/chirpstack-gateway-bridge:4` | `chirpstack-internal` | `1700:1700/udp` |
|| `chirpstack-rest-api-1` | `chirpstack/chirpstack-rest-api:4` | `chirpstack-internal`, `traefik-public` | `8090:8090` |
|| `chirpstack-postgres-1` | `postgres:14-alpine` | `chirpstack-internal` | `5432` |
|| `chirpstack-redis-1` | `redis:7-alpine` | `chirpstack-internal` | `6379` |
|| `chirpstack-mosquitto-1` | `eclipse-mosquitto:2` | `chirpstack-internal`, `smartcity-shared` | `1883` |
|| **The Things Stack LoRaWAN** | | | |
|| `tts-stack-1` | `thethingsnetwork/lorawan-stack:latest` | `tts-internal`, `traefik-public`, `smartcity-shared` | `1885:1885`, `1884:1884`, `1700:1700/udp` |
|| `tts-postgres-1` | `postgres:14` | `tts-internal` | `5432` |
|| `tts-redis-1` | `redis:7` | `tts-internal` | `6379` |

---

## 4. Réseaux Docker

| Réseau | Conteneurs Connectés |
|---------|----------------------|
| `smartcity-shared` | Tous les services Smart City (simulator, brokers, context brokers, databases, grafana) |
| `stellio-context-broker_default` | Stellio services (api-gateway, subscription, search, kafka, postgres) |
| `traefik-public` | Services exposés via Traefik (grafana, mapstore, pulsar, stellio, orion, chirpstack, tts, etc.) |
| `openremote_default` | OpenRemote services (manager, keycloak, postgresql) |
| `chirpstack-internal` | ChirpStack services (chirpstack, gateway-bridge, rest-api, postgres, redis, mosquitto) |
| `tts-internal` | TTS services (stack, postgres, redis) |

---

## 5. Diagramme d'Architecture (Mermaid)

```mermaid
graph TD
    subgraph Simulator [Smart City Simulator]
        SIM[Simulator<br/>Python MQTT Publisher]
    end
    
    subgraph MQTT_Brokers [MQTT Brokers]
        MOSQ[Mosquitto<br/>:1883]
        EMQX[EMQX<br/>:11883]
        BUNKER[BunkerM<br/>:1884]
    end
    
    subgraph IoT_Agents [IoT Agents FIWARE]
        IOT_MOSQ[IoT Agent Mosquitto<br/>:4041]
        IOT_EMQX[IoT Agent EMQX<br/>:4042]
        IOT_BUNKER[IoT Agent BunkerM<br/>:4043]
    end
    
    subgraph Orion_LD_Pipeline [Orion-LD Pipeline ✅]
        ORION[Orion-LD<br/>:1026]
        QL[QuantumLeap<br/>:8668]
        CRATEDB[CrateDB<br/>:4200/:5432]
    end
    
    subgraph Stellio_Pipeline [Stellio Pipeline ⚠️]
        STELLIO[Stellio API Gateway<br/>:8080]
        SUB[Stellio Subscription<br/>:8084]
        QL_STELLIO[QuantumLeap-Stellio<br/>:8669]
        CRATEDB_STELLIO[CrateDB-Stellio<br/>:4200]
    end
    
    subgraph Visualization [Visualization Layer]
        GRAFANA[Grafana<br/>:3000<br/>21 Dashboards]
        MAPSTORE[MapStore<br/>:8080]
        OPENREMOTE[OpenRemote<br/>:8080]
    end
    
    subgraph Message_Broker [Message Broker]
        KAFKA[Stellio Kafka<br/>:9092]
    end
    
    %% Flux Simulator
    SIM -->|MQTT| MOSQ
    SIM -->|MQTT| EMQX
    SIM -->|MQTT| BUNKER
    
    %% Flux IoT Agents
    MOSQ -->|MQTT| IOT_MOSQ
    EMQX -->|MQTT| IOT_EMQX
    BUNKER -->|MQTT| IOT_BUNKER
    
    %% Flux Orion-LD (Working ✅)
    IOT_MOSQ -->|NGSI-v2| ORION
    IOT_EMQX -->|NGSI-v2| ORION
    IOT_BUNKER -->|NGSI-v2| ORION
    ORION -->|Subscription| QL
    QL -->|INSERT| CRATEDB
    CRATEDB -->|Query| GRAFANA
    
    %% Flux Stellio (In Progress ⚠️)
    IOT_MOSQ -->|NGSI-LD?| STELLIO
    IOT_EMQX -->|NGSI-LD?| STELLIO
    STELLIO -->|Subscription| QL_STELLIO
    QL_STELLIO -->|INSERT?| CRATEDB_STELLIO
    CRATEDB_STELLIO -->|Query| GRAFANA
    
    %% Kafka (Stellio internal)
    STELLIO --> KAFKA
    SUB --> KAFKA
    
    %% Visualization
    GRAFANA -->|Dashboards| User[Utilisateur]
    MAPSTORE -->|Maps| User
    OPENREMOTE -->|Assets| User
```

---

## 6. État des Pipelines

### ✅ Pipeline Orion-LD (Opérationnel)
- **Statut** : Entièrement fonctionnel
- **Données** : CrateDB contient 6 tables avec données (`etairqualityobserved` a 6+ rows)
- **Grafana** : Dashboard "Smart City - Air Quality (CrateDB)" fonctionnel
- **Subscription** : Orion-LD → QuantumLeap active (`lastNotification: 2026-05-07`)

### ⚠️ Pipeline Stellio (Debug en cours)
- **Statut** : Subscription créée, notifications reçues par QuantumLeap-Stellio
- **Problème** : Données ne persistent pas dans CrateDB-Stellio (0 rows)
- **Cause probable** : Mappage NGSI-LD → CrateDB incompatible
- **Subscription Stellio** : `urn:ngsi-ld:Subscription:0baad89d-1625-4b42-adc1-e841e04120ff`
  - Endpoint : `http://smart-city-quantumleap-stellio:8668/v2/notify`
  - Format : NGSI-LD normalized

---

## 7. Services Web Accessibles

| Service | URL | Identifiants | Statut |
|---------|-----|-------------|--------|
| **Grafana** | https://grafana.digitribe.fr | `admin` / `Digitribe972` | ✅ 21 dashboards |
| **MapStore** | https://mapstore.digitribe.fr/mapstore/ | - | ✅ Page charge |
| **Pulsar Manager** | https://pulsar.digitribe.fr | `pulsar` / `pulsar` | ✅ Interface OK |
| **OpenRemote** | https://openremote.digitribe.fr | `admin` / `Digitribe972` | ✅ Carte Martinique |
| **Orion-LD** | http://smart-city-orion-ld:1026 | - | ✅ Healthy |
| **Stellio** | http://stellio-api-gateway:8080 | - | ✅ Contient entités |

---

## 8. Connexions Clés

1. **Traefik** (`:80`/`:443`) : Reverse proxy pour tous les services exposés à l'hôte.
2. **Brokers MQTT** (Mosquitto `:1883`, EMQX `:11883`) : Réception des données du simulateur et des capteurs IoT.
3. **Context Brokers** (Orion-LD `:1026`, Stellio `:8080`) : Gestion des entités NGSI-LD.
4. **Time-Series DB** (CrateDB `:4200` HTTP API, `:5432` PostgreSQL) : Persistance des données pour Grafana.
5. **Grafana** (`:3000`) : Visualisation des données depuis CrateDB, InfluxDB, Prometheus.

---

## 9. Références

- **Projet** : `~/smart-city-digital-twin-martinique/`
- **Gitea** : https://gitea.digitribe.fr/eric/smart-city-digital-twin-martinique
- **Skills** : `smart-city-sensor-simulator`, `fiware-quantumleap`, `fiware-orion-ld`, `cratedb`
- **Documentation** : `RAPPORT_FINAL_2026-05-06.md`, `BILAN-2026-05-05.md`

---

*Architecture mise à jour le 07 mai 2026 à 21:00 (UTC-4) par Hermes Agent.*
