backend/
main.py ← FastAPI routes (one entry point for all 3 tools)
models.py ← All Pydantic models for all 3 tools
requirements.txt ← All Python dependencies
render.yaml ← Free deployment on Render.com
core/
utils.py ← Shared helpers: price fetch, date parse, XIRR, tax calc
tools/
capgains.py ← Tool 3: Capital Gains (LIVE — dad's exact code)
backtest.py ← Tool 2: Backtest + XIRR (placeholder)
momentum.py ← Tool 1: Momentum Strategy (placeholder)
jobs/
store.py ← In-memory job queue (swap to Redis when scaling)
python -m venv venv
source venv/bin/activate # Mac/Linux
venv\Scripts\activate # Windows
pip install -r requirements.txt
uvicorn main:app --reload --port 8000Open http://localhost:8000/docs for interactive API docs.
Set frontend .env:
VITE_API_URL=http://localhost:8000
- Push backend/ folder to GitHub
- render.com → New Web Service → connect repo
- Build:
pip install -r requirements.txt - Start:
uvicorn main:app --host 0.0.0.0 --port $PORT - Get URL → update frontend VITE_API_URL
When dad updates the capital gains cell in Colab:
- Open
tools/capgains.py - Find the section marked
# ── FIFO Logic ── - Replace with dad's new logic
- Only strip these Colab lines:
# REMOVE: from google.colab import auth, userdata auth.authenticate_user() gc = gspread.authorize(creds) spreadsheet = gc.open_by_url(...) ws.update(...) / write_sheet(...)
- Keep ALL calculation logic exactly as-is
- Restart the server — done
When ready to build Tool 2:
- Open tools/backtest.py — instructions are at the top
- Copy the backtest cell from Colab
- Strip the Colab/gspread parts
- Replace
raise NotImplementedErrorwith the real logic - Update main.py
/api/backtest/runto call it
Same process. Instructions at top of tools/momentum.py.
| Method | URL | Tool | Status |
|---|---|---|---|
| GET | /api/health | — | ✅ Live |
| GET | /api/price | — | ✅ Live |
| POST | /api/capgains/run | Tool 3 | ✅ Live |
| GET | /api/capgains/job/:id | Tool 3 | ✅ Live |
| GET | /api/capgains/export/:id | Tool 3 | ✅ Live |
| POST | /api/backtest/run | Tool 2 | 🔜 Soon |
| POST | /api/momentum/run | Tool 1 | 🔜 Soon |