AI-Assisted Trading System for Indian Markets (NSE/BSE)
- AI Trade Analysis — Get trade suggestions with confidence bands, entry/exit levels, and risk plans powered by Google Gemini
- Interactive Charts — Real-time candlestick charts with technical indicators, drawing tools, and multiple timeframes (lightweight-charts v5)
- Market Scanner — Scan Nifty 50 stocks with customizable filters for momentum, volume breakouts, and trend reversals
- Backtesting Engine — Test trading strategies against historical data with detailed P&L reports
- News Sentiment — Aggregated market news with AI sentiment analysis and stock impact indicators
- Market Movers — Live top gainers, losers, and high-volume stocks
| Layer | Technology |
|---|---|
| Frontend | Next.js 14, TypeScript, Tailwind CSS |
| Charts | lightweight-charts v5 (TradingView) |
| Backend | Python 3.11+, FastAPI, async/await |
| AI/LLM | Google Gemini for reasoning & explanations |
| Data Sources | Groww, Angel One, Upstox APIs |
| Cache | Redis |
| Database | SQLAlchemy + SQLite/PostgreSQL |
| Real-time | Server-Sent Events (SSE), WebSocket |
Next.js Frontend (Port 3000)
|
| HTTP/JSON + SSE
v
FastAPI Backend (Port 8000)
├── Data Ingestion (Groww, Angel One, Upstox)
├── Indicator Engine (NumPy/Pandas)
├── LLM Reasoning (Google Gemini)
├── Risk Engine (Deterministic)
├── Market Scanner
├── Backtesting Engine
└── News Sentiment (Google News RSS)
| |
v v
PostgreSQL Redis
- AI suggests, human executes — No auto-trading
- Probabilistic confidence — Ranges, not certainty
- Risk-first approach — Hard limits enforced
- LLM for reasoning only — Never for math
- Node.js 18+
- Python 3.11+
- Redis (optional, for caching)
# Install dependencies
npm install
# Copy environment file
cp .env.example .env.local
# Edit .env.local with your settings
# Start development server
npm run devcd backend
# Create virtual environment
python -m venv venv
source venv/bin/activate # or `venv\Scripts\activate` on Windows
# Install dependencies
pip install -r requirements.txt
# Copy environment file
cp .env.example .env
# Edit .env with your API keys
# Start server
uvicorn app.main:app --reloadThe frontend runs on http://localhost:3000 and the backend on http://localhost:8000.
stockpro/
├── src/ # Next.js Frontend
│ ├── app/
│ │ ├── page.tsx # Home — search, market movers
│ │ ├── analyze/ # AI trade analysis page
│ │ ├── scanner/ # Market scanner page
│ │ ├── backtest/ # Backtesting page
│ │ ├── news/ # News sentiment page
│ │ └── chart/[symbol]/ # Full-screen chart page
│ ├── components/
│ │ ├── AdvancedChart.tsx # Main chart with indicators & drawings
│ │ ├── FullScreenChart.tsx # Full-screen chart with tools
│ │ ├── StockSearch.tsx # Autocomplete stock search
│ │ ├── Recommendations.tsx # Market movers widget
│ │ └── NewsWidget.tsx # Compact news sidebar
│ └── lib/
│ ├── api.ts # Backend API client
│ └── utils/ # Shared utilities
│
├── backend/ # Python FastAPI Backend
│ ├── app/
│ │ ├── main.py # FastAPI app entry
│ │ ├── api/v1/endpoints/ # REST API routes
│ │ │ ├── market.py # Quotes, OHLCV, movers, search
│ │ │ ├── strategy.py # AI trade analysis
│ │ │ ├── indicators.py # Technical indicators
│ │ │ ├── scanner.py # Market scanner
│ │ │ ├── backtest.py # Backtesting
│ │ │ ├── news.py # News & sentiment
│ │ │ ├── stream.py # SSE price streaming
│ │ │ ├── portfolio.py # Portfolio management
│ │ │ └── auth.py # Upstox OAuth
│ │ ├── core/ # Config, settings, database
│ │ ├── schemas/ # Pydantic models (API contracts)
│ │ └── services/ # Business logic
│ │ ├── data_ingestion/ # Multi-source data fetching
│ │ ├── indicators/ # Technical indicator calculations
│ │ ├── llm/ # LLM integration (Gemini)
│ │ ├── risk/ # Risk management engine
│ │ ├── strategy/ # Trade strategy generation
│ │ ├── scanner/ # Market scanning logic
│ │ ├── backtest/ # Backtesting engine
│ │ ├── news/ # News aggregation & sentiment
│ │ ├── cache/ # Redis caching layer
│ │ └── websocket/ # Real-time data manager
│ ├── Dockerfile # Container for deployment
│ └── render.yaml # Render.com blueprint
│
└── vercel.json # Vercel deployment config
| Endpoint | Description |
|---|---|
POST /api/v1/strategy/analyze |
Generate AI trade suggestion with risk plan |
GET /api/v1/market/quote/{symbol} |
Get live stock quote |
GET /api/v1/market/ohlcv/{symbol} |
Get OHLCV candlestick data |
GET /api/v1/market/movers |
Top gainers, losers, high volume |
GET /api/v1/market/search |
Search stocks by symbol/name |
GET /api/v1/indicators/{symbol} |
Calculate technical indicators |
GET /api/v1/scanner/scan |
Run market scanner with filters |
POST /api/v1/backtest/run |
Run backtest on historical data |
GET /api/v1/news/trending |
Get trending market news |
GET /api/v1/news/symbol/{symbol} |
Get news for a specific stock |
GET /api/v1/stream/prices |
SSE stream for live prices |
The frontend is deployed on Vercel. Set the environment variable:
NEXT_PUBLIC_API_URL=https://your-backend.onrender.com/api/v1
The backend is deployed on Render using Docker. Set environment variables:
GEMINI_API_KEY=your_gemini_key
FRONTEND_URL=https://your-app.vercel.app
ALLOWED_ORIGINS=https://your-app.vercel.app
| Variable | Description | Default |
|---|---|---|
NEXT_PUBLIC_API_URL |
Backend API base URL | http://localhost:8000/api/v1 |
| Variable | Description | Required |
|---|---|---|
GEMINI_API_KEY |
Google Gemini API key | Yes |
ANGEL_ONE_API_KEY |
Angel One API key | No |
ANGEL_ONE_CLIENT_ID |
Angel One client ID | No |
UPSTOX_CLIENT_ID |
Upstox OAuth client ID | No |
UPSTOX_CLIENT_SECRET |
Upstox OAuth client secret | No |
REDIS_URL |
Redis connection URL | No |
DATABASE_URL |
Database connection string | No |
FRONTEND_URL |
Frontend URL for CORS | No |
Private — All rights reserved