# shivamrai009/finance-graph-rag architecture

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

- Interactive diagram: https://gitdiagram.com/shivamrai009/finance-graph-rag
- Repository: https://github.com/shivamrai009/finance-graph-rag

## Overview

This repository is an SEC-filings ingestion and financial question-answering product. Its main workflow fetches filings, processes them into sections and embeddings, stores them in a Neo4j graph, then retrieves relevant evidence to answer user questions with citations. The graph preserves separate ingestion entry points and specialized insider-trading processing. Some connections are supported only by the README or SOURCE INDEX; unsampled implementation details are not assumed.

Main entry points: [`src/data/enhanced_sec_pipeline.py`](https://github.com/shivamrai009/finance-graph-rag/blob/main/src/data/enhanced_sec_pipeline.py) (Enhanced Pipeline), [`src/core/neo4j_retrieval_engine.py`](https://github.com/shivamrai009/finance-graph-rag/blob/main/src/core/neo4j_retrieval_engine.py) (Hybrid Retrieval), [`src/data/secio_client.py`](https://github.com/shivamrai009/finance-graph-rag/blob/main/src/data/secio_client.py) (SECIO Wrapper), [`src/storage/neo4j_client.py`](https://github.com/shivamrai009/finance-graph-rag/blob/main/src/storage/neo4j_client.py) (Graph Client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ingestion["Ingestion"]
  node_comprehensive_ingest["Comprehensive Ingest"]
  node_ingest_engine["Ingestion Engine"]
  node_enhanced_pipeline["Enhanced Pipeline"]
  node_bulk_ingest["Ticker Ingest"]
  node_ingest_cli["Ingest CLI"]
  node_assignment_collector["Research Collector"]
  node_assignment_strategy["Research Scope"]
  node_edgar_client["EDGAR Client"]
  node_secio_client["SECIO Wrapper<br/>[secio_client.py]"]
end

subgraph group_processing["Document Processing"]
  node_document_processor["Filing Processor"]
  node_insider_processor["Insider Forms"]
  node_embedding_ensemble["Embedding Ensemble"]
end

subgraph group_qa["Question Answering"]
  node_qa_system["SEC QA System<br/>[sec_qa_system.py]"]
  node_question_answering["Question Answering"]
  node_retrieval_engine["Hybrid Retrieval"]
end

subgraph group_storage["Knowledge Graph"]
  node_neo4j_client["Graph Client<br/>[neo4j_client.py]"]
  node_neo4j_db[("Neo4j Graph")]
end

node_researcher(("Researcher"))
node_sec_edgar{{"SEC EDGAR"}}
node_openai{{"GPT-4o"}}

node_researcher -->|"asks questions"| node_qa_system
node_researcher -->|"asks questions"| node_question_answering
node_qa_system -.->|"retrieves evidence"| node_retrieval_engine
node_question_answering -->|"retrieves evidence"| node_retrieval_engine
node_retrieval_engine -.->|"embeds queries"| node_embedding_ensemble
node_retrieval_engine -->|"searches graph"| node_neo4j_client
node_retrieval_engine -->|"supplies evidence"| node_openai
node_openai -->|"returns cited answers"| node_researcher
node_comprehensive_ingest -.->|"fetches filings"| node_edgar_client
node_comprehensive_ingest -->|"gets filing content"| node_secio_client
node_comprehensive_ingest -->|"processes filings"| node_document_processor
node_ingest_engine -->|"gets filing content"| node_secio_client
node_ingest_engine -->|"extracts sections"| node_document_processor
node_ingest_engine -.->|"delegates ingestion"| node_enhanced_pipeline
node_enhanced_pipeline -.->|"chunks documents"| node_document_processor
node_enhanced_pipeline -.->|"processes insider forms"| node_insider_processor
node_enhanced_pipeline -.->|"generates embeddings"| node_embedding_ensemble
node_enhanced_pipeline -->|"stores records"| node_neo4j_client
node_bulk_ingest -.->|"fetches filings"| node_secio_client
node_ingest_cli -->|"runs ingestion"| node_enhanced_pipeline
node_assignment_collector -->|"uses research scope"| node_assignment_strategy
node_secio_client -->|"wraps client"| node_edgar_client
node_edgar_client -->|"requests filings"| node_sec_edgar
node_embedding_ensemble -.->|"stores vectors"| node_neo4j_client
node_neo4j_client -->|"reads and writes"| node_neo4j_db

click node_comprehensive_ingest "https://github.com/shivamrai009/finance-graph-rag/blob/main/comprehensive_sec_ingest.py"
click node_ingest_engine "https://github.com/shivamrai009/finance-graph-rag/blob/main/data_ingestion_engine.py"
click node_enhanced_pipeline "https://github.com/shivamrai009/finance-graph-rag/blob/main/src/data/enhanced_sec_pipeline.py"
click node_bulk_ingest "https://github.com/shivamrai009/finance-graph-rag/blob/main/ingest_all_tickers.py"
click node_ingest_cli "https://github.com/shivamrai009/finance-graph-rag/blob/main/scripts/enhanced_ingest_cli.py"
click node_assignment_collector "https://github.com/shivamrai009/finance-graph-rag/blob/main/scripts/assignment_collector.py"
click node_assignment_strategy "https://github.com/shivamrai009/finance-graph-rag/blob/main/config/assignment_strategy.py"
click node_edgar_client "https://github.com/shivamrai009/finance-graph-rag/blob/main/src/data/sec_edgar_client.py"
click node_secio_client "https://github.com/shivamrai009/finance-graph-rag/blob/main/src/data/secio_client.py"
click node_document_processor "https://github.com/shivamrai009/finance-graph-rag/blob/main/src/data/document_processor.py"
click node_insider_processor "https://github.com/shivamrai009/finance-graph-rag/blob/main/src/data/forms_345_processor.py"
click node_embedding_ensemble "https://github.com/shivamrai009/finance-graph-rag/blob/main/src/core/embedding_ensemble.py"
click node_qa_system "https://github.com/shivamrai009/finance-graph-rag/blob/main/sec_qa_system.py"
click node_question_answering "https://github.com/shivamrai009/finance-graph-rag/blob/main/question_answering_system.py"
click node_retrieval_engine "https://github.com/shivamrai009/finance-graph-rag/blob/main/src/core/neo4j_retrieval_engine.py"
click node_neo4j_client "https://github.com/shivamrai009/finance-graph-rag/blob/main/src/storage/neo4j_client.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_comprehensive_ingest,node_ingest_engine,node_enhanced_pipeline,node_bulk_ingest,node_ingest_cli,node_assignment_collector,node_assignment_strategy,node_edgar_client,node_secio_client toneBlue
class node_document_processor,node_insider_processor,node_embedding_ensemble toneAmber
class node_qa_system,node_question_answering,node_retrieval_engine toneMint
class node_neo4j_client,node_neo4j_db toneRose
class node_researcher,node_sec_edgar,node_openai toneIndigo
```

## Components

### Ingestion

- [Comprehensive Ingest](https://github.com/shivamrai009/finance-graph-rag/blob/main/comprehensive_sec_ingest.py): `comprehensive_sec_ingest.py`
- [Ingestion Engine](https://github.com/shivamrai009/finance-graph-rag/blob/main/data_ingestion_engine.py): `data_ingestion_engine.py`
- [Enhanced Pipeline](https://github.com/shivamrai009/finance-graph-rag/blob/main/src/data/enhanced_sec_pipeline.py): `src/data/enhanced_sec_pipeline.py`
- [Ticker Ingest](https://github.com/shivamrai009/finance-graph-rag/blob/main/ingest_all_tickers.py): `ingest_all_tickers.py`
- [Ingest CLI](https://github.com/shivamrai009/finance-graph-rag/blob/main/scripts/enhanced_ingest_cli.py): `scripts/enhanced_ingest_cli.py`
- [Research Collector](https://github.com/shivamrai009/finance-graph-rag/blob/main/scripts/assignment_collector.py): `scripts/assignment_collector.py`
- [Research Scope](https://github.com/shivamrai009/finance-graph-rag/blob/main/config/assignment_strategy.py): `config/assignment_strategy.py`
- [EDGAR Client](https://github.com/shivamrai009/finance-graph-rag/blob/main/src/data/sec_edgar_client.py): `src/data/sec_edgar_client.py`
- [SECIO Wrapper](https://github.com/shivamrai009/finance-graph-rag/blob/main/src/data/secio_client.py): `src/data/secio_client.py`

### Document Processing

- [Filing Processor](https://github.com/shivamrai009/finance-graph-rag/blob/main/src/data/document_processor.py): `src/data/document_processor.py`
- [Insider Forms](https://github.com/shivamrai009/finance-graph-rag/blob/main/src/data/forms_345_processor.py): `src/data/forms_345_processor.py`
- [Embedding Ensemble](https://github.com/shivamrai009/finance-graph-rag/blob/main/src/core/embedding_ensemble.py): `src/core/embedding_ensemble.py`

### Question Answering

- [SEC QA System](https://github.com/shivamrai009/finance-graph-rag/blob/main/sec_qa_system.py): `sec_qa_system.py`
- [Question Answering](https://github.com/shivamrai009/finance-graph-rag/blob/main/question_answering_system.py): `question_answering_system.py`
- [Hybrid Retrieval](https://github.com/shivamrai009/finance-graph-rag/blob/main/src/core/neo4j_retrieval_engine.py): `src/core/neo4j_retrieval_engine.py`

### Knowledge Graph

- [Graph Client](https://github.com/shivamrai009/finance-graph-rag/blob/main/src/storage/neo4j_client.py): `src/storage/neo4j_client.py`
- **Neo4j Graph**

### Other components

- **Researcher**
- **SEC EDGAR**
- **GPT-4o**

## Connections

- Researcher → SEC QA System: asks questions (evidence: `README.md`)
- Researcher → Question Answering: asks questions (evidence: `README.md`)
- SEC QA System → Hybrid Retrieval: retrieves evidence
- Question Answering → Hybrid Retrieval: retrieves evidence (evidence: `question_answering_system.py`)
- Hybrid Retrieval → Embedding Ensemble: embeds queries (evidence: `src/core/neo4j_retrieval_engine.py`)
- Hybrid Retrieval → Graph Client: searches graph (evidence: `src/core/neo4j_retrieval_engine.py`)
- Hybrid Retrieval → GPT-4o: supplies evidence (evidence: `README.md`)
- GPT-4o → Researcher: returns cited answers (evidence: `README.md`)
- Comprehensive Ingest → EDGAR Client: fetches filings
- Comprehensive Ingest → SECIO Wrapper: gets filing content (evidence: `comprehensive_sec_ingest.py`)
- Comprehensive Ingest → Filing Processor: processes filings (evidence: `comprehensive_sec_ingest.py`)
- Ingestion Engine → SECIO Wrapper: gets filing content (evidence: `data_ingestion_engine.py`)
- Ingestion Engine → Filing Processor: extracts sections (evidence: `data_ingestion_engine.py`)
- Ingestion Engine → Enhanced Pipeline: delegates ingestion (evidence: `data_ingestion_engine.py`)
- Enhanced Pipeline → Filing Processor: chunks documents (evidence: `src/data/enhanced_sec_pipeline.py`)
- Enhanced Pipeline → Insider Forms: processes insider forms (evidence: `src/data/enhanced_sec_pipeline.py`)
- Enhanced Pipeline → Embedding Ensemble: generates embeddings (evidence: `src/data/enhanced_sec_pipeline.py`)
- Enhanced Pipeline → Graph Client: stores records (evidence: `src/data/enhanced_sec_pipeline.py`)
- Ticker Ingest → SECIO Wrapper: fetches filings (evidence: `ingest_all_tickers.py`)
- Ingest CLI → Enhanced Pipeline: runs ingestion (evidence: `scripts/enhanced_ingest_cli.py`)
- Research Collector → Research Scope: uses research scope (evidence: `scripts/assignment_collector.py`)
- SECIO Wrapper → EDGAR Client: wraps client (evidence: `src/data/secio_client.py`)
- EDGAR Client → SEC EDGAR: requests filings (evidence: `README.md`)
- Embedding Ensemble → Graph Client: stores vectors
- Graph Client → Neo4j Graph: reads and writes (evidence: `src/storage/neo4j_client.py`)
