How divishjindal19/finance_ai_agent works
Project Type and Purpose
• This is a Python-based, single-page financial analysis application built with Streamlit (front-end), a CrewAI multi-agent orchestration layer (back-end), and external services for data & inference. Its purpose is to fetch real-time financial data, run multiple specialized AI agents (via CrewAI) against that data using an LLM (Llama 4 on SambaNova hardware), and present consolidated insights in a web UI.
File-Structure Analysis
• Top-level files:
• .devcontainer/devcontainer.json – dev environment config
• .env – environment variables for API keys
• README.md – high-level overview & usage
• Core module: multi_agent_financial_analyst/
• financial_analyst.py – Streamlit entrypoint, orchestrates UI ↔ agents
• requirements.txt – Python dependencies (CrewAI, yfinance, llama4, etc.)
• tools/financial_tools.py – utility functions for data fetching & preprocessing
Key Architecture Insights from README
• Multi-agent design using CrewAI
• Real-time data ingestion via YFinance
• LLM inference (Llama 4) accelerated on SambaNova platform
• Modular design: new agents / tools can be plugged in
Main Components & Their Roles
A. Streamlit UI Layer (financial_analyst.py)
• Renders input forms (tickers, date ranges, analysis options)
• Displays charts and textual insights returned by agents
B. CrewAI Orchestrator
• Manages a set of agents (e.g., Market-Trend Agent, Risk-Analysis Agent, Valuation Agent)
• Dispatches tasks in parallel, aggregates results
C. Agent Modules (inside CrewAI framework)
• Each agent encapsulates a role: fetch data, run analysis via LLM, post-process
• They import shared utilities from tools/financial_tools.py
D. Financial Tools Library
• Data fetchers (YFinance API wrappers)
• Data normalization, feature extraction functions
E. External Services
1. YFinance REST API – real-time & historical financial data
2. SambaNova LLM Inference Endpoint – hosts Llama 4 model
Interactions & Data Flow
1. End-user interacts with Streamlit UI → selects tickers & options.
2. UI invokes CrewAI orchestrator API → spawns multiple agents.
3. Agents call Financial Tools → fetch raw data from YFinance.
4. Agents send prompts & data to Llama 4 inference endpoint on SambaNova.
5. LLM returns analysis snippets → agents post-process & return.
6. Orchestrator aggregates agent outputs → returns final result to UI.
7. UI renders charts & narrative summaries.
Architectural Patterns & Principles
• Multi-agent (concurrent workers with distinct roles)
• Modular separation: UI, orchestration, utilities, external services
• Dependency inversion: business logic (agents) depends on abstracted tool interfaces
• Extensibility: new agent modules or tool functions can be dropped into tools/