How danamistartrail/margo-lestari works
This backend periodically gathers BMKG and Open-Meteo weather data, evaluates rainfall risk, records a history, and broadcasts a formatted alert to a WhatsApp community or channel. The main control flow and calls are visible in src/index.ts; the README documents the external services and operational capabilities. The README also describes a health-check server and RainViewer radar link. Edges for these documented integrations cite the README; unsampled behavior is not inferred.
Main entry points: index.ts Scheduled weather job · whatsapp.ts WhatsApp client · openmeteo.ts Open-Meteo adapter · env.ts Environment config
Components 18
Scheduling & Health
- Scheduled weather job
src/index.ts - Health HTTP server
src/index.ts - Environment config
src/config/env.ts
Weather Data
- BMKG forecast adapter
src/services/weather.ts - Open-Meteo adapter
src/services/openmeteo.ts - BMKG data types
src/types/weather.ts - Open-Meteo data types
src/types/openmeteo.ts
Risk & Broadcast
- Rainfall risk formatter
src/utils/formatter.ts - WhatsApp client
src/services/whatsapp.ts
Persistence & Operations
- MongoDB auth adapter
src/services/mongoAuth.ts - System and history logs
src/utils/logger.ts
Other components
- BMKG API
- Open-Meteo API
- MongoDB Atlas
- Village community/channel
- UptimeRobot
- RainViewer radar
Connections 18
- Scheduled weather job → Environment config: reads schedule
src/index.ts - Scheduled weather job → BMKG forecast adapter: fetches forecast
src/index.ts - Scheduled weather job → Open-Meteo adapter: fetches weather
src/index.ts - BMKG forecast adapter → Environment config: reads endpoint
src/services/weather.ts - Open-Meteo adapter → Environment config: reads coordinates
src/services/openmeteo.ts - BMKG API → BMKG forecast adapter: provides forecast
README.md - Open-Meteo API → Open-Meteo adapter: provides forecast
README.md - Scheduled weather job → Rainfall risk formatter: formats results
src/index.ts - Rainfall risk formatter → Open-Meteo adapter: aggregates rainfall
src/utils/formatter.ts - Scheduled weather job → System and history logs: records history
src/index.ts - Scheduled weather job → WhatsApp client: sends summary
src/index.ts - WhatsApp client → Environment config: reads target
src/services/whatsapp.ts - WhatsApp client → MongoDB auth adapter: loads session
src/services/whatsapp.ts - MongoDB auth adapter → MongoDB Atlas: reads and writes
src/services/mongoAuth.ts - WhatsApp client → WhatsApp: sends messages
README.md - WhatsApp → Village community/channel: delivers broadcast
README.md - UptimeRobot → Health HTTP server: pings endpoint
README.md - Rainfall risk formatter → RainViewer radar: includes radar link
src/utils/formatter.ts