How eisoptrophobicc/saatya-engine works
1. Repo shape
- The repository is split into two largely separate application surfaces:
- backend/: the main FastAPI-based fact-verification engine.
- frontend/: a mixed frontend/prototype area with static UI assets plus its own Node and Django-based backend experiments.
- For architecture diagrams, the backend is the core system; the frontend looks like an auxiliary presentation layer rather than the primary logic host.
2. Primary backend entrypoint
- backend/app/main.py is the FastAPI application entrypoint, with backend/run.py as the launcher.
- Routing is divided into feature-specific API modules:
- routes_claims.py
- routes_verify.py
- routes_report.py
- This indicates a clean boundary between claim intake, verification execution, and report delivery.
3. Request/response boundary
- backend/app/schemas/request.py and response.py define the API contract.
- backend/app/adapter/response_adapter.py suggests output normalization so internal pipeline results are converted into stable API responses.
- backend/app/models/claim.py holds the core claim domain object used across the pipeline.
4. Orchestration layer
- The main work is not done in the routes themselves; it is delegated to services and agents.
- backend/app/services/pipeline_service.py appears to coordinate the overall workflow.
- claim_extractor.py, claim_analyzer.py, merge_service.py, and filter_service.py suggest the pipeline breaks one input into multiple claims, cleans/merges them, and prepares them for independent verification.
5. Agent-based verification core
- The repo uses a manual multi-agent design rather than a framework like LangChain.
- agents/query_agent.py is likely responsible for gathering evidence or crafting search queries.
- agents/verification_agent.py performs the final reasoning step over claims and evidence.
- services/input_agent.py indicates an abstraction for taking user input and placing it into the agent flow.
6. Evidence retrieval subsystem
- services/search_service.py and services/evidence_service.py form the evidence-collection boundary.
- The README states real-time search is done via external search APIs, specifically Tavily, so the architecture includes an external search dependency outside the repo.
- utils/url_loader.py and utils/text_utils.py support ingestion and normalization of source material before verification.
7. LLM abstraction and fallback
- backend/app/llm/llm_router.py is the central abstraction for choosing which model/provider to use.
- Provider-specific clients exist in gemini_client.py and openrouter_client.py.
- This is a reliability boundary: the system can fall back between LLM providers when one is unavailable or less suitable.
8. Verification and reporting
- services/verification_service.py is the main verifier, likely combining claim text, retrieved evidence, and LLM reasoning.
- services/report_generator.py turns verification output into a structured report.
- api/routes_report.py exposes that report generation result separately from the verification call, which is useful for asynchronous or multi-step workflows.
9. Media verification subsystem
- The backend also supports non-text inputs through a separate media pipeline:
- media_router.py
- media_model_loader.py
- media_detection_service.py
- image, video, audio, and ai_detection services
- The README notes local AI models and signal-processing-based audio checks, so this subsystem is intentionally independent from the LLM verification path and avoids relying on LLMs for media analysis.
10. Dependency/config boundary
- config.py and dependencies.py centralize environment setup and dependency injection for the FastAPI app.
- This likely isolates model clients, search clients, and service instances from the route layer, making the app easier to wire and test.
11. Testing surface
- backend/query_agent_test.py and backend/media_ai_test.py show two important test targets:
- the text/evidence agent flow
- the media-analysis pipeline
- This reinforces that the repository has two major technical branches: claim verification and media authenticity analysis.
12. Frontend/prototype area
- frontend/index.html, frontend/js/app.js, and frontend/css/styles.css form a lightweight UI.
- frontend/backend/server.js plus users.json indicate a small Node-based backend, while frontend/backend_py/ contains a Django app with its own settings, URLs, and SQLite database.
- This looks like a separate prototype or auxiliary app stack, not tightly integrated with the main FastAPI backend.
13. End-to-end flow to draw
- The clearest architecture diagram is:
- user input (text or URL, optionally media)
- claim extraction and normalization
- agent orchestration
- external search/evidence retrieval
- LLM-based claim verification
- response adaptation and report generation
- In parallel, media inputs can be routed through the local media-analysis pipeline before or alongside textual verification.
14. Core architectural takeaway
- The repo is a modular verification platform with a strong separation between:
- API surface
- orchestration/services
- agent reasoning
- model/provider routing
- media-analysis path
- response/report formatting
- That separation is the key thing to capture in an architecture diagram.
Main entry points: pipeline_service.py Pipeline service · main.py FastAPI app · verification_service.py Verification service · routes_claims.py Claims API
Components 26
Backend
Primary FastAPI verification engine
- FastAPI app · Application startup and app wiring
backend/app/main.py - Claims API · Claim intake and creation endpoints
backend/app/api/routes_claims.py - Verify API · Verification execution endpoints
backend/app/api/routes_verify.py - Report API · Report delivery endpoints
backend/app/api/routes_report.py - Config & deps · Environment setup and dependency injection
backend/app/config.py - API schemas · Request and response shapes
backend/app/schemas/request.py - Claim model · Core claim object shared across the pipeline
backend/app/models/claim.py - Response adapter · Normalizes internal results into API responses
backend/app/adapter/response_adapter.py - Pipeline service · Coordinates claim processing workflow
backend/app/services/pipeline_service.py - Input agent · Ingests user input into the agent flow
backend/app/services/input_agent.py - Claim extractor · Splits inputs into candidate claims
backend/app/services/claim_extractor.py - Claim analyzer · Analyzes and prepares claims for verification
backend/app/services/claim_analyzer.py - Merge/filter · Cleans, merges, and filters claims
backend/app/services/merge_service.py - Search & evidence · External search and evidence collection boundary
backend/app/services/search_service.py - Query agent · Builds search queries and gathers evidence
backend/app/agents/query_agent.py - Verifier agent · Reasons over claims and evidence
backend/app/agents/verification_agent.py - LLM router · Selects provider and handles fallback
backend/app/llm/llm_router.py - Verification service · Combines claims, evidence, and LLM reasoning
backend/app/services/verification_service.py - Report generator · Creates structured verification reports
backend/app/services/report_generator.py - Media router · Entry to media authenticity analysis
backend/app/services/media_router.py - Media detection · Coordinates image, video, audio, and AI checks
backend/app/services/media_detection_service.py - Media models · Loads local models used by media analysis
backend/app/services/media_model_loader.py - Text/url utils · Normalizes source text and loaded URLs
backend/app/utils/text_utils.py
Frontend
Auxiliary UI and prototype stacks
- Static UI · Lightweight browser interface
frontend/index.html - Node backend · Small Node-based backend experiment
frontend/backend/server.js - Django app · Separate Django prototype stack
frontend/backend_py/manage.py
Connections 30
- FastAPI app → Config & deps: wired by · App uses centralized config and dependencies
- FastAPI app → Claims API: mounts · Registers claim endpoints
- FastAPI app → Verify API: mounts · Registers verification endpoints
- FastAPI app → Report API: mounts · Registers report endpoints
- Claims API → API schemas: uses · Validates claim intake contract
- Verify API → API schemas: uses · Validates verification request contract
- Report API → Response adapter: uses · Formats report responses
- Claims API → Pipeline service: delegates · Hands off claim intake for processing
- Verify API → Verification service: delegates · Runs verification workflow
- Report API → Report generator: delegates · Builds report payloads
- Pipeline service → Input agent: starts with · Begins by ingesting user input
- Pipeline service → Claim extractor: invokes · Extracts candidate claims
- Pipeline service → Claim analyzer: invokes · Analyzes extracted claims
- Pipeline service → Merge/filter: invokes · Cleans and consolidates claims
- Claim extractor → Text/url utils: normalizes · Prepares text and URL sources
- Claim analyzer → Claim model: produces · Works on core claim objects
- Verification service → Search & evidence: retrieves · Collects supporting evidence
- Verification service → Query agent: orchestrates · Uses agent for evidence search
- Verification service → Verifier agent: reasons with · Runs final claim assessment
- Query agent → Search & evidence: queries · Forms and sends search requests
- Verifier agent → LLM router: calls · Uses provider routing for reasoning
- LLM router → Verifier agent: returns · Provides model output back to agent
- LLM router → Response adapter: supports · Model outputs are normalized for API use
- Report generator → Response adapter: formats · Converts results into report-ready responses
- Media router → Media detection: delegates · Hands media inputs to analysis pipeline
- Media detection → Media models: loads · Uses local models for analysis
- Media detection → Text/url utils: shares utils · Reuses normalization helpers where needed
- Static UI → Claims API: calls · Browser UI submits requests to backend APIs
- Node backend → Static UI: serves · Prototype Node layer serves the UI
- Django app → Static UI: prototypes · Separate Django stack alongside the static UI