# polestardhruvtiwari/denave architecture

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

- Interactive diagram: https://gitdiagram.com/polestardhruvtiwari/denave
- Repository: https://github.com/polestardhruvtiwari/denave

## Overview

This CLI extracts structured financials, risks, and business segments from SEC 10-K filings or local PDFs, then validates and saves a quality-scored JSON result. The graph follows the documented LangGraph stages; the source excerpt omits some workflow wiring, so those transitions rely on the README architecture. Detailed PDF-fetch and section-splitting implementations are not shown in the sampled source.

Main entry points: [`extractor.py`](https://github.com/polestardhruvtiwari/denave/blob/main/extractor.py) (LangGraph workflow), [`main.py`](https://github.com/polestardhruvtiwari/denave/blob/main/main.py) (CLI entry)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["CLI and orchestration"]
  node_cli["CLI entry<br/>[main.py]"]
  node_extractor["Financial extractor<br/>[extractor.py]"]
end

subgraph group_documents["Document acquisition"]
  node_fetcher["Document fetcher<br/>[extractor.py]"]
  node_splitter["Section identifier<br/>[extractor.py]"]
end

subgraph group_workflow["Extraction workflow"]
  node_workflow["LangGraph workflow<br/>[extractor.py]"]
  node_financials["Extract financials<br/>[extractor.py]"]
  node_validation["Validate data<br/>[extractor.py]"]
  node_risks["Extract risks<br/>[extractor.py]"]
  node_segments["Extract segments<br/>[extractor.py]"]
  node_quality["Quality check<br/>[extractor.py]"]
end

subgraph group_output["Results"]
  node_json["Result JSON<br/>[extractor.py]"]
end

node_user(("User"))
node_sec["SEC EDGAR"]
node_openai["OpenAI LLM"]
node_output_files[("Output files")]

node_user -->|"provides ticker/PDF"| node_cli
node_cli -->|"runs extraction"| node_extractor
node_extractor -->|"fetches document"| node_fetcher
node_fetcher -->|"downloads filing"| node_sec
node_fetcher -->|"returns text"| node_splitter
node_extractor -->|"splits sections"| node_splitter
node_extractor -->|"invokes workflow"| node_workflow
node_workflow -->|"dispatches"| node_financials
node_financials -->|"requests extraction"| node_openai
node_workflow -->|"dispatches"| node_validation
node_validation -->|"retries on failure"| node_financials
node_workflow -->|"continues"| node_risks
node_risks -->|"requests extraction"| node_openai
node_workflow -->|"continues"| node_segments
node_segments -->|"requests extraction"| node_openai
node_workflow -->|"continues"| node_quality
node_workflow -->|"returns final state"| node_json
node_extractor -->|"writes JSON"| node_output_files
node_json -->|"returns result"| node_cli

click node_cli "https://github.com/polestardhruvtiwari/denave/blob/main/main.py"
click node_extractor "https://github.com/polestardhruvtiwari/denave/blob/main/extractor.py"
click node_fetcher "https://github.com/polestardhruvtiwari/denave/blob/main/extractor.py"
click node_splitter "https://github.com/polestardhruvtiwari/denave/blob/main/extractor.py"
click node_workflow "https://github.com/polestardhruvtiwari/denave/blob/main/extractor.py"
click node_financials "https://github.com/polestardhruvtiwari/denave/blob/main/extractor.py"
click node_validation "https://github.com/polestardhruvtiwari/denave/blob/main/extractor.py"
click node_risks "https://github.com/polestardhruvtiwari/denave/blob/main/extractor.py"
click node_segments "https://github.com/polestardhruvtiwari/denave/blob/main/extractor.py"
click node_quality "https://github.com/polestardhruvtiwari/denave/blob/main/extractor.py"
click node_json "https://github.com/polestardhruvtiwari/denave/blob/main/extractor.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_cli,node_extractor,node_user toneBlue
class node_fetcher,node_splitter,node_output_files toneAmber
class node_workflow,node_financials,node_validation,node_risks,node_segments,node_quality toneMint
class node_json toneRose
class node_sec,node_openai toneIndigo
```

## Components

### CLI and orchestration

- [CLI entry](https://github.com/polestardhruvtiwari/denave/blob/main/main.py): `main.py`
- [Financial extractor](https://github.com/polestardhruvtiwari/denave/blob/main/extractor.py): `extractor.py`

### Document acquisition

- [Document fetcher](https://github.com/polestardhruvtiwari/denave/blob/main/extractor.py): `extractor.py`
- [Section identifier](https://github.com/polestardhruvtiwari/denave/blob/main/extractor.py): `extractor.py`

### Extraction workflow

- [LangGraph workflow](https://github.com/polestardhruvtiwari/denave/blob/main/extractor.py): `extractor.py`
- [Extract financials](https://github.com/polestardhruvtiwari/denave/blob/main/extractor.py): `extractor.py`
- [Validate data](https://github.com/polestardhruvtiwari/denave/blob/main/extractor.py): `extractor.py`
- [Extract risks](https://github.com/polestardhruvtiwari/denave/blob/main/extractor.py): `extractor.py`
- [Extract segments](https://github.com/polestardhruvtiwari/denave/blob/main/extractor.py): `extractor.py`
- [Quality check](https://github.com/polestardhruvtiwari/denave/blob/main/extractor.py): `extractor.py`

### Results

- [Result JSON](https://github.com/polestardhruvtiwari/denave/blob/main/extractor.py): `extractor.py`

### Other components

- **User**
- **SEC EDGAR**
- **OpenAI LLM**
- **Output files**

## Connections

- User → CLI entry: provides ticker/PDF
- CLI entry → Financial extractor: runs extraction
- Financial extractor → Document fetcher: fetches document
- Document fetcher → SEC EDGAR: downloads filing
- Document fetcher → Section identifier: returns text
- Financial extractor → Section identifier: splits sections
- Financial extractor → LangGraph workflow: invokes workflow
- LangGraph workflow → Extract financials: dispatches
- Extract financials → OpenAI LLM: requests extraction
- LangGraph workflow → Validate data: dispatches
- Validate data → Extract financials: retries on failure
- LangGraph workflow → Extract risks: continues
- Extract risks → OpenAI LLM: requests extraction
- LangGraph workflow → Extract segments: continues
- Extract segments → OpenAI LLM: requests extraction
- LangGraph workflow → Quality check: continues
- LangGraph workflow → Result JSON: returns final state
- Financial extractor → Output files: writes JSON
- Result JSON → CLI entry: returns result
