📋 Recensement & Architecture
Système de collecte de données terrain — Formulaire XLSForm, Stack technique, Alternatives
Stack Technique — Infrastructure de Collecte
┌──────────────────┐
│ NGINX (:80/:443)│ SSL, reverse proxy
└──┬───┬───┬───────┘
│ │ │
┌────────▼┐┌──▼──┐┌─▼────────┐
│ KPI ││KoBoCAT││ ENKETO │
│ Django ││OpenRosa││ Express │
│ :8000 ││:8000 ││:8005 │
└───┬────┘└──┬───┘└──┬───────┘
┌──────────┼────────┼────────┼──────────┐
│ │ │ │ │
┌────▼──┐ ┌────▼──┐ ┌───▼──┐ ┌───▼──┐ ┌────▼───┐
│PostgreSQL││MongoDB│ │Redis │ │Redis │ │RabbitMQ│
│:5432 ││:27017 │ │Cache │ │Main │ │:5672 │
│(métadata)││(subms)│ │:6379 │ │:6380 │ │(queue) │
└─────────┘└───────┘└──────┘└──────┘└─────────┘
⚠️ Ports backend (5432,27017,6379,6380,5672) = JAMAIS exposés publiquement9 conteneurs Docker — Stack production IFPB
Pattern d'Intégration : Polling API v2
KoboToolbox ──API v2 (polling 5min)──▶ ETL Python ──▶ PostgreSQL ──▶ Fiscal Engine
│
Redis Queue (dedup) Pourquoi PAS webhook ?
- • Connectivité intermittente à Madagascar → webhooks non fiables
- • Pas de retry natif dans Kobo REST Services
- • Polling = contrôle total + retry facile + logging complet
Exigences Hardware
| Config | Minimum | Recommandé | Production IFPB |
|---|---|---|---|
| OS | Ubuntu 22.04 | Ubuntu 24.04 LTS | Ubuntu 24.04 |
| CPU | 2 cœurs | 4 cœurs | 4 cœurs |
| RAM | 4 GB | 8 GB | 8 GB |
| Stockage | 20 GB SSD | 50-100 GB SSD | 100 GB (~117GB photos) |
📸 Estimation stockage photos: 14 636 parcelles × ~4 photos × ~2 MB ≈ 117 GB sur 12 mois
Sécurité & RBAC
Transport
TLS 1.3 (Let's Encrypt auto)
Auth API
Token Bearer
RBAC
Owner / Editor / Viewer / Data Collector
Pare-feu
UFW : ports 80, 443 uniquement
Isolation
Docker networks séparés frontend/backend
Mapping RBAC IFPB → Rôles Système
Admin système 🔑 Owner
Superviseur Qualité ✏️ Editor
Receveur Municipal 👁️ Viewer (lecture seule)
Agents Recenseurs ×10 📱 Data Collector
Comparatif des Solutions de Collecte (7 solutions × critères)
🥇
#1 KoboToolbox Cloud
✅ Coût 0$, zéro maintenance
✅ API v2 pour extraction Python
✅ Très utilisé à Madagascar
✅ Immédiat disponible
→ Phase 1 / Pilot
🥈
#2 ODK Central Self-Hosted
`pyodk` = librairie Python officielle
Souveraineté données totale
Nécessite compétences IT (Docker)
→ Phase 2 optionnel
🥉
#3 SurveyCTO
Top qualité mais 198-499$/mois
`pysurveycto` par IDInsight
Trop cher pour budget communal seul
→ Si bailleur finance
❌ Solutions à Éviter
Magpi: coût par submission prohibitif (~3800$ pour 14k)
DataWinners: activité incertaine, pas d'écosystème Python
Akvo Flow: organisation en difficultés financières
Installation Self-Hosted
git clone https://github.com/kobotoolbox/kobo-install.git cd kobo-install && python3 -m venv venv && source venv/bin/activate pip install -r requirements.txt ./run.py --interactive # Options IFPB : Server production, SSL Yes, nginx-certbot, domain kf.ifpb.org
Backup & Monitoring
💾 Backup Quotidien (cron 2h)
# PostgreSQL (2 bases)
docker exec kobo-postgres pg_dump -U kobo kbo_kpi | gzip > backup/kpi.sql.gz
docker exec kobo-postgres pg_dump -U kobo kobocat | gzip > backup/kobocat.sql.gz
# MongoDB (soumissions JSON)
docker exec kobo-mongo mongodump --db kibo --archive | gzip > backup/mongo.gz
# Médias (photos)
tar czf backup/media.tar.gz /var/lib/docker/volumes/kobo-docker_kobo_media/
# Nettoyage 30 jours
find /opt/kobo-backup/ -maxdepth 1 -mtime +30 -exec rm -rf {} \;📊 Monitoring Stack
Prometheus ← cAdvisor ← Docker → Grafana → AlertManager → Telegram Métriques clés: RAM >85% ⚠️ | CPU >90% 🔴 | Disque <20% 🔴 HTTP 5xx >10/min 🔴 | Conteneur down 🔴
Phases Architecture Cible
Phase 1 — MVP/Pilot
KoboCloud (0$) ──Polling API v2──▶ PostgreSQL + Flask ──▶ Fiscal Engine
Phase 2 — Production
KoboSelf-hosted (Docker) ──ETL──▶ PostgreSQL + Fiscal Engine
↓ Monitoring (Grafana) ↓ Dashboard (React/Vue)
↓ Monitoring (Grafana) ↓ Dashboard (React/Vue)