# omdehariya111/deligence architecture

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

- Interactive diagram: https://gitdiagram.com/omdehariya111/deligence
- Repository: https://github.com/omdehariya111/deligence

## Overview

DeligenX is a financial due-diligence platform: a user submits a ticker (optionally with a context file), a background job runs a five-agent analysis, and the platform returns an auditable investment memo. The README documents ingestion, financial analysis, market intelligence, risk assessment, and memo generation, plus authentication, payments, and live job progress. The graph preserves those stages and major capabilities; several links are documented in the README or SOURCE INDEX because their implementation files were not sampled.

Main entry points: [`api/routes.py`](https://github.com/omdehariya111/deligence/blob/main/api/routes.py) (REST API), [`crew.py`](https://github.com/omdehariya111/deligence/blob/main/crew.py) (Pipeline coordinator), [`utils/mcp_client.py`](https://github.com/omdehariya111/deligence/blob/main/utils/mcp_client.py) (MCP client), [`agents/ingestion/ingestion_agent.py`](https://github.com/omdehariya111/deligence/blob/main/agents/ingestion/ingestion_agent.py) (Data ingestion)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["User experience"]
  node_web["Web app<br/>[page.tsx]"]
end

subgraph group_platform["Platform services"]
  node_api["REST API<br/>[routes.py]"]
  node_auth["Authentication<br/>[auth_routes.py]"]
  node_jobsdb[("Users and jobs<br/>[models.py]")]
  node_worker["Job worker<br/>[celery_app.py]"]
  node_payments["Payments<br/>[payments_routes.py]"]
end

subgraph group_pipeline["Due diligence pipeline"]
  node_crew["Pipeline coordinator<br/>[crew.py]"]
  node_ingestion["Data ingestion<br/>[ingestion_agent.py]"]
  node_runstate[("Run-scoped state<br/>[paths.py]")]
  node_audit["Audit timeline<br/>[audit_logger.py]"]
end

subgraph group_data["Data and analysis"]
  node_analysis["Financial analysis<br/>[analysis_agent.py]"]
  node_ratios["Ratio engine"]
  node_market["Market intelligence"]
  node_risk["Risk assessment"]
  node_sec["SEC EDGAR tools"]
  node_markettools["Market data tools"]
  node_news["News tools<br/>[newsapi_server.py]"]
  node_fred["FRED tools<br/>[fred_server.py]"]
  node_mcpclient["MCP client<br/>[mcp_client.py]"]
end

subgraph group_report["Memo production"]
  node_memo["Memo generation"]
  node_verification["Memo verification"]
  node_rendering["Charts and narrative<br/>[chart_engine.py]"]
  node_output["Investment memo<br/>[html_renderer.py]"]
end

node_user(("User"))
node_stripe["Stripe"]

node_user -->|"uses"| node_web
node_web -->|"requests jobs"| node_api
node_api -->|"authenticates"| node_auth
node_auth -->|"reads users"| node_jobsdb
node_api -->|"stores jobs"| node_jobsdb
node_api -->|"dispatches job"| node_worker
node_worker -->|"runs pipeline"| node_crew
node_crew -->|"runs agent"| node_ingestion
node_crew -->|"runs agent"| node_analysis
node_crew -->|"runs agent"| node_market
node_crew -->|"runs agent"| node_risk
node_crew -->|"runs agent"| node_memo
node_ingestion -->|"uses paths"| node_runstate
node_ingestion -->|"records events"| node_audit
node_ingestion -->|"fetches data"| node_mcpclient
node_mcpclient -->|"calls tools"| node_sec
node_analysis -.->|"computes ratios"| node_ratios
node_market -.->|"fetches data"| node_mcpclient
node_mcpclient -.->|"calls tools"| node_markettools
node_mcpclient -.->|"calls tools"| node_news
node_mcpclient -.->|"calls tools"| node_fred
node_memo -.->|"verifies memo"| node_verification
node_memo -.->|"builds report"| node_rendering
node_memo -.->|"produces memo"| node_output
node_api -->|"reads logs"| node_audit
node_api -.->|"serves payment routes"| node_payments
node_payments -.->|"processes payments"| node_stripe
node_payments -->|"records events"| node_jobsdb

click node_web "https://github.com/omdehariya111/deligence/blob/main/frontend/src/app/dashboard/page.tsx"
click node_api "https://github.com/omdehariya111/deligence/blob/main/api/routes.py"
click node_auth "https://github.com/omdehariya111/deligence/blob/main/api/auth_routes.py"
click node_jobsdb "https://github.com/omdehariya111/deligence/blob/main/api/models.py"
click node_worker "https://github.com/omdehariya111/deligence/blob/main/api/celery_app.py"
click node_payments "https://github.com/omdehariya111/deligence/blob/main/api/payments_routes.py"
click node_crew "https://github.com/omdehariya111/deligence/blob/main/crew.py"
click node_ingestion "https://github.com/omdehariya111/deligence/blob/main/agents/ingestion/ingestion_agent.py"
click node_analysis "https://github.com/omdehariya111/deligence/blob/main/agents/analysis/analysis_agent.py"
click node_ratios "https://github.com/omdehariya111/deligence/blob/main/agents/analysis/module1_ratio_engine.py"
click node_market "https://github.com/omdehariya111/deligence/blob/main/agents/market_intelligence/market_intelligence_agent.py"
click node_risk "https://github.com/omdehariya111/deligence/blob/main/agents/risk_assessment/risk_assessment_agent.py"
click node_memo "https://github.com/omdehariya111/deligence/blob/main/agents/memo_generation/memo_generation_agent.py"
click node_verification "https://github.com/omdehariya111/deligence/blob/main/agents/memo_generation/verification_engine.py"
click node_rendering "https://github.com/omdehariya111/deligence/blob/main/agents/memo_generation/chart_engine.py"
click node_sec "https://github.com/omdehariya111/deligence/blob/main/mcp_servers/sec_edgar_server.py"
click node_markettools "https://github.com/omdehariya111/deligence/blob/main/mcp_servers/market_data_server.py"
click node_news "https://github.com/omdehariya111/deligence/blob/main/mcp_servers/newsapi_server.py"
click node_fred "https://github.com/omdehariya111/deligence/blob/main/mcp_servers/fred_server.py"
click node_mcpclient "https://github.com/omdehariya111/deligence/blob/main/utils/mcp_client.py"
click node_runstate "https://github.com/omdehariya111/deligence/blob/main/config/paths.py"
click node_audit "https://github.com/omdehariya111/deligence/blob/main/utils/audit_logger.py"
click node_output "https://github.com/omdehariya111/deligence/blob/main/agents/memo_generation/html_renderer.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_web,node_user toneBlue
class node_api,node_auth,node_jobsdb,node_worker,node_payments toneAmber
class node_crew,node_ingestion,node_runstate,node_audit toneMint
class node_analysis,node_ratios,node_market,node_risk,node_sec,node_markettools,node_news,node_fred,node_mcpclient toneRose
class node_memo,node_verification,node_rendering,node_output,node_stripe toneIndigo
```

## Components

### User experience

- [Web app](https://github.com/omdehariya111/deligence/blob/main/frontend/src/app/dashboard/page.tsx): `frontend/src/app/dashboard/page.tsx`

### Platform services

- [REST API](https://github.com/omdehariya111/deligence/blob/main/api/routes.py): `api/routes.py`
- [Authentication](https://github.com/omdehariya111/deligence/blob/main/api/auth_routes.py): `api/auth_routes.py`
- [Users and jobs](https://github.com/omdehariya111/deligence/blob/main/api/models.py): `api/models.py`
- [Job worker](https://github.com/omdehariya111/deligence/blob/main/api/celery_app.py): `api/celery_app.py`
- [Payments](https://github.com/omdehariya111/deligence/blob/main/api/payments_routes.py): `api/payments_routes.py`

### Due diligence pipeline

- [Pipeline coordinator](https://github.com/omdehariya111/deligence/blob/main/crew.py): `crew.py`
- [Data ingestion](https://github.com/omdehariya111/deligence/blob/main/agents/ingestion/ingestion_agent.py): `agents/ingestion/ingestion_agent.py`
- [Run-scoped state](https://github.com/omdehariya111/deligence/blob/main/config/paths.py): `config/paths.py`
- [Audit timeline](https://github.com/omdehariya111/deligence/blob/main/utils/audit_logger.py): `utils/audit_logger.py`

### Data and analysis

- [Financial analysis](https://github.com/omdehariya111/deligence/blob/main/agents/analysis/analysis_agent.py): `agents/analysis/analysis_agent.py`
- [Ratio engine](https://github.com/omdehariya111/deligence/blob/main/agents/analysis/module1_ratio_engine.py): `agents/analysis/module1_ratio_engine.py`
- [Market intelligence](https://github.com/omdehariya111/deligence/blob/main/agents/market_intelligence/market_intelligence_agent.py): `agents/market_intelligence/market_intelligence_agent.py`
- [Risk assessment](https://github.com/omdehariya111/deligence/blob/main/agents/risk_assessment/risk_assessment_agent.py): `agents/risk_assessment/risk_assessment_agent.py`
- [SEC EDGAR tools](https://github.com/omdehariya111/deligence/blob/main/mcp_servers/sec_edgar_server.py): `mcp_servers/sec_edgar_server.py`
- [Market data tools](https://github.com/omdehariya111/deligence/blob/main/mcp_servers/market_data_server.py): `mcp_servers/market_data_server.py`
- [News tools](https://github.com/omdehariya111/deligence/blob/main/mcp_servers/newsapi_server.py): `mcp_servers/newsapi_server.py`
- [FRED tools](https://github.com/omdehariya111/deligence/blob/main/mcp_servers/fred_server.py): `mcp_servers/fred_server.py`
- [MCP client](https://github.com/omdehariya111/deligence/blob/main/utils/mcp_client.py): `utils/mcp_client.py`

### Memo production

- [Memo generation](https://github.com/omdehariya111/deligence/blob/main/agents/memo_generation/memo_generation_agent.py): `agents/memo_generation/memo_generation_agent.py`
- [Memo verification](https://github.com/omdehariya111/deligence/blob/main/agents/memo_generation/verification_engine.py): `agents/memo_generation/verification_engine.py`
- [Charts and narrative](https://github.com/omdehariya111/deligence/blob/main/agents/memo_generation/chart_engine.py): `agents/memo_generation/chart_engine.py`
- [Investment memo](https://github.com/omdehariya111/deligence/blob/main/agents/memo_generation/html_renderer.py): `agents/memo_generation/html_renderer.py`

### Other components

- **User**
- **Stripe**

## Connections

- User → Web app: uses
- Web app → REST API: requests jobs
- REST API → Authentication: authenticates (evidence: `api/routes.py`)
- Authentication → Users and jobs: reads users (evidence: `api/auth_routes.py`)
- REST API → Users and jobs: stores jobs (evidence: `api/routes.py`)
- REST API → Job worker: dispatches job (evidence: `api/routes.py`)
- Job worker → Pipeline coordinator: runs pipeline (evidence: `api/celery_app.py`)
- Pipeline coordinator → Data ingestion: runs agent (evidence: `crew.py`)
- Pipeline coordinator → Financial analysis: runs agent (evidence: `crew.py`)
- Pipeline coordinator → Market intelligence: runs agent (evidence: `crew.py`)
- Pipeline coordinator → Risk assessment: runs agent (evidence: `crew.py`)
- Pipeline coordinator → Memo generation: runs agent (evidence: `crew.py`)
- Data ingestion → Run-scoped state: uses paths (evidence: `agents/ingestion/ingestion_agent.py`)
- Data ingestion → Audit timeline: records events (evidence: `agents/ingestion/ingestion_agent.py`)
- Data ingestion → MCP client: fetches data
- MCP client → SEC EDGAR tools: calls tools (evidence: `utils/mcp_client.py`)
- Financial analysis → Ratio engine: computes ratios
- Market intelligence → MCP client: fetches data
- MCP client → Market data tools: calls tools
- MCP client → News tools: calls tools
- MCP client → FRED tools: calls tools
- Memo generation → Memo verification: verifies memo
- Memo generation → Charts and narrative: builds report
- Memo generation → Investment memo: produces memo
- REST API → Audit timeline: reads logs (evidence: `api/routes.py`)
- REST API → Payments: serves payment routes
- Payments → Stripe: processes payments
- Payments → Users and jobs: records events (evidence: `api/payments_routes.py`)
