This is an institutional-style portfolio intelligence MVP inspired by BlackRock's investment workflows. It fetches live market data, identifies macroeconomic regimes, generates AI-powered investment recommendations via the Groq LLM API, and persists all historical intelligence to MongoDB for change-tracking and comparative analysis.
The platform follows a clean service-oriented architecture:
- Market Agent: Fetches live pricing, market cap, and calculates volatility using
yfinance. - Macro Agent: Provides macroeconomic data (inflation, interest rates, GDP growth).
- Regime Service: Detects market regimes based on macroeconomic conditions.
- Portfolio Agent: Aggregates and analyzes multi-asset portfolios for sector exposure and concentration risks.
- Committee Agent: Leverages a specified Groq LLM (e.g., Llama 3.3) to formulate structured, qualitative investment recommendations.
- Comparison Service: A historical intelligence engine that tracks rating, confidence, and regime changes over time.
- MongoDB Service: Persists every analysis securely to MongoDB Atlas or a local instance, enabling historical memory.
- Python 3.9+
- A valid Groq API Key
- A MongoDB Atlas cluster (or local MongoDB running on port 27017)
-
Create a Virtual Environment
python -m venv venv source venv/bin/activate -
Install Dependencies
pip install -r backend/requirements.txt
-
Configure Environment Variables Create a
.envfile in the root directory (you can copy.env.example) and add your Groq API key and MongoDB URI:GROQ_API_KEY=your_groq_api_key_here MONGODB_URI=mongodb+srv://<user>:<password>@cluster.mongodb.net/
-
Run the Application Start the FastAPI development server:
uvicorn backend.main:app --reload
The API will be accessible at
http://localhost:8000. You can access the interactive Swagger UI athttp://localhost:8000/docs.
POST /analyze: Generates a complete market, macro, and AI committee analysis for a single ticker (e.g.,RELIANCE.NS).POST /analyze-portfolio: Generates an aggregated analysis for a multi-asset portfolio, including sector exposure and concentration risk.
Every time an analysis is generated, it is persisted to MongoDB along with a tracked comparison against its previous run.
GET /history/stocks: Retrieves the most recent stock analyses.GET /history/stocks/{ticker}: Retrieves the entire timeline of analyses for a specific asset.GET /history/stocks/{ticker}/latest: Retrieves the absolute latest analysis for a specific asset.GET /history/portfolios: Retrieves the history of portfolio analyses.GET /history/portfolios/latest: Retrieves the absolute latest portfolio run.
The repository includes several bash scripts to quickly validate the platform without needing a frontend:
test_api.sh: Spins up the server and tests the single-asset/analyzeendpoint.test_portfolio_api.sh: Spins up the server and tests the multi-asset/analyze-portfolioendpoint.test_script.py: Tests the underlying Python agents directly without the web server.test_models.py: Pings the Groq API to list available LLMs.