Système de Routage Dynamique pour Véhicules d'Urgence avec Hyperledger Fabric
# 1. Install everything (Docker, Node.js, Fabric, dependencies)
./install.sh
# 2. Start the entire system
./start.sh
# 3. Open in browser
# Frontend: http://localhost:3001
# Backend: http://localhost:3000
# 4. Stop the system
./stop.sh┌─────────────────────────────────────────────────────────────┐
│ Frontend React │
│ - Dashboard interactif (Material-UI) │
│ - Carte de ville en grille 10×10 │
│ - WebSocket temps réel │
│ Port 3001 │
└─────────────────────────────────────────────────────────────┘
↕ HTTP/WebSocket
┌─────────────────────────────────────────────────────────────┐
│ Backend Node.js API │
│ - Express.js + Socket.IO │
│ - Hyperledger Fabric SDK │
│ - Winston Logger │
│ Port 3000 │
└─────────────────────────────────────────────────────────────┘
↕ Fabric SDK (gRPC)
┌─────────────────────────────────────────────────────────────┐
│ Réseau Hyperledger Fabric 2.5 │
│ │
│ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │
│ │ CityOrg │ │ HospitalOrg │ │ FireOrg │ │
│ │ peer0/peer1 │ │ peer0/peer1 │ │ peer0/peer1 │ │
│ └──────────────┘ └──────────────┘ └──────────────┘ │
│ │
│ ┌──────────────┐ ┌─────────────────────┐ │
│ │ PoliceOrg │ │ Orderer │ │
│ │ peer0/peer1 │ │ (RAFT Consensus) │ │
│ └──────────────┘ └─────────────────────┘ │
│ │
│ Channel: routing | Chaincode: DynamicRoutingCC (JS) │
└─────────────────────────────────────────────────────────────┘
blockchain/
├── install.sh # Install all dependencies
├── start.sh # Start entire system
├── stop.sh # Stop entire system
│
├── chaincode/ # Smart Contract (Hyperledger Fabric)
│ ├── lib/
│ │ └── dynamicRouting.js
│ ├── index.js
│ └── package.json
│
├── network/ # Hyperledger Fabric Network Configuration
│ ├── configtx.yaml
│ ├── crypto-config.yaml
│ ├── docker-compose.yaml
│ └── scripts/
│ ├── create-channel.sh
│ └── deploy-chaincode.sh
│
├── backend/ # Node.js REST API
│ ├── src/
│ │ ├── server.js
│ │ ├── fabric.js
│ │ └── routes/
│ │ ├── vehicles.js
│ │ ├── emergencies.js
│ │ ├── routing.js
│ │ └── system.js
│ └── package.json
│
└── frontend/ # React Dashboard
├── public/
├── src/
│ ├── App.js
│ ├── components/
│ │ ├── Layout.js
│ │ ├── CityMap.js
│ │ ├── VehiclePanel.js
│ │ ├── EmergencyPanel.js
│ │ ├── StatsPanel.js
│ │ └── TransactionLog.js
│ └── services/
│ └── api.js
└── package.json
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/vehicles |
List all vehicles |
| POST | /api/vehicles/register |
Register new vehicle |
| GET | /api/vehicles/:id |
Get vehicle by ID |
| PUT | /api/vehicles/:id/position |
Update position |
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/emergencies/active |
List active emergencies |
| POST | /api/emergencies/declare |
Declare emergency |
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/routing/calculate |
Calculate route |
| POST | /api/routing/reserve |
Reserve route |
| POST | /api/routing/recalculate |
Recalculate after blockage |
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/system/stats |
System statistics |
| GET | /api/system/health |
Health check |
| POST | /api/system/attack |
Simulate attack |
| Type | Icon | Priority |
|---|---|---|
| NORMAL | 🚗 | 0 |
| AMBULANCE | 🚑 | 10+ |
| FIRE | 🚒 | 10+ |
| POLICE | 🚓 | 10+ |
ACCIDENT- Traffic accidentFIRE- Fire emergencyMEDICAL- Medical emergencyCRIME- Criminal incident
- MSP (Membership Service Provider) - Organization authentication
- TLS - Encrypted communications
- Endorsement Policy - Multi-org consensus validation
- Immutability - Unalterable transaction history
- Attack Detection - Simulated attack blocking
DOUBLE_RESERVATION- Double booking attemptFAKE_EMERGENCY- False emergency declarationROUTE_HIJACK- Route tampering attempt
| Service | Port |
|---|---|
| Frontend React | 3001 |
| Backend API | 3000 |
| Orderer | 7050 |
| CityOrg Peer0 | 7051 |
| CityOrg Peer1 | 7151 |
| HospitalOrg Peer0 | 8051 |
| HospitalOrg Peer1 | 8151 |
| FireOrg Peer0 | 9051 |
| FireOrg Peer1 | 9151 |
| PoliceOrg Peer0 | 10051 |
| PoliceOrg Peer1 | 10151 |
# Add user to docker group
sudo usermod -aG docker $USER
# Logout and login, or run:
newgrp docker# Check what's using the port
sudo lsof -i :3000
sudo lsof -i :3001
# Kill the process
kill -9 <PID>./stop.sh # Answer 'y' to clean up data
./start.shApache-2.0
| Organization | Role | Peers |
|---|---|---|
| CityOrg | Municipal management | peer0, peer1 |
| HospitalOrg | Hospital services (ambulances) | peer0, peer1 |
| FireOrg | Fire services | peer0, peer1 |
| PoliceOrg | Police services | peer0, peer1 |