Add NASA FIRMS active-fire ingest + /api/fires; API keys management page

Coherent merge of two coordinated features on the shared working tree:

FIRMS fire heatmap (backend, t_6e404c14):
- app/fire_sources.py: fetch FIRMS VIIRS area CSV (free MAP_KEY) -> NATS events.fire
- fires hypertable (TimescaleDB, 1-day chunks) with natural-key PK
  (latitude, longitude, acq_time, satellite); idempotent ON CONFLICT DO NOTHING
- alembic/versions/002_fires.py; GET /api/fires?bbox=&since= (JSON only)
- POST /api/ingest/fires; ~15 min poll loop (FIRMS_INTERVAL=900) in ingester
- env-driven config (FIRMS_MAP_KEY/DATASET/BBOX/INTERVAL); docs/firms.md covers
  the zero-cost GIBS VIIRS_SNPP_Thermal_Anomalies_375m_All tile alternative
- 18 tests (parser, mapping, idempotency, API contract) verified vs real
  TimescaleDB+PostGIS (localhost/osint-dashboard-pg image)

API keys page (frontend, t_4433cff2):
- app/keystore.py: api_keys table (self-creating), FIRMS/GEMINI/TELEGRAM
  registry with format validation, ****last4 masking, get_api_key()
- GET/POST/DELETE /api/keys (never returns full values); Keys tab in index.html

DB_NULL_POOL env switch in app/database.py enables a NullPool for tests /
short-lived processes that open a fresh event loop per unit.
This commit is contained in:
Sirius DevOps 2026-08-24 15:37:42 -04:00
commit 627990efde
19 changed files with 1428 additions and 10 deletions

View file

@ -215,6 +215,44 @@ class DocumentOut(BaseModel):
uploaded_at: datetime
# ─── API Keys ────────────────────────────────────────────────────────────
class KeyValueIn(BaseModel):
"""Body for POST /api/keys/{name} — the value to store.
The raw value is accepted only on write; it is never read back out.
"""
value: str = Field(..., min_length=1, max_length=4096)
class KeyOut(BaseModel):
"""One key's status as exposed by GET /api/keys.
``masked`` is the "****last4" hint; the full value is NEVER included.
"""
name: str
set: bool
masked: Optional[str] = None
description: Optional[str] = None
example: Optional[str] = None
validated: bool = True
# ─── Active fires / hotspots (NASA FIRMS) ────────────────────────────────
class FireOut(BaseModel):
latitude: float
longitude: float
brightness: float # bright_ti4 brightness temperature, Kelvin
confidence: str # VIIRS: n (nominal) / l (low) / h (high)
acq_time: datetime
satellite: str
instrument: Optional[str] = None
bright_ti5: Optional[float] = None # 12µm brightness temperature, Kelvin
frp: Optional[float] = None # fire radiative power, MW
daynight: Optional[str] = None # D / N
# ─── Aggregations ────────────────────────────────────────────────────────
class SentimentSummary(BaseModel):