Rewrite btcprice from Clojure to Python FastAPI

Replace the Clojure Kit application with a Python FastAPI app that
produces identical HTML output. WebSocket proxy, Danish number
formatting, and HTMX integration all preserved.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-13 12:33:03 +01:00
co-authored by Claude Opus 4.6
parent ae676f2b6c
commit c999d831e7
37 changed files with 277 additions and 780 deletions
+7 -35
View File
@@ -1,15 +1,12 @@
# btcprice
Bitcoin price tracker UI — Clojure Kit web application. Serves the HTML/Tailwind UI. Connects to btcdata for live price data via WebSocket.
Bitcoin price tracker UI — Python FastAPI web application. Serves the HTML/Tailwind UI. Connects to btcdata for live price data via WebSocket.
## Build & Development Commands
- `make run` — Start dev server on port 4000
- `make repl` — Start nREPL
- `make test` — Run tests
- `make tailwind` — Watch Tailwind CSS for changes
- `make uberjar` — Build production JAR
- `docker compose up -d` — Start btcprice + btcdata containers
- `make test` — Run tests
## Docker
@@ -22,21 +19,11 @@ Docker runs alongside local dev on different ports:
btcprice's docker-compose includes btcdata via `include: ../btcdata/docker-compose.yml`.
## REPL Commands
```clojure
(dev-prep!) ;; Prepare dev system
(go) ;; Start system
(reset) ;; Reload code & restart
(halt) ;; Stop system
```
## Architecture
- **Framework:** Kit (Integrant-based)
- **Server:** Undertow
- **Routing:** Reitit
- **Templates:** Hiccup + HTMX (WebSocket extension)
- **Framework:** FastAPI
- **Server:** Uvicorn
- **Templates:** Inline HTML strings + HTMX (WebSocket extension)
- **Styling:** Tailwind CSS v4
- **Data backend:** btcdata (separate service at BTCDATA_URL, default http://localhost:4100)
- **No database** — all data comes from btcdata
@@ -44,21 +31,6 @@ btcprice's docker-compose includes btcdata via `include: ../btcdata/docker-compo
## Source Layout
```
src/clj/pmagnus/btcprice/
── core.clj # App entry point
├── config.clj # System config loader
└── web/
├── handler.clj # Ring handler + routes
├── htmx.clj # page/fragment macros
├── controllers/
│ └── health.clj # Health check
├── middleware/
│ ├── core.clj # Base middleware
│ ├── exception.clj # Exception handling
│ └── formats.clj # Content negotiation
└── routes/
├── api.clj # /api routes (JSON)
├── ui.clj # UI routes (HTML + HTMX WebSocket)
├── ws_proxy.clj # WebSocket proxy to btcdata
└── utils.clj # Route utilities
app/
── main.py # FastAPI app: routes, WebSocket proxy, HTML rendering
```