August 2026
Trader
A trading terminal with imaginary money: prices stream in twice a second, and an assistant that can read your portfolio and place the trades for you.

- Role
- Solo build — frontend, backend, infrastructure
- Stack
- Next.js, FastAPI, Postgres, SSE, OpenRouter, Docker, Vercel
What it brings
- The assistant executes trades through the same API the UI uses, and shows each fill inline as it happens. The live demo answers from its scripted client rather than the model, so leaving it up costs nothing.
- One codebase, two deployment shapes. Serverless has no background task, so prices become a closed-form function of the clock — Brownian motion by Lévy construction, 22 steps down a hashed tree rather than 172,800 summed half-second increments — and one factory picks between that and the simulator at startup. Routes, services and the frontend are untouched.
- Market data comes from a geometric Brownian motion simulator by default — per-ticker volatility, correlated sector moves, no API key. Real quotes are opt-in, and there is deliberately no silent fallback between them.
- 846 tests across the stack: 591 on the backend, 228 on the frontend, plus 27 Playwright specs run against the built container.
Technical design
SSE /api/market/streamlitellm (container build)
Client
Next.js 15 (static export)
Zustand
lightweight-charts
Server
FastAPI
One serverless function, api/index.py.
app/market
Deterministic prices, two ticks a second.
app/llm
Data
Postgres
Driven by asyncpg.
External
OpenRouter
Container build only.
GET /api/*
asyncpg
- One FastAPI app, two deployments. The container build simulates prices with numpy and answers through a real model; the Vercel function computes them in closed form and ships LLM_MOCK=true. Both talk to the same Postgres, and the routes are identical, so the frontend never learns which build it reached.
- SSE, not WebSockets. Prices only ever flow one way. STREAM_MAX_SECONDS is 55, which keeps a stream inside Vercel's sixty-second ceiling for a function.
- The frontend is a static export on the CDN. vercel.json rewrites only /api/* into Python, so no page render ever passes through the function.
The demo runs the serverless build with no database attached, so the portfolio starts at $10,000 and resets whenever the instance is recycled.