Repository avatar
AI Tools
v1.0.0
active

sightline

io.github.serkankzlrmk/sightline

Cited humanitarian evidence, funding, displacement & SITREP bundles for AI assistants. Read-only.

Documentation

Sightline — Humanitarian Intelligence Platform

Sightline

Humanitarian intelligence platform for crisis response teams.

Real-time data aggregation · 10-stage SITREP pipeline · bring-your-own-key chat · LLM evaluation and observability · donor-compliant proposal generator.

License: AGPL v3 Commercial License Python 3.12+ Docker Tests Version

Quick Start · Features · Architecture · Observability · Docs · Contributing


Why Sightline?

Humanitarian professionals spend a large share of their time collecting, synthesizing, and formatting information from scattered sources — ReliefWeb, HDX, GDACS, ACLED, FTS, UNHCR, news feeds, field reports. Sightline automates this workflow with direct API integrations, a 60-tool LangGraph agent, a 10-stage SITREP pipeline, and a donor-compliance-aware Proposal Studio.

WhatHow
60-tool data agent50 native tools defined (ReliefWeb, HDX, ACLED, FTS, UNHCR, FIRMS, GIEWS, OSM, GDACS, weather, World Bank, FX, EONET, IMF, SQL; 44 active without optional keys) + 20 MCP tools (arXiv, sequential-thinking, Brave). Quantitative questions route to HDX/ACLED/FTS. The MCP set is runtime-extensible via MCP_SERVERS_JSON + POST /api/admin/mcp/reload.
10-stage SITREP pipelineUMAP + HDBSCAN clustering → question generation → filtering → pool-based RRF retrieval → citation post-processing → synthesis. Produces structured situation reports from the report corpus.
Donor-compliant Proposal StudioSeparate repository embedded in the same Flask process: 5-step pipeline, 6 donor manifests, deterministic scoring, Typst PDF export.
Evaluation & observabilityG-Eval chat evaluation, human calibration (QWK), 👍/👎 user feedback, per-turn telemetry, error monitoring, audit log, alerts and synthetic canary.

Quick Start

git clone https://github.com/serkankzlrmk/sightline.git
cd sightline
cp .env.example .env
# Fill in at least OPENROUTER_API_KEY and RELIEFWEB_APPNAME

Local development (no Firebase)

python -m venv .venv
.venv/bin/pip install -r requirements.txt
SERVER_HOST=127.0.0.1 DESKTOP_MODE=true SERVER_DEBUG=true .venv/bin/python server.py
# → http://127.0.0.1:5001/app

DESKTOP_MODE/DEV_AUTH_BYPASS only work on loopback; all requests get a mock admin user.

Docker (production-like)

The production image is built by CI and run with docker run (see docs/SYSTEM_DESIGN.md and deploy/gunicorn.conf.py). docker-compose.yml is a current, runnable production+local-dev compose (app + proposal + caddy + daily-ingest scheduler); production itself deploys via the CI docker run workflow.

No API keys? The app starts without them; /api/health reports degraded. GDACS, Open-Meteo, FTS, Overpass, and World Bank are keyless. Add keys for ReliefWeb, HDX, News, ACLED, UNHCR, FIRMS, Brave, and the LLM as needed. See docs/TOOLS.md for the full tool/key matrix.


Features

Data agent (50 native + 20+ MCP tools)

The agent uses a source-routing prompt: ReliefWeb for qualitative reports, HDX/UNHCR for displacement and refugee statistics, ACLED for conflict events, FTS for funding plans, World Bank for macro indicators, GDACS for rapid-onset alerts, FIRMS for fires, OSM for nearby infrastructure, News/Brave for media, arXiv for literature, and SQL for local database analytics.

Availability depends on keys; see docs/TOOLS.md. ACLED auth failures and GIEWS schema-pending errors are surfaced as tool errors (not silently counted as success).

SITREP pipeline

POST /api/sitrep/run (premium) runs sitrep/pipeline.py in a subprocess and streams progress over a nonce-authenticated SSE endpoint:

  1. Load chunks from SQLite (country/theme/date filter)
  2. HDX enrichment (non-fatal)
  3. UMAP + HDBSCAN clustering (adaptive hyperparameter search)
  4. Question generation
  5. Question filtering + dedup
  6. Pool-based retrieval with reciprocal rank fusion over sub-queries
  7. RAG answers with citations
  8. Citation post-processing
  9. Cluster summaries + executive summary + narrative HTML
  10. JSON + Markdown report assembly

Outputs live under output/ (reports, clusters, questions, answers, summaries, data-quality reports).

BYOK — bring your own AI key

Registered users can connect a personal OpenRouter / OpenAI Platform / Google AI Studio key from the chat's AI Key menu. While connected, every model call for that user (main agent loop, cross-chat memory, title generation) runs on their key; premium models unlock and the daily quota no longer applies. Keys are validated against the provider, stored AES-256-GCM encrypted (CREDENTIAL_MASTER_KEY env; a 0600 key file is auto-generated if unset), and never returned by any API or written to logs. Mid-stream provider failures surface targeted errors (ERR-byok-auth/limit/quota) with an "Open AI Key settings" action. Full reference: docs/BYOK.md.

