How wfp-vam/prism-app works
Project type and purpose
• This is a full-stack, multi-service mapping and data-visualization platform (WFP PRISM).
• It consists of three core services:
• Frontend (React + MapLibre, deployed as a static site)
• API service (Python/Flask or FastAPI for data ingestion, raster/vector processing)
• Alerting service (Node/TypeScript microservice with cron jobs, sends email alerts)
• A shared “common” library holds reusable code (e.g., OWS parsers).
File structure
• Top-level directories:
• frontend: CRA-based React app, Redux Toolkit, MapLibre, hosted on Firebase/CDN.
• api: Python app (uwsgi, pytest, STAC & WMS clients, Postgres via TypeORM equivalent).
• alerting: Node/TypeScript service with TypeORM migrations, email templates, cron scripts.
• common: TypeScript utilities for OWS (WMS/WFS/WCS), shared across services.
• Config, Dockerfiles, compose files, CI workflows (.github/workflows) span services.
• Deployment scripts: docker-compose, Firebase deploy, server_setup.sh, cron scripts.
README for additional insights
• Frontend README details configuration files (prism.json, layers.json, tables.json),
environment variables (REACT_APP_COUNTRY, map settings, OAuth, Sentry, Mapbox),
and build/deploy commands (yarn start/build, lint, CI/CD to Firebase channels).
• Highlights how the static site fetches geojson, WMS layers, CSV, point data via API calls.
Main components & interactions (to include
A. Frontend
• React app served from Firebase/CDN
• Uses Redux store slices for map state, layers, alerts
• Fetches:
• REST endpoints on API service (e.g., /api/alerts, /api/geotiff, /api/raster-utils)
• External WMS servers (Geonode GeoServer, Earthobservation VAM WPS)
• Point-data APIs (Kobo forms via Prism API)
• Common library functions (client-side HTTP utilities)
B. API service
• Python app with:
• Database layer (Postgres via SQLAlchemy or similar)
• Endpoints for STAC data, raster processing (zonal stats), caching, authentication
• Utilizes:
– geoTIFF/STAC clients
– Google Floods & Kobo clients
– Caching (Redis or in-memory)
• Exposes REST/JSON API consumed by frontend
C. Alerting service
• TypeScript Node service
• Scheduled cron jobs (cron_alert_run.sh, cron_aa_storm_alert_run.sh)
• TypeORM migrations and entities for alerts table
• Workers process storm & anticipatory action alerts
• Sends emails via templates (EJS)
D. Shared library
• NPM package under common/
• Provides OWS parsers (WMS/WFS/WCS), XML utils, bbox utilities
• Versioned and consumed by frontend & alerting
E. Database
• Postgres (hosted or containerized)
• Schemas for users, alerts, anticipatory_action_alerts
• Accessed by API & alerting service
F. External services
• GeoServer WMS endpoints
• Humanitarian Data Cube WCS/WFS
• STAC API endpoints
• Kobo/form API
• Sentry for monitoring
• Firebase Hosting & Channels for frontend
Architectural patterns & design principles
• Microservice pattern: three loosely-coupled services
• Shared library for DRY code (common)
• Cron-driven event processing in alerting
• Static site generation + SPA with external API calls
• Layered architecture in API (controllers → services → data access)
• Redux for client state separation (map, layers, alerts)
• Clear, concise labels (e.g., “MapLibre SPA”, “/alerts endpoint”).