How the-bhuvi/mazh-ai- works
Mazh AI turns a location into rainfall-risk guidance through a React dashboard or phone service. The web flow obtains geolocation or a chosen place/PIN, requests an insight from FastAPI, and presents forecast, risk, and recommendations; chat and SMS are additional dashboard capabilities. The backend combines weather and climate context with a calibrated ML risk estimate and cached insight generation. Phone access is keypad-only: Asterisk is the documented reference deployment, with legacy Twilio voice webhooks also available. Source-index references and README statements support some subsystem links where implementation excerpts were incomplete.
Main entry points: main.py FastAPI service · App.tsx Web application · routes.py Twilio IVR webhooks · insight.py Insight builder
Components 31
Web experience
- Web application
frontend/src/App.tsx - Geolocation
frontend/src/hooks/useGeolocation.ts - Location picker
frontend/src/components/LocationPicker.tsx - Web API client
frontend/src/api/client.ts - Risk dashboard
frontend/src/components/Dashboard.tsx - Insight chat
frontend/src/components/ChatWidget.tsx - Phone and SMS
frontend/src/components/PhoneCard.tsx
Insight service
- FastAPI service
backend/app/main.py - Location resolution
backend/app/location.py - Insight builder
backend/app/engine/insight.py - Insight cache
backend/app/cache.py - Chat reply engine
backend/app/llm/client.py
Weather and climate
- Forecast provider
backend/app/providers/open_meteo.py - Historical weather
backend/app/providers/historical_weather.py - Climate context
backend/app/climate_service.py
Rainfall model
- ML runtime adapter
backend/app/ml_engine.py - Risk inference
backend/ml/infer.py - Feature engineering
backend/ml/features.py - Training data
backend/ml/data.py - Model training
backend/ml/train.py
Phone channels
- SMS adapter
backend/app/sms/twilio_adapter.py - Twilio IVR webhooks
backend/app/voice/routes.py - Fixed voice phrases
backend/app/voice/phrases.py - Signed call state
backend/app/voice/state.py - Voice audio
backend/app/voice/audio.py - Asterisk AGI
asterisk/agi/mazh_weather.py
Other components
- Web user
- Phone caller
- Open-Meteo
- Twilio SMS
- Twilio voice
Connections 35
- Web user → Web application: uses
frontend/src/App.tsx - Web application → Geolocation: gets location
frontend/src/App.tsx - Web application → Location picker: offers fallback
frontend/src/App.tsx - Web application → Web API client: requests insight
frontend/src/App.tsx - Web API client → FastAPI service: HTTP request
frontend/src/api/client.ts - FastAPI service → Location resolution: resolves location
backend/app/main.py - FastAPI service → Insight builder: builds insight
backend/app/main.py - FastAPI service → Forecast provider: fetches forecast
backend/app/main.py - FastAPI service → Historical weather: fetches archive
backend/app/main.py - FastAPI service → Insight cache: uses cache
backend/app/main.py - Insight builder → ML runtime adapter: estimates risk
backend/app/engine/insight.py - Insight builder → Climate context: adds context
- Forecast provider → Open-Meteo: fetches data
backend/app/providers/open_meteo.py - Historical weather → Forecast provider: reuses provider
backend/app/providers/historical_weather.py - ML runtime adapter → Risk inference: loads and predicts
backend/app/ml_engine.py - Risk inference → Feature engineering: builds features
backend/ml/infer.py - Model training → Training data: loads data
backend/ml/train.py - Model training → Feature engineering: builds features
backend/ml/train.py - Web application → Risk dashboard: renders
frontend/src/App.tsx - Web application → Insight chat: renders
frontend/src/App.tsx - Web application → Phone and SMS: renders
frontend/src/App.tsx - Insight chat → Web API client: sends chat
frontend/src/components/ChatWidget.tsx - Phone and SMS → Web API client: requests SMS
frontend/src/components/PhoneCard.tsx - FastAPI service → Chat reply engine: generates reply
backend/app/main.py - FastAPI service → SMS adapter: sends SMS
backend/app/main.py - SMS adapter → Twilio SMS: delivers message
backend/app/sms/twilio_adapter.py - Phone caller → Twilio voice: calls
README.md - Twilio voice → Twilio IVR webhooks: posts webhooks
README.md - Twilio IVR webhooks → Insight builder: prefetches insight
backend/app/voice/routes.py - Twilio IVR webhooks → Fixed voice phrases: uses phrases
backend/app/voice/routes.py - Twilio IVR webhooks → Signed call state: validates state
backend/app/voice/routes.py - Twilio IVR webhooks → SMS adapter: sends SMS
backend/app/voice/routes.py - Twilio IVR webhooks → Voice audio: serves audio
- Phone caller → Asterisk AGI: calls
README.md - Asterisk AGI → FastAPI service: calls phone API
README.md