# harsh-0000/fy_project architecture

> Architecture diagram of the GitHub repository harsh-0000/fy_project, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-15). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/harsh-0000/fy_project
- Repository: https://github.com/harsh-0000/fy_project

## Overview

Irium is a FinTech research and document-analysis application. A user submits a query through the chat UI or research API; the API protects it, then the research service applies cache/workflow orchestration to produce a routed answer with evidence and citations. Complex research plans tasks, searches, reads, consolidates evidence, writes, and critiques with retry; document uploads follow parsing and analysis paths. Other major capabilities include auth, chat memory/history, PII controls, observability, and health checks. Edges follow excerpts, source-index references, or README statements; unsampled feature links are omitted where evidence does not establish a caller.

Main entry points: [`app/workflows/research_graph.py`](https://github.com/harsh-0000/fy_project/blob/main/app/workflows/research_graph.py) (Research graph), [`app/services/llm.py`](https://github.com/harsh-0000/fy_project/blob/main/app/services/llm.py) (LLM service), [`app/api/routes/research.py`](https://github.com/harsh-0000/fy_project/blob/main/app/api/routes/research.py) (Research endpoint), [`app/services/document_service.py`](https://github.com/harsh-0000/fy_project/blob/main/app/services/document_service.py) (Document service)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["User Entry"]
  node_frontend["Chat interface<br/>[app.js]"]
  node_api["FastAPI application<br/>[main.py]"]
  node_research_api["Research endpoint<br/>[research.py]"]
end

subgraph group_research["Research Workflow"]
  node_router["Tier router<br/>[router.py]"]
  node_workflow["Research graph<br/>[research_graph.py]"]
  node_simple["Simple answers<br/>[simple.py]"]
  node_verification["Fact verification<br/>[verification.py]"]
  node_planner["Research planner<br/>[planner.py]"]
  node_reader["Search reader<br/>[reader.py]"]
  node_evidence["Evidence consolidation<br/>[evidence.py]"]
  node_writer["Answer writer<br/>[writer.py]"]
  node_critic["Quality critic<br/>[critic.py]"]
end

subgraph group_documents["Document Analysis"]
  node_doc_api["Document endpoints<br/>[documents.py]"]
  node_doc_service["Document service"]
  node_doc_parser["Format parsers<br/>[parser.py]"]
  node_doc_validator["Document validator<br/>[validator.py]"]
  node_doc_agent["Document analysis agent"]
end

subgraph group_services["Shared Services"]
  node_llm["LLM service<br/>[llm.py]"]
  node_search["Search service<br/>[search.py]"]
  node_tavily["Tavily search<br/>[tavily.py]"]
  node_cache[("Response cache<br/>[cache.py]")]
  node_pii["PII protection<br/>[pii_detector.py]"]
  node_memory[("User memory<br/>[memory.py]")]
  node_chat_history[("Chat history<br/>[chat_history.py]")]
  node_auth["Authentication<br/>[auth.py]"]
end

subgraph group_platform["Data and Operations"]
  node_database[("Application database<br/>[session.py]")]
  node_observability["Tracing and metrics<br/>[observability.py]"]
  node_health["Health checks<br/>[health.py]"]
end

node_user(("Research user"))
node_llm_provider{{"LLM providers"}}

node_user -->|"uses"| node_frontend
node_frontend -.->|"sends queries"| node_api
node_user -->|"submits query"| node_research_api
node_api -->|"mounts routes"| node_research_api
node_research_api -->|"protects query"| node_pii
node_research_api -->|"resolves user"| node_auth
node_research_api -->|"runs research"| node_workflow
node_research_api -->|"saves conversation"| node_chat_history
node_research_api -->|"uses cache"| node_cache
node_workflow -->|"classifies query"| node_router
node_workflow -->|"routes simple"| node_simple
node_workflow -->|"routes verification"| node_verification
node_workflow -->|"routes complex"| node_planner
node_workflow -->|"extracts findings"| node_reader
node_workflow -->|"consolidates evidence"| node_evidence
node_workflow -->|"writes answer"| node_writer
node_workflow -->|"reviews answer"| node_critic
node_workflow -->|"retrieves sources"| node_search
node_workflow -->|"records metrics"| node_observability
node_router -->|"classifies fallback"| node_llm
node_simple -->|"generates answer"| node_llm
node_verification -->|"checks current facts"| node_search
node_planner -->|"decomposes query"| node_llm
node_reader -->|"extracts information"| node_llm
node_writer -->|"synthesizes answer"| node_llm
node_critic -->|"evaluates draft"| node_llm
node_search -->|"queries provider"| node_tavily
node_search -->|"caches results"| node_cache
node_llm -->|"invokes model"| node_llm_provider
node_doc_api -.->|"handles uploads"| node_doc_service
node_doc_service -->|"validates files"| node_doc_validator
node_doc_service -->|"parses content"| node_doc_parser
node_doc_service -.->|"stores documents"| node_database
node_doc_agent -->|"analyzes documents"| node_llm
node_api -->|"records requests"| node_observability
node_health -.->|"checks readiness"| node_llm_provider
node_auth -->|"reads users"| node_database
node_memory -.->|"persists memory"| node_database

click node_frontend "https://github.com/harsh-0000/fy_project/blob/main/frontend/app.js"
click node_api "https://github.com/harsh-0000/fy_project/blob/main/app/main.py"
click node_research_api "https://github.com/harsh-0000/fy_project/blob/main/app/api/routes/research.py"
click node_router "https://github.com/harsh-0000/fy_project/blob/main/app/agents/router.py"
click node_workflow "https://github.com/harsh-0000/fy_project/blob/main/app/workflows/research_graph.py"
click node_simple "https://github.com/harsh-0000/fy_project/blob/main/app/agents/simple.py"
click node_verification "https://github.com/harsh-0000/fy_project/blob/main/app/agents/verification.py"
click node_planner "https://github.com/harsh-0000/fy_project/blob/main/app/agents/planner.py"
click node_reader "https://github.com/harsh-0000/fy_project/blob/main/app/agents/reader.py"
click node_evidence "https://github.com/harsh-0000/fy_project/blob/main/app/agents/evidence.py"
click node_writer "https://github.com/harsh-0000/fy_project/blob/main/app/agents/writer.py"
click node_critic "https://github.com/harsh-0000/fy_project/blob/main/app/agents/critic.py"
click node_doc_api "https://github.com/harsh-0000/fy_project/blob/main/app/api/routes/documents.py"
click node_doc_service "https://github.com/harsh-0000/fy_project/blob/main/app/services/document_service.py"
click node_doc_parser "https://github.com/harsh-0000/fy_project/blob/main/app/documents/parser.py"
click node_doc_validator "https://github.com/harsh-0000/fy_project/blob/main/app/documents/validator.py"
click node_doc_agent "https://github.com/harsh-0000/fy_project/blob/main/app/agents/document_analysis.py"
click node_llm "https://github.com/harsh-0000/fy_project/blob/main/app/services/llm.py"
click node_search "https://github.com/harsh-0000/fy_project/blob/main/app/services/search.py"
click node_tavily "https://github.com/harsh-0000/fy_project/blob/main/app/providers/tavily.py"
click node_cache "https://github.com/harsh-0000/fy_project/blob/main/app/services/cache.py"
click node_pii "https://github.com/harsh-0000/fy_project/blob/main/app/services/pii_detector.py"
click node_memory "https://github.com/harsh-0000/fy_project/blob/main/app/services/memory.py"
click node_chat_history "https://github.com/harsh-0000/fy_project/blob/main/app/services/chat_history.py"
click node_auth "https://github.com/harsh-0000/fy_project/blob/main/app/services/auth.py"
click node_database "https://github.com/harsh-0000/fy_project/blob/main/app/database/session.py"
click node_observability "https://github.com/harsh-0000/fy_project/blob/main/app/core/observability.py"
click node_health "https://github.com/harsh-0000/fy_project/blob/main/app/api/routes/health.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_frontend,node_api,node_research_api,node_user toneBlue
class node_router,node_workflow,node_simple,node_verification,node_planner,node_reader,node_evidence,node_writer,node_critic toneAmber
class node_doc_api,node_doc_service,node_doc_parser,node_doc_validator,node_doc_agent toneMint
class node_llm,node_search,node_tavily,node_cache,node_pii,node_memory,node_chat_history,node_auth toneRose
class node_database,node_observability,node_health,node_llm_provider toneIndigo
```

## Components

### User Entry

- [Chat interface](https://github.com/harsh-0000/fy_project/blob/main/frontend/app.js): `frontend/app.js`
- [FastAPI application](https://github.com/harsh-0000/fy_project/blob/main/app/main.py): `app/main.py`
- [Research endpoint](https://github.com/harsh-0000/fy_project/blob/main/app/api/routes/research.py): `app/api/routes/research.py`

### Research Workflow

- [Tier router](https://github.com/harsh-0000/fy_project/blob/main/app/agents/router.py): `app/agents/router.py`
- [Research graph](https://github.com/harsh-0000/fy_project/blob/main/app/workflows/research_graph.py): `app/workflows/research_graph.py`
- [Simple answers](https://github.com/harsh-0000/fy_project/blob/main/app/agents/simple.py): `app/agents/simple.py`
- [Fact verification](https://github.com/harsh-0000/fy_project/blob/main/app/agents/verification.py): `app/agents/verification.py`
- [Research planner](https://github.com/harsh-0000/fy_project/blob/main/app/agents/planner.py): `app/agents/planner.py`
- [Search reader](https://github.com/harsh-0000/fy_project/blob/main/app/agents/reader.py): `app/agents/reader.py`
- [Evidence consolidation](https://github.com/harsh-0000/fy_project/blob/main/app/agents/evidence.py): `app/agents/evidence.py`
- [Answer writer](https://github.com/harsh-0000/fy_project/blob/main/app/agents/writer.py): `app/agents/writer.py`
- [Quality critic](https://github.com/harsh-0000/fy_project/blob/main/app/agents/critic.py): `app/agents/critic.py`

### Document Analysis

- [Document endpoints](https://github.com/harsh-0000/fy_project/blob/main/app/api/routes/documents.py): `app/api/routes/documents.py`
- [Document service](https://github.com/harsh-0000/fy_project/blob/main/app/services/document_service.py): `app/services/document_service.py`
- [Format parsers](https://github.com/harsh-0000/fy_project/blob/main/app/documents/parser.py): `app/documents/parser.py`
- [Document validator](https://github.com/harsh-0000/fy_project/blob/main/app/documents/validator.py): `app/documents/validator.py`
- [Document analysis agent](https://github.com/harsh-0000/fy_project/blob/main/app/agents/document_analysis.py): `app/agents/document_analysis.py`

### Shared Services

- [LLM service](https://github.com/harsh-0000/fy_project/blob/main/app/services/llm.py): `app/services/llm.py`
- [Search service](https://github.com/harsh-0000/fy_project/blob/main/app/services/search.py): `app/services/search.py`
- [Tavily search](https://github.com/harsh-0000/fy_project/blob/main/app/providers/tavily.py): `app/providers/tavily.py`
- [Response cache](https://github.com/harsh-0000/fy_project/blob/main/app/services/cache.py): `app/services/cache.py`
- [PII protection](https://github.com/harsh-0000/fy_project/blob/main/app/services/pii_detector.py): `app/services/pii_detector.py`
- [User memory](https://github.com/harsh-0000/fy_project/blob/main/app/services/memory.py): `app/services/memory.py`
- [Chat history](https://github.com/harsh-0000/fy_project/blob/main/app/services/chat_history.py): `app/services/chat_history.py`
- [Authentication](https://github.com/harsh-0000/fy_project/blob/main/app/services/auth.py): `app/services/auth.py`

### Data and Operations

- [Application database](https://github.com/harsh-0000/fy_project/blob/main/app/database/session.py): `app/database/session.py`
- [Tracing and metrics](https://github.com/harsh-0000/fy_project/blob/main/app/core/observability.py): `app/core/observability.py`
- [Health checks](https://github.com/harsh-0000/fy_project/blob/main/app/api/routes/health.py): `app/api/routes/health.py`

### Other components

- **Research user**
- **LLM providers**

## Connections

- Research user → Chat interface: uses
- Chat interface → FastAPI application: sends queries
- Research user → Research endpoint: submits query
- FastAPI application → Research endpoint: mounts routes (evidence: `app/main.py`)
- Research endpoint → PII protection: protects query (evidence: `app/api/routes/research.py`)
- Research endpoint → Authentication: resolves user (evidence: `app/api/routes/research.py`)
- Research endpoint → Research graph: runs research
- Research endpoint → Chat history: saves conversation (evidence: `app/api/routes/research.py`)
- Research endpoint → Response cache: uses cache (evidence: `app/api/routes/research.py`)
- Research graph → Tier router: classifies query (evidence: `app/workflows/research_graph.py`)
- Research graph → Simple answers: routes simple (evidence: `app/workflows/research_graph.py`)
- Research graph → Fact verification: routes verification (evidence: `app/workflows/research_graph.py`)
- Research graph → Research planner: routes complex (evidence: `app/workflows/research_graph.py`)
- Research graph → Search reader: extracts findings (evidence: `app/workflows/research_graph.py`)
- Research graph → Evidence consolidation: consolidates evidence (evidence: `app/workflows/research_graph.py`)
- Research graph → Answer writer: writes answer (evidence: `app/workflows/research_graph.py`)
- Research graph → Quality critic: reviews answer (evidence: `app/workflows/research_graph.py`)
- Research graph → Search service: retrieves sources (evidence: `app/workflows/research_graph.py`)
- Research graph → Tracing and metrics: records metrics (evidence: `app/workflows/research_graph.py`)
- Tier router → LLM service: classifies fallback (evidence: `app/agents/router.py`)
- Simple answers → LLM service: generates answer (evidence: `app/agents/simple.py`)
- Fact verification → Search service: checks current facts (evidence: `app/agents/verification.py`)
- Research planner → LLM service: decomposes query (evidence: `app/agents/planner.py`)
- Search reader → LLM service: extracts information (evidence: `app/agents/reader.py`)
- Answer writer → LLM service: synthesizes answer (evidence: `app/agents/writer.py`)
- Quality critic → LLM service: evaluates draft (evidence: `app/agents/critic.py`)
- Search service → Tavily search: queries provider (evidence: `app/services/search.py`)
- Search service → Response cache: caches results (evidence: `app/services/search.py`)
- LLM service → LLM providers: invokes model (evidence: `app/services/llm.py`)
- Document endpoints → Document service: handles uploads
- Document service → Document validator: validates files (evidence: `app/services/document_service.py`)
- Document service → Format parsers: parses content (evidence: `app/services/document_service.py`)
- Document service → Application database: stores documents
- Document analysis agent → LLM service: analyzes documents
- FastAPI application → Tracing and metrics: records requests (evidence: `app/main.py`)
- Health checks → LLM providers: checks readiness
- Authentication → Application database: reads users (evidence: `app/services/auth.py`)
- User memory → Application database: persists memory
