You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
KUBERA is an intelligent stock analysis chatbot specialized in Indian markets (NSE/BSE). Built with FastAPI, PostgreSQL, and OpenRouter (supporting multiple LLMs including Llama 3.3, Claude, GPT-4), it provides comprehensive stock analysis through AI-powered conversations.
π Live Deployment
The application is fully deployed and available online:
Backend API: https://kubera007.duckdns.org | WebSocket: wss://kubera007.duckdns.org (Running on AWS EC2 t3.micro using Docker containerization. Mapped to EC2 IP 54.206.176.208 using DuckDNS to support secure HTTPS/WSS connections for Vercel compatibility).
git clone https://github.com/yourusername/kubera-backend.git
cd kubera-backend
2. Create Virtual Environment
# Using venv
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate# OR using uv (recommended)
uv venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
3. Install Dependencies
# Using pip
pip install --upgrade pip
pip install -r requirements.txt
# OR using uv
uv pip install -r requirements.txt
POST /auth/register/step1 # Step 1: Send OTP to emailPOST /auth/register/step2 # Step 2: Verify OTPPOST /auth/register/step3 # Step 3: Complete registrationPOST /auth/login # Login with username and passwordPOST /auth/refresh # Refresh access tokenPOST /auth/logout # Logout userGET /auth/check-username/{username} # Check username availabilityPOST /auth/password-reset/send-otp # Send OTP for password resetPOST /auth/password-reset/confirm # Confirm password reset with OTPPOST /auth/forgot-password/send-otp # Send forgot password OTPPOST /auth/forgot-password/confirm # Reset password with OTP
User Endpoints (7)
GET /user/profile # Get user profilePUT /user/profile # Update user profilePUT /user/username # Update usernamePUT /user/password # Update passwordGET /user/email-preferences # Get email preferencesPUT /user/email-preferences # Update email preferencesGET /user/stats # Get user statistics
Portfolio Endpoints (5)
GET /portfolio/ # Get user portfolioPOST /portfolio/ # Add portfolio entryPUT /portfolio/{portfolio_id} # Update portfolio entryDELETE /portfolio/{portfolio_id} # Delete portfolio entryPOST /portfolio/update-prices # Update portfolio prices
Chat Endpoints (5)
GET /chats/ # Get all chatsPOST /chats/ # Create new chatGET /chats/{chat_id} # Get chat with messagesDELETE /chats/{chat_id} # Delete chatPUT /chats/{chat_id}/rename # Rename chat
Admin Endpoints (22)
POST /admin/login/send-otp # Admin login - Send OTPPOST /admin/login/verify-otp # Admin login - Verify OTPGET /admin/dashboard # Get dashboard statisticsGET /admin/dashboard/prompt-activity # Get prompt activity time-seriesGET /admin/users # Get all usersGET /admin/users/{user_id} # Get user detailsPUT /admin/users/{user_id}/deactivate # Deactivate userPUT /admin/users/{user_id}/reactivate # Reactivate userGET /admin/rate-limits/config # Get rate limit configurationPUT /admin/rate-limits/global # Update global rate limitsPUT /admin/rate-limits/user/{user_id} # Set user-specific rate limitsPOST /admin/rate-limits/whitelist # Add user to whitelistDELETE /admin/rate-limits/whitelist/{user_id} # Remove user from whitelistPOST /admin/rate-limits/reset/{user_id} # Reset user rate limit countersGET /admin/rate-limits/violations # Get rate limit violationsGET /admin/portfolio-reports/settings # Get portfolio report settingsPUT /admin/portfolio-reports/settings # Update portfolio report settingsPOST /admin/system/control # System control (start/stop)GET /admin/activity-logs # Get admin activity logs# Super Admin only (role: super_admin)GET /admin/admins # List all adminsPUT /admin/admins/{admin_id}/deactivate # Deactivate an adminPUT /admin/admins/{admin_id}/reactivate # Reactivate an admin
Root Endpoints (4)
GET / # API RootGET /health # Health CheckGET /mcp/tools # List MCP ToolsGET /scheduler/status # Scheduler Status
WebSocket (1)
WS /ws/chat?token={jwt_token} # Real-time chat
MCP Servers
KUBERA uses 5 specialized MCP servers with 45 tools total:
Server 1: Financial Data (fin_data.py) - 7 Tools
Tool
Description
fetch_company_fundamentals
Core fundamental metrics
fetch_historical_financials
Historical financial data
fetch_balance_sheet_data
Balance sheet components
fetch_cash_flow_data
Cash flow statement
fetch_dividend_history
Dividend data & sustainability
fetch_eps_analysis
EPS trends & analysis
validate_stock_symbol
Symbol validation
Server 2: Market & Technical (market_tech.py) - 9 Tools
Tool
Description
fetch_current_price_data
Real-time price data
fetch_historical_price_data
OHLCV historical data
fetch_technical_indicators
SMA, RSI, MACD, BBands
fetch_volume_analysis
Volume trends
fetch_volatility_metrics
Beta, drawdown, Sharpe
fetch_comparative_performance
Performance comparison
fetch_institutional_holding_data
FII/DII holdings
fetch_liquidity_metrics
Trading liquidity
validate_technical_data
Data quality check
Server 3: Governance & Compliance (gov_compliance.py) - 8 Tools
Tool
Description
fetch_promoter_holding_data
Promoter & pledging info
fetch_board_composition
Board structure
fetch_audit_quality
Auditor information
fetch_regulatory_compliance
Regulatory status
fetch_shareholding_pattern
Complete shareholding
fetch_related_party_transactions
Related party deals
fetch_governance_score
Governance quality score
fetch_insider_transactions
Insider trading patterns
Server 4: News & Sentiment (news_sent.py) - 10 Tools
Tool
Description
fetch_news_articles
Recent news articles
fetch_overall_news_sentiment
Aggregate sentiment
fetch_analyst_ratings
Analyst recommendations
fetch_social_sentiment
Social media sentiment
fetch_company_announcements
Official announcements
fetch_sector_sentiment
Sector-wide sentiment
fetch_competitor_sentiment
Competitor comparison
fetch_news_impact_analysis
Price impact analysis
fetch_management_commentary
Management guidance
calculate_sentiment_score
Text sentiment scoring
Server 5: Visualization (visualization.py) - 11 Tools
4-Level Fail-Fast System (DB-driven & live-configurable)
All limits are stored in the database and enforced per-prompt via RateLimitService. Changes made in the Admin Panel take effect on the next prompt β no server restart required.
Level
Default
Window
Action
π Burst
10 prompts
1 minute
Block immediately
π¬ Per-Chat
50 prompts
Per chat session
Block prompt
β° Hourly
150 prompts
1 hour
Block for remainder
π Daily
1000 prompts
24 hours
Block for remainder
Admin Controls
β Update limits globally (live, no restart)
β Set per-user overrides (takes priority over global)
β Whitelist users (completely bypass all limits)
β Reset individual user counters
β View violation logs with user info and timestamp
Email Notifications
15+ Email Types
Category
Templates
π OTP Emails
Registration, Password Reset, Admin Login
π€ Account Emails
Welcome, Password Changed, Account Deactivated
β‘ Rate Limit Emails
Burst/Hourly/Daily Limit Exceeded
π Portfolio Emails
Daily/Weekly/Monthly Reports
π System Emails
Maintenance, Security Alerts
Docker Deployment
Quick Start
# Build and run
docker-compose up -d
# View logs
docker-compose logs -f backend
# Stop
docker-compose down
Services
Service
Port
Description
backend
8000
FastAPI application
postgres
5432
PostgreSQL database
redis
6379
Redis cache (optional)
pgadmin
5050
Database management
Production Deployment
# Build production image
docker build -t kubera-backend:latest .# Run with environment file
docker run -d \
--name kubera-backend \
--env-file .env \
-p 8000:8000 \
kubera-backend:latest
Development
Code Style
# Format code
black app/ mcp_servers/ scripts/
# Sort imports
isort app/ mcp_servers/ scripts/
# Lint
flake8 app/ mcp_servers/ scripts/
# Type checking
mypy app/
Database Migrations
# Create migration
python scripts/run_migrations.py create "description"# Apply migrations
python scripts/run_migrations.py migrate
# Check status
python scripts/run_migrations.py status
Troubleshooting
Common Issues
MCP Client Not Initializing
# Check if all required API keys are setecho$OPENROUTER_API_KEY# Verify MCP server files exist
ls mcp_servers/