# CVE Fact Checker Flask API Production-oriented API layer exposing fact checking, Firebase ingestion, and semantic search. ## Features - Firebase article ingestion -> vector store (Chroma) - Semantic similarity search - Claim fact-check endpoint (LLM backed if OPENROUTER_API_KEY present; graceful fallback otherwise) - Schema inspection & collection listing - Lightweight dummy embeddings fallback (no GPU / HF model required) ## Environment Variables ``` OPENROUTER_API_KEY=your_key # Optional (improves analysis) APP_DOMAIN=https://yourdomain.tld # For OpenRouter headers (optional) APP_TITLE="Your App Title" # For OpenRouter headers (optional) ``` ## Install ``` python -m venv .venv .venv\Scripts\activate # Windows pip install -r requirements.txt pip install flask ``` ## Run ``` python -m cve_factchecker.app ``` Server listens on `http://0.0.0.0:8000`. ## Endpoints | Method | Path | Description | | ------ | ---- | ----------- | | GET | / | Index + endpoint list | | GET | /health | Health & uptime | | POST | /ingest/firebase | Ingest from Firebase (paged) `{collection?, limit?}` | | POST | /ingest/firebase/full | Ingest ALL documents (pagination) `{collection?}` | | GET | /schema | Inspect collection schema `?collection=Articles` | | GET | /collections | List probable collections | | GET | /search | Semantic search `?q=term&k=5` | | POST | /fact-check | Fact check `{claim, auto_ingest?, ingest_limit?}` | ## Example Requests (PowerShell) ``` # Health curl http://localhost:8000/health # Ingest sample (limited) curl -Method POST -Uri http://localhost:8000/ingest/firebase -Headers @{"Content-Type"="application/json"} -Body '{"limit":50}' # Full ingest (all) curl -Method POST -Uri http://localhost:8000/ingest/firebase/full -Headers @{"Content-Type"="application/json"} -Body '{}' # Search curl "http://localhost:8000/search?q=Pakistan" # Fact Check (with auto ingest) curl -Method POST -Uri http://localhost:8000/fact-check -Headers @{"Content-Type"="application/json"} -Body '{"claim":"Pakistan signed a new mineral deal","auto_ingest":true,"ingest_limit":80}' ``` ## Notes - If you have no API key configured, verdicts will be `UNVERIFIED`; retrieval still works. - Adjust vector DB path by editing `FactCheckSystem` init in `orchestrator.py`. - Set `AUTO_INGEST_FIREBASE=true` (env var) to automatically ingest all articles on startup.