A sophisticated FastAPI-based web application that provides real-time stock news analysis and portfolio alerts using AI/LLM integration.
- 🔐 Secure Authentication - JWT-based user authentication
- 🔗 Zerodha Integration - Connect your Kite portfolio via MCP
- 📰 Smart News Aggregation - Fetch relevant news using GNews API
- 🧠 AI-Powered Analysis - LLM-based sentiment and impact analysis via Groq
- ⚡ Real-time Processing - Pathway streaming for live news monitoring
- 📬 Multi-channel Notifications - Email, Telegram, and WhatsApp alerts
- 📊 Portfolio Management - Track your stocks and their performance
- ⚙️ Customizable Settings - Configure notification preferences and thresholds
- Backend: FastAPI with async/await
- Streaming: Pathway for real-time data processing
- AI/LLM: Groq API for news impact analysis
- Database: Airtable for data storage
- Authentication: JWT with bcrypt password hashing
- News API: GNews.io for financial news
- Broker Integration: Zerodha Kite Connect API
- Notifications: SMTP (email) and Telegram Bot API
- Python 3.8+
- Virtual environment (recommended)
- API keys for required services (see Configuration section)
- Clone and setup the project:
cd /Users/anveshmishra/Developer/Vibeathon
python -m venv venv
source venv/bin/activate # On macOS/Linux
pip install -r requirements.txt- Configure environment variables:
cp .env.example .env
# Edit .env with your API keys and configuration- Run the test suite:
python test_setup.py- Start the application:
python main.pyThe application will be available at http://localhost:8000
Create accounts and obtain API keys for the following services:
- Sign up at Kite Connect
- Create an app to get API key and secret
- Add to
.env:KITE_API_KEY=your-kite-api-key KITE_API_SECRET=your-kite-api-secret
- Register at GNews.io
- Get your free API key
- Add to
.env:GNEWS_API_KEY=your-gnews-api-key
- Sign up at Groq
- Get your API key for LLM access
- Add to
.env:GROQ_API_KEY=your-groq-api-key
- Create account at Airtable
- Create a base with tables: Users, Portfolios, NewsAlerts, Settings
- Generate a personal access token (API keys are deprecated)
- Add to
.env:AIRTABLE_BASE_ID=your-airtable-base-id AIRTABLE_ACCESS_TOKEN=your-airtable-access-token
For email notifications:
SMTP_SERVER=smtp.gmail.com
SMTP_PORT=587
SMTP_USERNAME=your-email@gmail.com
SMTP_PASSWORD=your-app-password
- Create a bot via @BotFather
- Add to
.env:TELEGRAM_BOT_TOKEN=your-telegram-bot-token
Complete .env configuration:
# JWT Settings
# Environment Variables
JWT_SECRET_KEY=your-super-secret-jwt-key-change-this-in-production
ALGORITHM=HS256
ACCESS_TOKEN_EXPIRE_MINUTES=30
# Zerodha MCP Server
ZERODHA_MCP_SERVER_URL=https://mcp.kite.trade/sse
# API Keys
GNEWS_API_KEY=your-gnews-api-key
GROQ_API_KEY=your-groq-api-key
AIRTABLE_BASE_ID=your-airtable-base-id
AIRTABLE_ACCESS_TOKEN=your-airtable-access-token
# Email Configuration
SMTP_SERVER=smtp.gmail.com
SMTP_PORT=587
SMTP_USERNAME=your-email@gmail.com
SMTP_PASSWORD=your-app-password
# Telegram
TELEGRAM_BOT_TOKEN=your-telegram-bot-token
# Application
DEBUG=True
HOST=0.0.0.0
PORT=8000POST /register- Register new userPOST /token- Login and get access tokenGET /users/me- Get current user profile
GET /kite/login-url- Get Kite Connect login URLPOST /kite/connect- Connect Kite accountGET /portfolio- Get user portfolioPOST /portfolio/refresh- Refresh portfolio data
GET /news- Get news for portfolio stocksGET /news/analyze- Analyze news impact on portfolioGET /alerts- Get user's news alerts
GET /settings- Get notification settingsPOST /settings- Update notification settings
POST /test/notification- Send test notificationGET /health- Health check endpointGET /- Home pageGET /docs- Interactive API documentation
-
Registration & Authentication
- Register account via
/register - Login to get JWT token via
/token
- Register account via
-
Connect Zerodha Account
- Get Kite login URL via
/kite/login-url - Complete Kite OAuth flow
- Connect account via
/kite/connect
- Get Kite login URL via
-
Portfolio Setup
- Fetch portfolio via
/portfolio - System automatically monitors your stocks
- Fetch portfolio via
-
News Monitoring
- Pathway service continuously fetches news
- LLM analyzes impact on your stocks
- Notifications sent based on your preferences
-
Manage Settings
- Configure notification methods
- Set impact thresholds
- Exclude specific stocks
Run the comprehensive test suite:
python test_setup.pyThis will test:
- Module imports
- Service initialization
- FastAPI app setup
- Configuration validation
- Model creation
python main.py
# or
uvicorn main:app --reload --host 0.0.0.0 --port 8000# Update .env for production
DEBUG=False
JWT_SECRET_KEY=your-very-secure-production-key
# Run with Gunicorn
pip install gunicorn
gunicorn main:app -w 4 -k uvicorn.workers.UvicornWorker --bind 0.0.0.0:8000┌─────────────────┐ ┌──────────────────┐ ┌─────────────────┐
│ FastAPI App │ │ Pathway Stream │ │ External APIs │
│ │ │ │ │ │
│ • Auth Routes │◄──►│ • News Monitor │◄──►│ • GNews API │
│ • Portfolio API │ │ • LLM Analysis │ │ • Groq LLM │
│ • Settings API │ │ • Notifications │ │ • Kite Connect │
└─────────────────┘ └──────────────────┘ └─────────────────┘
│ │ │
▼ ▼ ▼
┌─────────────────┐ ┌──────────────────┐ ┌─────────────────┐
│ Airtable │ │ Notification │ │ Telegram/ │
│ │ │ Services │ │ Email │
│ • Users │ │ │ │ │
│ • Portfolios │ │ • Email SMTP │ │ • Real-time │
│ • Alerts │ │ • Telegram Bot │ │ Delivery │
│ • Settings │ │ • WhatsApp (TBD) │ │ │
└─────────────────┘ └──────────────────┘ └─────────────────┘
- JWT Authentication - Secure token-based auth
- Password Hashing - bcrypt for password security
- Input Validation - Pydantic model validation
- Rate Limiting - Built-in request throttling
- Environment Variables - Secure configuration management
- CORS Protection - Configurable cross-origin requests
Edit news_service.py to add mappings for different exchanges:
def _get_company_names(self, symbol: str) -> List[str]:
symbol_mapping = {
# Add your exchange symbols here
"YOUR_SYMBOL": ["Company Name", "Alternative Name"],
}Modify prompts in llm_service.py for different analysis styles:
def _create_analysis_prompt(self, news_item: NewsItem, user_stocks: List[str]) -> str:
# Customize your analysis prompt hereUpdate notification templates in notifications.py:
# Customize email/telegram message formats
html_body = f"""
<!-- Your custom HTML template -->
"""The application includes comprehensive logging:
- Application logs - FastAPI request/response logs
- Service logs - Individual service operation logs
- Error tracking - Detailed error logging with context
- Performance metrics - Response time monitoring
Check logs in the console output or configure file logging as needed.
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new features
- Submit a pull request
This project is for educational and personal use. Make sure to comply with all API terms of service when using in production.
- Documentation: Visit
/docsendpoint for interactive API docs - Health Check: Use
/healthendpoint to verify system status - Test Notifications: Use
/test/notificationto verify alert delivery
- API Limits: Be aware of rate limits for external APIs
- Market Hours: Consider Indian market hours (9:15 AM - 3:30 PM IST)
- Data Accuracy: News analysis is AI-generated and should not be the sole basis for investment decisions
- Security: Always use HTTPS in production and secure your API keys
- Compliance: Ensure compliance with financial data regulations in your jurisdiction
Happy Trading! 📈