# kalyai1322005/impirex-research-assistant architecture

> Architecture diagram of the GitHub repository kalyai1322005/impirex-research-assistant, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-05). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/kalyai1322005/impirex-research-assistant
- Repository: https://github.com/kalyai1322005/impirex-research-assistant

## Overview

ImpireX is a research desk offering quick public-web lookups, a six-stage evidence-checking workflow, and an offline Atlas demo. Users enter a question in the Streamlit desk or submit it through the FastAPI API; the research service runs the selected workflow, returns a report for display and PDF download, and saves owned reports for later retrieval. Account, signup, email, and usage-policy components support access. The README documents additional pilot capabilities; some implementation details are unsampled, so their internal links are omitted.

Main entry points: [`workflow/graph.py`](https://github.com/kalyai1322005/impirex-research-assistant/blob/main/workflow/graph.py) (Workflow dispatcher), [`database/history.py`](https://github.com/kalyai1322005/impirex-research-assistant/blob/main/database/history.py) (SQLite history), [`app.py`](https://github.com/kalyai1322005/impirex-research-assistant/blob/main/app.py) (Research desk), [`studio.py`](https://github.com/kalyai1322005/impirex-research-assistant/blob/main/studio.py) (Access interface)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interfaces["User interfaces"]
  node_streamlit["Research desk<br/>[app.py]"]
  node_api["HTTP API<br/>[api.py]"]
  node_studio["Access interface<br/>[studio.py]"]
end

subgraph group_research["Research workflow"]
  node_service["Research service"]
  node_workflow["Workflow dispatcher<br/>[graph.py]"]
  node_manager["Query manager<br/>[manager.py]"]
  node_researcher["Document research<br/>[researcher.py]"]
  node_source_finder["Source screening<br/>[source_finder.py]"]
  node_fact_checker["Fact checker<br/>[fact_checker.py]"]
  node_analyst["Evidence analysis<br/>[analyst.py]"]
  node_report["Report assembly"]
  node_provider_config["Model configuration<br/>[config.py]"]
end

subgraph group_retrieval["Search and retrieval"]
  node_quick["Quick lookup<br/>[quick.py]"]
  node_loader["Document loader<br/>[document_loader.py]"]
  node_passages["Passage selection<br/>[passages.py]"]
  node_retriever["Follow-up retrieval<br/>[retriever.py]"]
end

subgraph group_identity["Accounts and policy"]
  node_accounts["Account security<br/>[accounts.py]"]
  node_mail["Email codes<br/>[mail.py]"]
  node_signup["Signup requests<br/>[signup.py]"]
  node_policy["Usage policy<br/>[policy.py]"]
end

subgraph group_persistence["Reports and state"]
  node_history[("SQLite history<br/>[history.py]")]
end

node_user(("Researcher"))
node_model_provider["Model provider"]
node_public_sources["Public sources"]

node_user -->|"asks question"| node_streamlit
node_user -->|"submits request"| node_api
node_streamlit -->|"runs research"| node_service
node_api -->|"runs research"| node_service
node_streamlit -->|"uses access"| node_studio
node_studio -->|"authenticates"| node_accounts
node_studio -->|"requests codes"| node_mail
node_studio -->|"handles signup"| node_signup
node_service -->|"runs workflow"| node_workflow
node_service -->|"answers follow-ups"| node_retriever
node_workflow -->|"dispatches"| node_manager
node_workflow -->|"dispatches"| node_researcher
node_workflow -->|"dispatches"| node_source_finder
node_workflow -->|"dispatches"| node_fact_checker
node_workflow -->|"dispatches"| node_analyst
node_workflow -->|"dispatches"| node_report
node_workflow -->|"routes lookups"| node_quick
node_manager -->|"requests model"| node_provider_config
node_fact_checker -->|"checks claims"| node_provider_config
node_fact_checker -->|"selects passages"| node_passages
node_researcher -->|"retrieves documents"| node_loader
node_researcher -->|"uses lookup"| node_quick
node_quick -->|"falls back to"| node_loader
node_quick -->|"searches web"| node_public_sources
node_loader -->|"fetches abstracts"| node_public_sources
node_provider_config -->|"sends requests"| node_model_provider
node_retriever -.->|"requests answers"| node_provider_config
node_streamlit -->|"builds PDF"| node_report
node_streamlit -->|"loads and saves"| node_history
node_api -->|"loads reports"| node_history
node_accounts -->|"uses email codes"| node_mail
node_accounts -->|"records events"| node_policy
node_accounts -->|"uses connection"| node_history
node_mail -->|"stores codes"| node_history
node_policy -->|"stores usage"| node_history
node_history -->|"records report events"| node_policy

click node_streamlit "https://github.com/kalyai1322005/impirex-research-assistant/blob/main/app.py"
click node_api "https://github.com/kalyai1322005/impirex-research-assistant/blob/main/api.py"
click node_studio "https://github.com/kalyai1322005/impirex-research-assistant/blob/main/studio.py"
click node_service "https://github.com/kalyai1322005/impirex-research-assistant/blob/main/research_service.py"
click node_workflow "https://github.com/kalyai1322005/impirex-research-assistant/blob/main/workflow/graph.py"
click node_manager "https://github.com/kalyai1322005/impirex-research-assistant/blob/main/agents/manager.py"
click node_researcher "https://github.com/kalyai1322005/impirex-research-assistant/blob/main/agents/researcher.py"
click node_source_finder "https://github.com/kalyai1322005/impirex-research-assistant/blob/main/agents/source_finder.py"
click node_fact_checker "https://github.com/kalyai1322005/impirex-research-assistant/blob/main/agents/fact_checker.py"
click node_analyst "https://github.com/kalyai1322005/impirex-research-assistant/blob/main/agents/analyst.py"
click node_report "https://github.com/kalyai1322005/impirex-research-assistant/blob/main/agents/report_generator.py"
click node_quick "https://github.com/kalyai1322005/impirex-research-assistant/blob/main/rag/quick.py"
click node_loader "https://github.com/kalyai1322005/impirex-research-assistant/blob/main/rag/document_loader.py"
click node_passages "https://github.com/kalyai1322005/impirex-research-assistant/blob/main/rag/passages.py"
click node_retriever "https://github.com/kalyai1322005/impirex-research-assistant/blob/main/rag/retriever.py"
click node_provider_config "https://github.com/kalyai1322005/impirex-research-assistant/blob/main/config.py"
click node_accounts "https://github.com/kalyai1322005/impirex-research-assistant/blob/main/database/accounts.py"
click node_mail "https://github.com/kalyai1322005/impirex-research-assistant/blob/main/database/mail.py"
click node_signup "https://github.com/kalyai1322005/impirex-research-assistant/blob/main/database/signup.py"
click node_policy "https://github.com/kalyai1322005/impirex-research-assistant/blob/main/database/policy.py"
click node_history "https://github.com/kalyai1322005/impirex-research-assistant/blob/main/database/history.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_streamlit,node_api,node_studio toneBlue
class node_service,node_workflow,node_manager,node_researcher,node_source_finder,node_fact_checker,node_analyst,node_report,node_provider_config toneAmber
class node_quick,node_loader,node_passages,node_retriever toneMint
class node_accounts,node_mail,node_signup,node_policy toneRose
class node_history,node_user,node_model_provider,node_public_sources toneIndigo
```

## Components

### User interfaces

- [Research desk](https://github.com/kalyai1322005/impirex-research-assistant/blob/main/app.py): `app.py`
- [HTTP API](https://github.com/kalyai1322005/impirex-research-assistant/blob/main/api.py): `api.py`
- [Access interface](https://github.com/kalyai1322005/impirex-research-assistant/blob/main/studio.py): `studio.py`

### Research workflow

- [Research service](https://github.com/kalyai1322005/impirex-research-assistant/blob/main/research_service.py): `research_service.py`
- [Workflow dispatcher](https://github.com/kalyai1322005/impirex-research-assistant/blob/main/workflow/graph.py): `workflow/graph.py`
- [Query manager](https://github.com/kalyai1322005/impirex-research-assistant/blob/main/agents/manager.py): `agents/manager.py`
- [Document research](https://github.com/kalyai1322005/impirex-research-assistant/blob/main/agents/researcher.py): `agents/researcher.py`
- [Source screening](https://github.com/kalyai1322005/impirex-research-assistant/blob/main/agents/source_finder.py): `agents/source_finder.py`
- [Fact checker](https://github.com/kalyai1322005/impirex-research-assistant/blob/main/agents/fact_checker.py): `agents/fact_checker.py`
- [Evidence analysis](https://github.com/kalyai1322005/impirex-research-assistant/blob/main/agents/analyst.py): `agents/analyst.py`
- [Report assembly](https://github.com/kalyai1322005/impirex-research-assistant/blob/main/agents/report_generator.py): `agents/report_generator.py`
- [Model configuration](https://github.com/kalyai1322005/impirex-research-assistant/blob/main/config.py): `config.py`

### Search and retrieval

- [Quick lookup](https://github.com/kalyai1322005/impirex-research-assistant/blob/main/rag/quick.py): `rag/quick.py`
- [Document loader](https://github.com/kalyai1322005/impirex-research-assistant/blob/main/rag/document_loader.py): `rag/document_loader.py`
- [Passage selection](https://github.com/kalyai1322005/impirex-research-assistant/blob/main/rag/passages.py): `rag/passages.py`
- [Follow-up retrieval](https://github.com/kalyai1322005/impirex-research-assistant/blob/main/rag/retriever.py): `rag/retriever.py`

### Accounts and policy

- [Account security](https://github.com/kalyai1322005/impirex-research-assistant/blob/main/database/accounts.py): `database/accounts.py`
- [Email codes](https://github.com/kalyai1322005/impirex-research-assistant/blob/main/database/mail.py): `database/mail.py`
- [Signup requests](https://github.com/kalyai1322005/impirex-research-assistant/blob/main/database/signup.py): `database/signup.py`
- [Usage policy](https://github.com/kalyai1322005/impirex-research-assistant/blob/main/database/policy.py): `database/policy.py`

### Reports and state

- [SQLite history](https://github.com/kalyai1322005/impirex-research-assistant/blob/main/database/history.py): `database/history.py`

### Other components

- **Researcher**
- **Model provider**
- **Public sources**

## Connections

- Researcher → Research desk: asks question (evidence: `README.md`)
- Researcher → HTTP API: submits request (evidence: `README.md`)
- Research desk → Research service: runs research (evidence: `app.py`)
- HTTP API → Research service: runs research (evidence: `api.py`)
- Research desk → Access interface: uses access (evidence: `app.py`)
- Access interface → Account security: authenticates (evidence: `studio.py`)
- Access interface → Email codes: requests codes (evidence: `studio.py`)
- Access interface → Signup requests: handles signup (evidence: `studio.py`)
- Research service → Workflow dispatcher: runs workflow (evidence: `research_service.py`)
- Research service → Follow-up retrieval: answers follow-ups (evidence: `research_service.py`)
- Workflow dispatcher → Query manager: dispatches (evidence: `workflow/graph.py`)
- Workflow dispatcher → Document research: dispatches (evidence: `workflow/graph.py`)
- Workflow dispatcher → Source screening: dispatches (evidence: `workflow/graph.py`)
- Workflow dispatcher → Fact checker: dispatches (evidence: `workflow/graph.py`)
- Workflow dispatcher → Evidence analysis: dispatches (evidence: `workflow/graph.py`)
- Workflow dispatcher → Report assembly: dispatches (evidence: `workflow/graph.py`)
- Workflow dispatcher → Quick lookup: routes lookups (evidence: `workflow/graph.py`)
- Query manager → Model configuration: requests model (evidence: `agents/manager.py`)
- Fact checker → Model configuration: checks claims (evidence: `agents/fact_checker.py`)
- Fact checker → Passage selection: selects passages (evidence: `agents/fact_checker.py`)
- Document research → Document loader: retrieves documents (evidence: `agents/researcher.py`)
- Document research → Quick lookup: uses lookup (evidence: `agents/researcher.py`)
- Quick lookup → Document loader: falls back to (evidence: `rag/quick.py`)
- Quick lookup → Public sources: searches web (evidence: `rag/quick.py`)
- Document loader → Public sources: fetches abstracts (evidence: `rag/document_loader.py`)
- Model configuration → Model provider: sends requests (evidence: `config.py`)
- Follow-up retrieval → Model configuration: requests answers (evidence: `rag/retriever.py`)
- Research desk → Report assembly: builds PDF (evidence: `app.py`)
- Research desk → SQLite history: loads and saves (evidence: `app.py`)
- HTTP API → SQLite history: loads reports (evidence: `api.py`)
- Account security → Email codes: uses email codes (evidence: `database/accounts.py`)
- Account security → Usage policy: records events (evidence: `database/accounts.py`)
- Account security → SQLite history: uses connection (evidence: `database/accounts.py`)
- Email codes → SQLite history: stores codes (evidence: `database/mail.py`)
- Usage policy → SQLite history: stores usage (evidence: `database/policy.py`)
- SQLite history → Usage policy: records report events (evidence: `database/history.py`)
