naik123/ai-financial-modeler
1
AI Financial Modeling Platform
An AI-powered platform for generating institutional-grade Excel financial models for Indian stocks. Built with FastAPI, Next.js, and Google Gemini AI.

๐ Features
Core Capabilities
- AI-Powered Industry Classification: Uses Google Gemini AI to classify companies and select appropriate model templates
- Real Excel Formulas: Generated models use linked formulas, not static values - fully editable
- 150+ Indian Stocks: Comprehensive database covering Power, Banking, IT, Pharma, FMCG, Auto, and more
- Raw Data Input: Generate models from your own financial data without scraping
Advanced Financial Modeling
- Three-Statement Model: Income Statement, Balance Sheet, Cash Flow - all linked
- DCF Valuation: WACC calculation, FCFF projections, terminal value, implied share price
- Sensitivity Analysis: WACC vs Terminal Growth, Revenue vs EBITDA Margin tables
- Scenario Analysis: Bear/Base/Bull case projections with IRR calculation
- Dashboard with Charts: Revenue & EBITDA bars, margin trends, net income charts
Industry-Specific Templates
- Power Sector: PLF tracking, fuel costs, tariff analysis
- Banking: NIM analysis, credit costs, CASA ratios
- IT Services: Utilization, billing rates, offshore mix
- Pharmaceuticals: R&D intensity, ANDA filings
- FMCG: Distribution metrics, brand spending
- And more!
๐ Requirements
- Python 3.9+
- Node.js 18+
- Google Gemini API Key (optional, uses templates as fallback)
๐ ๏ธ Installation
Backend Setup
cd backend
# Create virtual environment
python -m venv venv
venv\Scripts\activate # Windows
# source venv/bin/activate # Linux/Mac
# Install dependencies
pip install -r requirements.txt
# Create .env file
copy .env.example .env
# Edit .env and add your GEMINI_API_KEYFrontend Setup
cd frontend
# Install dependencies
npm install๐ Running the Application
Start Backend
cd backend
python main.py
# Server starts at http://127.0.0.1:8000Start Frontend
cd frontend
npm run dev
# App opens at http://localhost:3000๐ก API Endpoints
Company Information
GET /api/company/{symbol}?exchange=NSEReturns company name, sector, market cap, and current price.
Stock Database
GET /api/stocks # All 172 stocks
GET /api/stocks?sector=power # Filter by sector
GET /api/stocks/search/TCS # Search by symbol or name
GET /api/sectors # List all 14 sectorsModel Generation
POST /api/model/generate
{
"symbol": "ADANIPOWER",
"exchange": "NSE",
"forecast_years": 5,
"model_types": ["three_statement", "dcf"]
}Raw Data Model Generation
POST /api/model/generate-raw
{
"company_name": "My Company Ltd",
"industry": "general",
"forecast_years": 5,
"historical_data": {
"income_statement": {
"revenue": 10000,
"ebitda": 2500,
"net_income": 1500
},
"balance_sheet": {
"total_assets": 20000,
"total_liabilities": 8000
}
},
"assumptions": {
"revenue_growth": 0.10,
"ebitda_margin": 0.25,
"tax_rate": 0.25
}
}Job Status
GET /api/job/{job_id}Download Model
GET /api/download/{job_id}๐ Excel Model Structure
Each generated model contains:
๐ญ Supported Sectors (14 Categories)
- Power & Utilities - ADANIPOWER, NTPC, TATAPOWER, POWERGRID...
- Banking - HDFCBANK, ICICIBANK, SBIN, KOTAKBANK...
- IT Services - TCS, INFY, WIPRO, HCLTECH, TECHM...
- Pharmaceuticals - SUNPHARMA, DRREDDY, CIPLA, LUPIN...
- FMCG - HINDUNILVR, ITC, NESTLEIND, BRITANNIA...
- Automobiles - MARUTI, TATAMOTORS, M&M, HEROMOTOCO...
- Metals & Mining - TATASTEEL, HINDALCO, JSWSTEEL, VEDL...
- Oil & Gas - RELIANCE, ONGC, IOC, BPCL...
- Cement - ULTRACEMCO, SHREECEM, ACC, AMBUJACEM...
- Infrastructure - L&T, ADANIENT, ADANIPORTS, GMRINFRA...
- NBFC - BAJFINANCE, BAJAJFINSV, SBICARD, MUTHOOTFIN...
- Telecom - BHARTIARTL, IDEA...
- Chemicals - PIDILITIND, UPL, CLEAN...
- Consumer Durables - TITAN, HAVELLS, VOLTAS, CROMPTON...
๐จ Frontend Features
- Modern Dark Theme: Glassmorphism effects, gradient accents
- Stock Browser: Search, filter by sector, click to select
- Raw Data Input: Enter your own financial data and assumptions
- Real-time Progress: Live status updates during generation
- Model Preview: See included features before downloading
๐ง Configuration
Environment Variables
# Required for AI features (optional - falls back to templates)
GEMINI_API_KEY=your_gemini_api_key
# Optional
ALPHA_VANTAGE_API_KEY=your_alpha_vantage_keyModel Assumptions (Editable in Excel)
The Assumptions sheet contains named ranges for:
- Revenue Growth Rate
- EBITDA Margin
- Depreciation % of Revenue
- Tax Rate
- Working Capital Days
- CapEx % of Revenue
- WACC, Risk-Free Rate, Equity Risk Premium
- Terminal Growth Rate
- And more...
๐ Project Structure
ai-financial-modeler/
โโโ backend/
โ โโโ main.py # FastAPI server
โ โโโ requirements.txt # Python dependencies
โ โโโ data/
โ โ โโโ yahoo_finance.py # Yahoo Finance data collector
โ โ โโโ screener_scraper.py # Screener.in scraper
โ โ โโโ stock_database.py # 172 Indian stocks database
โ โโโ agents/
โ โ โโโ industry_classifier.py # AI industry classification
โ โ โโโ financial_modeler.py # Model structure design
โ โ โโโ qa_validator.py # Model validation
โ โโโ excel/
โ โ โโโ generator.py # Excel model generator
โ โโโ output/ # Generated Excel files
โโโ frontend/
โโโ app/
โ โโโ page.tsx # Main page with stock selection
โ โโโ layout.tsx # Root layout
โ โโโ globals.css # Dark theme styles
โโโ package.json
โโโ tailwind.config.js # Custom theme config๐ค Contributing
Pull requests are welcome! Please ensure:
- Code follows existing style patterns
- New features include appropriate tests
- Documentation is updated
๐ License
MIT License - see LICENSE file for details.
๐ Acknowledgments
- Yahoo Finance for financial data
- Screener.in for detailed Indian stock data
- Google Gemini AI for intelligent classification
- openpyxl for Excel generation
