- WebSocket sends HTML fragments with id="price-display" instead of JSON for direct HTMX OOB swap on the client - Switch from ring-undertow-adapter ws wrapper to raw Undertow WebSocket API (proxy) to fix single-connection limitation - Keep JSON endpoint at /api/price/latest unchanged - Update CLAUDE.md and README.md Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
41 lines
1.2 KiB
Markdown
41 lines
1.2 KiB
Markdown
# btcdata
|
|
|
|
Bitcoin data backend service. Fetches BTC prices from Binance (WebSocket) and Kraken (HTTP polling), stores them in PostgreSQL, and exposes a JSON API with WebSocket for live price streaming.
|
|
|
|
## API
|
|
|
|
| Endpoint | Description |
|
|
|---|---|
|
|
| `GET /api/price/ws` | WebSocket — sends HTML fragments with live price updates (HTMX-compatible) |
|
|
| `GET /api/price/latest` | Latest price as JSON |
|
|
| `GET /api/health` | Health check |
|
|
|
|
## Quick Start
|
|
|
|
```bash
|
|
# Local dev (requires PostgreSQL)
|
|
cp .env.example .env # edit JDBC_URL
|
|
make run # starts on port 4100
|
|
|
|
# Docker
|
|
docker compose up -d # starts on port 4101
|
|
```
|
|
|
|
## Environment Variables
|
|
|
|
| Variable | Default | Description |
|
|
|---|---|---|
|
|
| `BTCDATA_PORT` | `4100` | HTTP server port |
|
|
| `JDBC_URL` | — | PostgreSQL connection string |
|
|
| `CORS_ORIGIN` | `*` | Allowed origin for CORS headers |
|
|
|
|
## Data Sources
|
|
|
|
- **Binance** — WebSocket trade stream (`btcusdt@trade`), throttled to 5s writes
|
|
- **Kraken hourly** — OHLC candles polled at HH:01:00 UTC
|
|
- **Kraken daily** — OHLC candles polled at 00:01:00 UTC
|
|
|
|
## Tech Stack
|
|
|
|
Clojure · Kit · Undertow · Reitit · PostgreSQL · conman · Migratus
|