How vyngo98/financial_analysis_agent works
This is a local financial-report PDF analysis application. Users upload a report, which is routed through native-table or scanned-document extraction, chunked with page and financial metadata, and indexed; they then ask questions through the UI or CLI and receive sourced answers, with Python handling supported ratio/growth calculations. The graph also shows document/session persistence, hybrid/adaptive retrieval, and the documented evaluation capability. Some subsystem links are based on README descriptions or source-index references; unsampled implementation details are not inferred.
Main entry points: pdf_ingestion.py PDF ingestion and chunking · financial_agent.py Agent entry and tools · retrieval.py Hybrid retrieval · api.py FastAPI
Components 21
User interface
- Web UI
app/frontend/app.js - FastAPI
app/api.py - CLI
app/main.py - JSON registry and sessions
app/storage.py
PDF ingestion
- PDF ingestion and chunking
app/ingestion/pdf_ingestion.py - Native table extraction
app/ingestion/camelot_extract.py - Tabula extraction
app/ingestion/tabula_extract.py - Scanned PDF OCR
app/ingestion/ocr.py
Retrieval and storage
- Vector store access
app/rag/vector_store.py - Qdrant
- Ollama embeddings
- Hybrid retrieval
app/rag/retrieval.py - Adaptive retrieval
app/rag/adaptive.py
Agent reasoning
- PDF search tool
app/tools/rag_tool.py - Agent entry and tools
app/agent/financial_agent.py - Reasoning graph
app/agent/graph.py - Tool-call repair
app/agent/tool_call_repair.py - Deterministic calculator
app/tools/calc_tool.py
Evaluation
- Evaluation runner
app/eval/run_eval.py - Failure analysis
app/eval/dump_failures.py
Other components
- User
Connections 32
- User → Web UI: asks questions
README.md - User → FastAPI: uploads reports
README.md - Web UI → FastAPI: uses API
README.md - FastAPI → JSON registry and sessions: persists sessions
app/api.py - FastAPI → PDF ingestion and chunking: ingests uploads
app/api.py - FastAPI → Agent entry and tools: invokes agent
app/api.py - User → CLI: runs commands
README.md - CLI → PDF ingestion and chunking: ingests PDFs
app/main.py - CLI → Agent entry and tools: asks questions
app/main.py - PDF ingestion and chunking → Native table extraction: extracts native tables
app/ingestion/pdf_ingestion.py - PDF ingestion and chunking → Scanned PDF OCR: routes scanned pages
app/ingestion/pdf_ingestion.py - PDF ingestion and chunking → Tabula extraction: supports extraction
app/ingestion/tabula_extract.py - PDF ingestion and chunking → Vector store access: indexes chunks
app/ingestion/pdf_ingestion.py - Vector store access → Ollama embeddings: creates embeddings
app/rag/vector_store.py - Vector store access → Qdrant: reads and writes
app/rag/vector_store.py - Hybrid retrieval → Vector store access: loads indexed chunks
app/rag/retrieval.py - Hybrid retrieval → Adaptive retrieval: dispatches adaptive mode
app/rag/retrieval.py - PDF search tool → Hybrid retrieval: retrieves context
app/tools/rag_tool.py - PDF search tool → Adaptive retrieval: decomposes metrics
app/tools/rag_tool.py - Agent entry and tools → PDF search tool: registers search tool
app/agent/financial_agent.py - Agent entry and tools → Deterministic calculator: registers calculator
app/agent/financial_agent.py - Agent entry and tools → Tool-call repair: installs middleware
app/agent/financial_agent.py - Agent entry and tools → Reasoning graph: selects graph mode
app/agent/financial_agent.py - Reasoning graph → Hybrid retrieval: retrieves and rewrites
app/agent/graph.py - Reasoning graph → Adaptive retrieval: decomposes operands
app/agent/graph.py - Reasoning graph → PDF ingestion and chunking: resolves document
app/agent/graph.py - Evaluation runner → PDF ingestion and chunking: indexes evaluation PDFs
app/eval/run_eval.py - Evaluation runner → Agent entry and tools: evaluates answers
app/eval/run_eval.py - Evaluation runner → Hybrid retrieval: scores retrieval
app/eval/run_eval.py - Evaluation runner → Failure analysis: dumps failures
app/eval/run_eval.py - Failure analysis → Hybrid retrieval: replays retrieval
app/eval/dump_failures.py - Failure analysis → Vector store access: reads gold chunks
app/eval/dump_failures.py