How kotianprakash/ai-portfolio-analytics works
This is a FastAPI investor-intelligence backend. Its main user-to-result workflow accepts an annual-report PDF, converts it to Markdown, chunks it, indexes it in Azure AI Search, extracts financial KPIs with Azure OpenAI, and stores those KPIs in PostgreSQL; users can also query indexed reports through RAG chat and view stored metrics in a dashboard. The graph includes the separately defined dashboard/health API as well. Edges reflect the shown calls or README capabilities; some UI and service details are documented but not implemented in the sampled excerpts.
Main entry points: app.py FastAPI App · ingest_documents.py Ingestion Orchestrator · postgres_sql.py PostgreSQL Access · chat.py Chat Route
Components 22
API and Dashboard
- FastAPI App
app.py - Dashboard API
main.py - Upload Route
routes/ingestion.py - Chat Route
routes/chat.py - Dashboard Route
routes/dashboard.py - Health Route
routes/health.py - Dashboard UI
templates/dashboard.html
Report Ingestion
- Ingestion Orchestrator
ingestion/ingest_documents.py - PDF Converter
ingestion/pdf_to_markdown.py - Semantic Chunker
ingestion/semantic_chunker.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 - OpenAI Client
llm/azure_openai.py
Persistence
- Metrics Query
database/metrics.py - Metric Persistence
database/save_metrics.py - Table Setup
database/create_table.py - PostgreSQL Access
database/postgres_sql.py
Other components
- Investor
- Azure AI Search
- Azure OpenAI
- PostgreSQL
Connections 31
- Investor → Upload Route: uploads PDF
routes/ingestion.py - FastAPI App → Upload Route: registers route
app.py - Upload Route → Ingestion Orchestrator: ingests document
routes/ingestion.py - Ingestion Orchestrator → PDF Converter: converts PDF
ingestion/ingest_documents.py - Ingestion Orchestrator → Semantic Chunker: chunks Markdown
ingestion/ingest_documents.py - Ingestion Orchestrator → Search Vector Store: uploads chunks
ingestion/ingest_documents.py - Search Vector Store → Azure AI Search: indexes and searches
vectorstore/azure_ai_search.py - FastAPI App → Search Index Setup: creates index
app.py - Search Index Setup → Azure AI Search: configures index
vectorstore/create_index.py - Ingestion Orchestrator → KPI Extraction RAG: extracts KPIs
ingestion/ingest_documents.py - KPI Extraction RAG → Search Vector Store: retrieves context
rag/kpi_extractor_rag.py - KPI Extraction RAG → OpenAI Client: requests structured output
rag/kpi_extractor_rag.py - OpenAI Client → Azure OpenAI: calls model
llm/azure_openai.py - Ingestion Orchestrator → Metric Persistence: persists extracted KPIs
ingestion/ingest_documents.py - Metric Persistence → PostgreSQL Access: writes metrics
database/save_metrics.py - PostgreSQL Access → PostgreSQL: connects to
database/postgres_sql.py - Investor → Chat Route: asks question
routes/chat.py - FastAPI App → Chat Route: registers route
app.py - Chat Route → Search Vector Store: retrieves report context
routes/chat.py - Chat Route → OpenAI Client: gets model client
routes/chat.py - Investor → Dashboard UI: views metrics
README.md - FastAPI App → Dashboard UI: renders dashboard
app.py - FastAPI App → Metrics Query: loads metrics
app.py - Metrics Query → PostgreSQL Access: queries database
database/metrics.py - Investor → Dashboard API: requests API
main.py - Dashboard API → Dashboard Route: registers route
main.py - Dashboard API → Health Route: registers route
main.py - Dashboard Route → PostgreSQL Access: reads metrics
routes/dashboard.py - FastAPI App → PostgreSQL Access: creates database
app.py - FastAPI App → Table Setup: creates tables
app.py - Table Setup → PostgreSQL Access: uses database access
database/create_table.py