How sandesh-hase/ai-powered-investor-intelligence-platform works
This is a FastAPI investor-intelligence backend. Its primary workflow accepts an annual-report PDF, converts and chunks it, indexes the chunks in Azure AI Search, extracts financial metrics with retrieval-augmented Azure OpenAI, and stores KPIs in PostgreSQL; chat and dashboard endpoints expose results. The graph also preserves index initialization and the separate API entry point. Edges reflect the excerpts, SOURCE INDEX references, or README; unsampled internals are not inferred.
Main entry points: app.py FastAPI application · ingest_documents.py Document orchestrator · postgres_sql.py PostgreSQL connection · chat.py Chat endpoint
Components 22
API and presentation
- FastAPI application
app.py - Dashboard template
templates/dashboard.html - Dashboard API routes
routes/dashboard.py - Health routes
routes/health.py - Upload endpoint
routes/ingestion.py - Chat endpoint
routes/chat.py - Alternate API entry
main.py
Report ingestion
- PDF conversion
ingestion/pdf_to_markdown.py - Semantic chunking
ingestion/semantic_chunker.py - Document orchestrator
ingestion/ingest_documents.py
Search and AI
- Search vector store
vectorstore/azure_ai_search.py - Search index setup
vectorstore/create_index.py - KPI extraction RAG
rag/kpi_extractor_rag.py - Azure OpenAI client
llm/azure_openai.py
Persistence
- KPI persistence
database/save_metrics.py - Metrics reader
database/metrics.py - Metrics table setup
database/create_table.py - PostgreSQL connection
database/postgres_sql.py
External services
- Azure AI Search
- Azure OpenAI service
- PostgreSQL database
Other components
- Investor / uploader
Connections 33
- Investor / uploader → FastAPI application: uses dashboard
app.py - FastAPI application → Dashboard template: renders
app.py - FastAPI application → Metrics reader: reads metrics
app.py - FastAPI application → Upload endpoint: registers
app.py - FastAPI application → Chat endpoint: registers
app.py - FastAPI application → PostgreSQL connection: initializes database
app.py - FastAPI application → Metrics table setup: creates tables
app.py - FastAPI application → Search index setup: creates index
app.py - Alternate API entry → Dashboard API routes: registers
main.py - Alternate API entry → Health routes: registers
main.py - Investor / uploader → Upload endpoint: uploads report
routes/ingestion.py - Upload endpoint → Document orchestrator: invokes
routes/ingestion.py - Document orchestrator → PDF conversion: converts PDF
ingestion/ingest_documents.py - Document orchestrator → Semantic chunking: chunks Markdown
ingestion/ingest_documents.py - Document orchestrator → Search vector store: uploads chunks
ingestion/ingest_documents.py - Document orchestrator → KPI extraction RAG: extracts metrics
ingestion/ingest_documents.py - Document orchestrator → KPI persistence: persists metrics
ingestion/ingest_documents.py - Document orchestrator → Azure OpenAI service: creates embeddings
ingestion/ingest_documents.py - Search vector store → Azure AI Search: uploads and searches
vectorstore/azure_ai_search.py - Search index setup → Azure AI Search: configures index
vectorstore/create_index.py - KPI extraction RAG → Search vector store: retrieves context
rag/kpi_extractor_rag.py - KPI extraction RAG → Azure OpenAI client: requests structured output
rag/kpi_extractor_rag.py - Azure OpenAI client → Azure OpenAI service: completes prompt
llm/azure_openai.py - Investor / uploader → Chat endpoint: asks question
routes/chat.py - Chat endpoint → Search vector store: retrieves context
routes/chat.py - Chat endpoint → Azure OpenAI client: gets client
routes/chat.py - Chat endpoint → Azure OpenAI service: requests answer
routes/chat.py - KPI persistence → PostgreSQL connection: writes KPIs
database/save_metrics.py - Metrics reader → PostgreSQL connection: queries metrics
database/metrics.py - Metrics table setup → PostgreSQL connection: uses connection
database/create_table.py - PostgreSQL connection → PostgreSQL database: connects
database/postgres_sql.py - Dashboard API routes → PostgreSQL connection: queries metrics
routes/dashboard.py - Investor / uploader → Dashboard API routes: requests dashboard data