feat(web): v0.1 UI — calendar heatmap, day detail, trade detail#5
Merged
SwathiMystery merged 3 commits intomainfrom Apr 21, 2026
Merged
feat(web): v0.1 UI — calendar heatmap, day detail, trade detail#5SwathiMystery merged 3 commits intomainfrom
SwathiMystery merged 3 commits intomainfrom
Conversation
Adds the first web UI for khata: FastAPI + Jinja2 + HTMX, zero JS
framework, single stylesheet, dark-mode via prefers-color-scheme.
Pages
- GET / → redirect to current month calendar
- GET /calendar/{year}/{month} → month grid, P&L-coloured days,
Tue/Thu expiry markers, prev/next nav
- GET /day/{YYYY-MM-DD} → day header, summary strip, trade
table, inline daily reflection
- GET /trade/{id} → trade meta, executions/fills, tag
chips with add/remove, note editor
HTMX partials (no client JS)
- POST /notes/trade/{id} → save trade note on blur
- POST /notes/day/{YYYY-MM-DD} → save daily note on blur
- POST /tags/trade/{id} → add tag (kind: psych/setup/mistake/custom)
- DELETE /tags/trade/{id}/{tag} → remove tag
CLI
- khata web [--host 127.0.0.1] [--port 8000] [--reload/--no-reload]
Defaults to localhost-only and reload-on for dev.
Tests
- 12 new smoke tests via FastAPI TestClient covering every route, HTMX
round-trip, and edge cases (invalid date, missing trade, empty day).
34/34 green overall.
Notes
- Schema untouched; only new reads on existing tables.
- HTMX loaded via unpkg CDN; comment in base.html notes vendoring option
for offline installs.
- FastAPI's Depends() in parameter defaults is idiomatic — added per-file
ruff ignore for B008 in khata/web/main.py only.
- `datetime.utcnow()` replaced with timezone-aware equivalent for 3.12+.
Verified against live Dhan data: 103 executions, 18 trades, calendar
heatmap coloured correctly, day view links to trade detail, daily note
save+reload roundtrip, tag add+remove persists.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
First web UI for khata. FastAPI + Jinja2 + HTMX. No client JS framework. Single stylesheet with dark mode via
prefers-color-scheme. Logo-matched amber/indigo palette.Pages
GET /GET /calendar/{year}/{month}GET /day/{YYYY-MM-DD}GET /trade/{id}HTMX partials
POST /notes/trade/{id}POST /notes/day/{YYYY-MM-DD}POST /tags/trade/{id}DELETE /tags/trade/{id}/{tag}CLI
Tests
12 new smoke tests via
fastapi.testclient.TestClient. Covers every route, every HTMX round-trip, and edge cases (invalid date, missing trade, empty day). Full suite: 34/34 green.Notes
trades,executions,trade_legs,notes,tags,trade_tags).Depends()idiom trips ruff's B008 on import-time function calls. Added a per-file ignore only forkhata/web/main.py— doesn't affect the rest of the codebase.datetime.utcnow()replaced with timezone-aware equivalent for Python 3.12+ deprecation.Verification
Ran against a live Dhan account (103 executions, 18 trades from my real sync):
Checklist
uv run ruff check khata testsclean (with scoped B008 allowance)uv run ruff format khata testsapplied