Dynamic MCP

MCP servers are configuration, not code: add a server via MCP_SERVERS_JSON (inline JSON or file path, {"name": {"command", "args", "env", "transport"}}) and apply it live with POST /api/admin/mcp/reload — the agent tool registry re-syncs (new servers' tools appear, removed servers' tools drop) without a restart. GET /api/admin/mcp/status reports servers, tools and readiness; the admin panel has an MCP tab with a reload button.

Public surface

The public site is intentionally small: the landing page, the app at /app, the MCP onboarding page at /connect, and the legal pages. Editorial publications (crisis/country/SITREP/bulletin/digest/deep-dive pages, AdSense, the newsletter and IndexNow/GSC sync) were retired and are preserved on the archive/v1.3-content-products branch; their old URLs answer 410 Gone. sitemap.xml lists only the core pages and robots.txt keeps /app out of the index.

Proposal Studio

A separate repository (proposal/ symlink in development, mounted read-only in production) registered into the same Flask process by proposal_bridge.py. It owns the donor-call ingestion, 5-step proposal pipeline, deterministic verification, and Typst PDF export. API routes remain root-relative (/api/proposals, /api/calls, /api/proposal-v2/...).


Architecture

Browser                       AI assistants (Claude / ChatGPT / agents)
 ├── /            landing        └── /connect   onboarding
 ├── /app         SPA (map, chat, database, SITREP, admin)   └── /mcp  MCP server (OAuth 2.1 / API keys)
 ├── /connect     MCP onboarding
 ├── /privacy /terms
 └── /proposal    Proposal Studio SPA (separate repo, same process)

Flask — server.py (~600 lines: app init, request IDs, error handlers, middleware)
├── blueprints/     14 route modules + helpers.py (~120 routes)
├── auth.py         Firebase + RBAC (role source of truth: users table)
├── agent/          LangGraph agent, models, memory, tool resilience
├── reliefweb_api/  13+ external data clients + tools
├── sitrep/         10-stage pipeline, country summaries, assembly
├── observability/  turn telemetry, eval scores, error tracking
└── proposal/       embedded Proposal Studio (separate repo)

Storage
├── reliefweb.db    reports + chunks (SQLite; chunk store is the retrieval source)
├── chats.db        chats, messages, users, rate limits, events
├── obs.db          turns, tool calls, feedback, eval scores, retrieval eval
├── errors.db       error events, request stats, alert state
├── chroma/         embeddings (384-dim) + agent memory collections
└── output/         generated reports, SITREPs, data-quality reports, caches

Runtime: gunicorn 1 worker / 4 threads (SQLite + Chroma single-process constraint), Caddy for TLS and SSE, OpenRouter for LLM, Firebase for auth, MCP subprocesses for arXiv/sequential-thinking.


Observability & evaluation

Sightline records every chat turn in obs.db and every error in errors.db:

  • Turn telemetry: model, tokens, cost, latency/total, iterations, tool calls, citations, no-answer signal, tool evidence previews.
  • Chat evaluation: G-Eval judge (cross-family default, multi-sample), evidence-aware rubric, low-score queue.
  • Human calibration: blind admin queue, 1–5 rating, QWK/Spearman/MAE against the judge.
  • User feedback: 👍/👎 under assistant answers (one vote per turn/user).
  • Error monitoring: request IDs (X-Request-ID, ERR-…), backend/frontend/tool/LLM/SSE capture, grouped fingerprints, admin Errors panel, audit log.
  • Alerts & canary: threshold checks (scripts/alert_check.py) and synthetic uptime checks (scripts/canary.py), webhook/Telegram delivery.
  • Load testing: async HTTP load script with p50/p95/p99 reporting.

Details: docs/EVALUATION.md, docs/CALIBRATION.md, docs/ERROR_MONITORING.md, docs/LOAD_TESTING.md, docs/SRE_RUNBOOK.md, docs/TOOLS.md.


Configuration

Configuration is environment-driven (.env); see .env.example and docs/SYSTEM_DESIGN.md for the current groups.

Key variables:

VariableRequiredDescription
LLM_PROVIDEROptionalopenrouter (default), google (Gemini API) or ollama
OPENROUTER_API_KEYIf OpenRouterLLM access (chat + evaluation judge + SITREP)
GOOGLE_API_KEYIf GoogleGemini API key; server-side only, never exposed to the browser
RELIEFWEB_APPNAME✅ReliefWeb API identifier
HDX_APP_IDENTIFIEROptionalHDX API (base64 app identifier)
NEWS_API_KEYOptionalNewsAPI.org
ACLED_EMAIL/ACLED_PASSWORD or ACLED_API_KEYOptionalACLED conflict events
UNHCR_API_KEYOptionalUNHCR refugee statistics
FIRMS_MAP_KEYOptionalNASA FIRMS active fires
GIEWS_ENABLEDOptionalEnable FAO GIEWS once schema is verified (default false)
BRAVE_API_KEY + MCP_BRAVE_ENABLED=trueOptionalBrave search MCP
DESKTOP_MODE/DEV_AUTH_BYPASSOptionalLocal auth bypass (loopback only)
OBS_DB_PATH, ERRORS_DB_PATH, ERRORS_SALTOptionalTelemetry/error stores
ALERT_WEBHOOK_URL, ALERT_TELEGRAM_*OptionalAlert delivery
CHAT_MAX_CONCURRENTOptionalChat SSE concurrency guard (keep ≤ gunicorn threads; default 4)
CREDENTIAL_MASTER_KEYRecommendedAES-256-GCM master key for user BYOK keys (0600 key file auto-generated if unset)
MCP_SERVERS_JSONOptionalCustom MCP servers (inline JSON or file path); apply live via POST /api/admin/mcp/reload
DAILY_MESSAGE_LIMIT / PREMIUM_MESSAGE_LIMITOptionalChat quotas (free 20/day, premium 100/day)
RELEASE_SHAOptionalRelease identifier in health/errors

