Inspiration

Every March, millions of Indian stock traders overpay tax — not because they have to, but because tax loss harvesting is complex, confusing, and no tool exists that actually does it intelligently for Indian markets.

I built StockTax Pro to fix that.

What it does

StockTax Pro is an AI-powered tax planning platform for Indian traders. Upload your broker P&L (Zerodha, Upstox, AngelOne) and the app:

  • Calculates your exact STCG/LTCG tax liability
  • Identifies unrealized losses that can legally offset your gains
  • Runs an optimization algorithm to select the minimum stocks to sell
  • Deploys an AI agent that analyzes your harvest plan across 4 dimensions: Risk Radar, Stock Intelligence, Opportunity Scanner, and Harvest Scorecard
  • Generates ITR-ready Schedule 112A exports for tax filing

The AI Agent

The core of StockTax Pro is an agentic AI layer built on GPT-4o-mini. When a user runs "AI Tax Insights", 4 specialized agents fire in parallel:

  1. Harvest Scorecard Agent — grades the plan across Tax Efficiency, Timing, Cost-Benefit, Target Precision, and Future Value
  2. Stock Intelligence Agent — gives per-stock harvest/wait/skip recommendations with sector-aware reasoning
  3. Opportunity Scanner Agent — finds tax-saving opportunities the user is missing (unused LTCG exemption, optimal booking windows)
  4. Risk Radar Agent — identifies wash sale risks, execution risks, and generates a pre-harvest checklist

Each agent receives only the minimal pre-computed data it needs, keeping total token usage under 2,400 per analysis. Results are cached and rendered progressively as each agent resolves.

How I built it

  • Frontend: React + TypeScript + Tailwind CSS + shadcn/ui
  • State: Zustand with cross-page computed selectors
  • Parsing: SheetJS for multi-broker Excel/CSV parsing with dynamic header detection (never hardcoded row numbers)
  • AI: OpenAI GPT-4o-mini via 4 parallel async fetch calls
  • PDF: @react-pdf/renderer for Schedule 112A generation
  • Tax Engine: Custom rule-based engine handling STCG/LTCG offset rules, pre/post July 23 2024 rate splits, grandfathering, and carry-forward loss calculations

Challenges

Multi-broker normalization was the hardest problem. Each broker formats stock names differently ("TATA MOTORS LTD - EQ" vs "TATAMOTORS"), uses different column structures, and some files lack avg buy price entirely. Building a robust dynamic parser that works across all three brokers without hardcoding row positions took significant iteration.

Token efficiency for the AI layer required pre-computing all tax math on the frontend and sending only summarized JSON to GPT — keeping responses specific and fast rather than generic.

What I learned

Indian tax rules are surprisingly nuanced — the STCG/LTCG offset asymmetry, the July 23 2024 rate change mid-year, grandfathering for pre-2018 holdings, and the 8-year carry-forward window all required careful implementation. Building this taught me how to translate complex regulatory rules into reliable software logic.

Built With

  • openai-gpt-4o-mini-(as-i-already-have-but-will-replace-with-gemini-soon)
  • react
  • recharts
  • shadcn/ui
  • sheetjs
  • tailwind-css
  • typescript
  • vite
  • zustand
Share this project:

Updates

Submission history