How chinmayshastry/ai-finance-research-assistant works
1. Project shape
- This is a single-page Streamlit application with a small, modular backend. app.py is the entrypoint and likely owns the UI state, user interaction, and orchestration of the analysis pipeline.
2. Primary runtime boundary
- The application runs as a local/hosted Streamlit app in Python. The repo is not split into separate services; instead, it is organized into feature modules under modules/ plus asset lists under data/.
3. User-facing flow
- The user selects an Indian stock or commodity in the Streamlit UI, then the app pulls market history and recent news, runs LLM-based analysis, and renders charts plus generated research sections back into the dashboard.
4. Market data subsystem
- modules/market_data.py is the market price layer. Based on the README, it likely retrieves historical price and volume data from Yahoo Finance and prepares time-series outputs for multiple horizons and charting.
5. News aggregation subsystem
- modules/news_fetcher.py is responsible for collecting headlines and article metadata from the external news sources mentioned in the README: NewsAPI and Google News RSS. This is the raw textual input for downstream analysis.
6. LLM analysis subsystem
- modules/sentiment_analyzer.py uses OpenAI models to summarize news sentiment over time windows such as 7, 30, and 90 days. This is where raw headlines become structured bullish/bearish/neutral assessments and key drivers.
7. Research report generation
- modules/report_generator.py appears to synthesize the longer-form investment research output: recent price trends, probable reasons for movement, macro/sector context, future catalysts, and risks. This is distinct from simple sentiment scoring and is the main “report” product of the app.
8. Shared utilities
- modules/utils.py is the common helper layer. In a repo like this it typically centralizes formatting, date handling, caching, string cleanup, and reusable transformations so the feature modules stay focused.
9. Asset universe / reference data
- data/nifty250.py and data/commodities.py define the supported instruments. These files act as the app’s asset registry, letting the UI offer predefined Indian equities and commodity symbols instead of free-form lookup only.
10. Configuration and secrets boundary
- config.py likely manages environment-backed settings such as OPENAI_API_KEY and NEWS_API_KEY, plus app constants. This is the boundary between code and deployment-specific credentials.
11. End-to-end data flow
- The flow is: user input in Streamlit → asset lookup from data/ → price retrieval from Yahoo Finance via market_data → news collection via news_fetcher → synthesis via OpenAI in sentiment_analyzer and report_generator → rendered charts, summaries, and risk/catalyst sections in the UI.
12. External dependencies that matter architecturally
- The app depends on three external integration points that shape the architecture: Yahoo Finance for market data, NewsAPI/Google News RSS for news intake, and OpenAI for generative analysis. These are the core system boundaries and failure points.
13. Presentation and visualization layer
- Streamlit is the only frontend framework in the repo, while Plotly and Pandas likely handle charting and tabular data preparation. The UI is therefore tightly coupled to the analysis pipeline rather than to a separate backend API.
14. Development/deployment packaging
- .devcontainer/ indicates a containerized development environment, which helps standardize Python dependencies and runtime setup. requirements.txt defines the Python stack used by the Streamlit app and its analysis modules.
15. What to show in an architecture diagram
- A useful diagram would show one top-level Streamlit app, three downstream data/AI subsystems (market data, news ingestion, LLM analysis/reporting), shared config/utils, and the supported asset catalogs feeding the selection step. The main outputs are dashboards, charts, sentiment summaries, long-term reports, and risk/catalyst insights.
Main entry points: app.py Streamlit App · utils.py Shared Utils · news_fetcher.py News Fetcher · market_data.py Market Data
Components 17
Runtime
Streamlit app entrypoint and user-facing orchestration
- Streamlit App · Main UI, state, and end-to-end orchestration
app.py
Modules
Core analysis and data-processing subsystems
- Market Data · Fetches and prepares historical price/volume data
modules/market_data.py - News Fetcher · Collects headlines and article metadata from external sources
modules/news_fetcher.py - Sentiment Analyzer · Summarizes news into bullish/bearish/neutral signals and drivers
modules/sentiment_analyzer.py - Report Generator · Builds longer-form investment research and risk/catalyst sections
modules/report_generator.py - Shared Utils · Common formatting, cleanup, caching, and transformation helpers
modules/utils.py
Reference Data
Supported instruments for selection in the UI
- Nifty 250 · Predefined Indian stock universe for selection
data/nifty250.py - Commodities · Predefined commodity symbols for selection
data/commodities.py
External Systems
Third-party data and AI dependencies
- Streamlit · Interactive single-page dashboard runtime
- Yahoo Finance · External source for historical market data
- NewsAPI · External news source used for headline collection
- Google News RSS · RSS-based news intake source
- OpenAI · Generative analysis backend for summarization and report drafting
Dev & Config
Environment, secrets, and local setup
- Config · Environment-backed settings and app constants
config.py - README · Usage and integration notes for the application
README.md - Requirements · Pinned Python dependencies for the app and modules
requirements.txt - Dev Container · Containerized local development environment
.devcontainer/devcontainer.json
Connections 23
- Streamlit App → Nifty 250: asset list · Loads supported stocks for the selector
- Streamlit App → Commodities: asset list · Loads supported commodities for the selector
- Streamlit App → Market Data: prices · Requests historical market data for the selected instrument
- Streamlit App → News Fetcher: news · Requests recent headlines and article metadata
- Streamlit App → Sentiment Analyzer: analysis · Triggers LLM-based sentiment synthesis
- Streamlit App → Report Generator: report · Triggers long-form research generation
- Streamlit App → Streamlit: ui · Runs the interactive dashboard in Streamlit
- Market Data → Yahoo Finance: fetch · Retrieves historical prices and volume
- News Fetcher → NewsAPI: fetch · Pulls news from NewsAPI when available
- News Fetcher → Google News RSS: fetch · Collects headlines from Google News RSS
- Sentiment Analyzer → OpenAI: summarize · Uses OpenAI models to classify and summarize sentiment
- Report Generator → OpenAI: draft · Uses OpenAI models to synthesize the research report
- Streamlit App → Shared Utils: helpers · Shares formatting and transformation utilities
- Market Data → Shared Utils: helpers · Uses common data preparation helpers
- News Fetcher → Shared Utils: helpers · Uses common text cleanup and parsing helpers
- Sentiment Analyzer → Shared Utils: helpers · Uses shared normalization and aggregation helpers
- Report Generator → Shared Utils: helpers · Uses shared formatting and synthesis helpers
- Config → OpenAI: api key · Provides OpenAI credentials
- Config → NewsAPI: api key · Provides NewsAPI credentials
- Streamlit App → Config: settings · Reads runtime configuration and secrets
- Streamlit App → Requirements: deps · Runs against the declared Python dependency set
- Dev Container → Requirements: env · Uses the repository dependency stack in development
- README → Streamlit App: docs · Documents the main application workflow