Chat models (current): flash → google/gemini-3.8-flash (free), deep_think → google/gemini-3.1-pro-preview (premium, sequential reasoning), vision → google/gemini-3.8-flash (premium), plus 7 premium custom models. Synthesis calls follow LLM_MODEL and pass reasoning_effort=low with generous completion budgets — thinking models (gemini-3-flash-preview) burn completion tokens reasoning, which previously truncated JSON output (verified live).


Auth & RBAC

RoleChatSITREPBulletinDatabaseAdmin
free (no personal key)20/day✗readlast 3 days✗
free + BYOK keyunlimited*✗readlast 3 days✗
premium100/day✓readfull✗
adminunlimited✓generatefull✓

*BYOK (bring your own key): connect an OpenRouter / OpenAI / Gemini API key in the chat UI (AI Key) and every model call — including premium models — runs on the user's own key (AES-256-GCM encrypted at rest, never echoed or logged); the daily quota no longer applies. See docs/BYOK.md.

Role resolution order: ADMIN_UIDS → chats.db users.role (source of truth) → Firebase custom claim → free. Decorators: @require_auth, @require_admin, @require_role("premium"), @optional_auth.

Freemium gating (current code): gated tabs are agent chat, database, admin; SITREP generation remains premium. MCP access is read-only and quota-limited for everyone (see docs/MCP_ONBOARDING.md).


Development

# Tests — 480 passed, 21 skipped (current suite)
.venv/bin/python -m pytest tests/ -q

# Lint/format (CI gate)
ruff check .
ruff format --check .

# Frontend bundle (required for /app after JS/CSS edits)
npm run lint
npm run build
node --check static/dist/app.js

# Dev server
SERVER_HOST=127.0.0.1 DESKTOP_MODE=true SERVER_DEBUG=true .venv/bin/python server.py

The SPA is plain script-tag JavaScript bundled by esbuild (static/dist/app.js, static/dist/style.css). static/dist/ is gitignored and built inside Docker.


Deployment

Production: Hetzner ARM64 + Docker + Caddy, image ghcr.io/serkankzlrmk/sightline. Pushing to main triggers GitHub Actions: test → ARM64 build → GHCR → SSH docker run → health check → automatic rollback on failure. RELEASE_SHA is exposed in /api/health and error records.

docker-compose.yml also works for production-like local runs; production deploys via .github/workflows/deploy.yml (test → ARM64 build → SSH docker run → health check → rollback restores both web and daily-ingest containers). See docs/SRE_RUNBOOK.md for operations.


Documentation

DocPurpose
docs/SYSTEM_DESIGN.mdCurrent architecture, modules, data flows, storage, auth, deployment
docs/BYOK.mdBYOK user keys, dynamic MCP reload, ops/deploy checklist
docs/API_KEYS.mdPer-user API keys for programmatic MCP access
docs/DATA_MODEL.mdStores, schemas, indexes, curated views
docs/DATA_INTEGRATION_PLAN.md3-tier data contract
docs/SITREP_EVAL.mdSITREP quality gates and baseline
docs/EVALUATION.mdChat evaluation + retrieval evaluation process
docs/EVALUATION_RESULTS.mdPreliminary measured results and pending evaluations
docs/CALIBRATION.mdHuman calibration of the LLM judge (UI + CSV)
docs/ERROR_MONITORING.mderrors.db, request IDs, admin Errors, alerts, canary, audit
docs/LOAD_TESTING.mdLoad-test baseline and capacity guards
docs/SRE_RUNBOOK.mdOn-call checks, rollback, alerts
docs/TOOLS.mdTool inventory and enablement matrix
CONTRIBUTING.mdContribution workflow, CLA
SECURITY.mdVulnerability disclosure policy

License

Sightline is dual-licensed:

  1. AGPL v3 (LICENSE) — open-source use; network use requires sharing modifications.
  2. Commercial License (LICENSES/Commercial-LICENSE.md) — for proprietary/SaaS use.

All contributions require signing the CLA.


Security

See SECURITY.md for the vulnerability disclosure policy. Do not open public issues for security vulnerabilities; use GitHub Security Advisories.


Built by Serkan Kizilirmak

Sightline — Humanitarian intelligence for crisis response

No installation packages available.