LGA-level security risk forecast for Nigeria — FastAPI + PostGIS backend, Next.js choropleth frontend
# 🇳🇬 Naija Security Forecast
A "weather forecast for security" — a live, LGA-level risk dashboard for Nigeria that fuses historical incident data, news sentiment, and statistical trend models into a choropleth map anyone can read at a glance.
---
## What it does
| Feature | Detail |
|---|---|
| **Choropleth map** | All 775 Nigerian LGAs coloured LOW → MODERATE → HIGH → SEVERE |
| **Timeline slider** | Slide from −3 days (historical) through today to +3 days (forecast); scores use trend velocity + news sentiment decay |
| **Incident type filters** | Kidnappings, school abductions, jihadist attacks, bombings, banditry, riots, protests, and more |
| **Live news feed** | Scrapes 10 Nigerian RSS sources; NLP classifies security relevance and sentiment |
| **State rankings** | Left sidebar ranks all 36 states + FCT by average risk score |
| **LGA detail panel** | Click any LGA on the map for a full score breakdown |
---
## Architecture
```
naija-security-forecast/
├── app/
│ ├── api/routes/ # FastAPI routers (risk, news, incidents, filters)
│ ├── core/ # DB engine, settings
│ ├── models/ # SQLAlchemy ORM (LGA, Incident, NewsArticle, RiskScore)
│ ├── schemas/ # Pydantic v2 response schemas
│ ├── services/
│ │ ├── acled_client.py # ACLED API client (email + access_key auth)
│ │ ├── acled_sync.py # Historical incident sync (from 2010)
│ │ ├── forecaster.py # 7-day statistical forecast engine
│ │ ├── lga_matcher.py # Fuzzy LGA name → PostGIS point-in-polygon matcher
│ │ ├── news_pipeline.py # Scrape → NLP → upsert pipeline
│ │ ├── nlp.py # Keyword NLP: security classification + sentiment
│ │ ├── rss_scraper.py # feedparser scraper for 10 Nigerian news sources
│ │ └── scorer.py # Composite risk scoring engine
│ └── workers/ # Celery tasks + beat schedule
├── alembic/ # DB migrations
├── scripts/ # Manual t …