Go API + React Router SPA, shipped as a single binary.
main.go— wiring: env, database, routes, server.handlers.go—/api/*handlers.db.go— GORM models and connection.spa.go— serves the built frontend (embedded viago:embed), with anindex.htmlfallback for client-side routes.web/— React Router v7 app in SPA mode (Vite is its build tool; it outputs static files toweb/build/client).
Two terminals:
make dev-api # Go API on http://localhost:8090
make dev-web # frontend on http://localhost:5173, proxies /api to the Go serverWork against http://localhost:5173 — you get Vite HMR, and API calls hit Go.
make build # npm run build, then go build (frontend embedded)
./dispatcher # serves everything on :8090 (override with PORT)Note: go build embeds web/build/client, so the frontend must be built first — make build handles the order.
GORM with DuckDB (via github.com/vogo/duckdb/v2). Data lives in dispatcher.duckdb next to the binary (override with DB_PATH); db.go holds the models and connection, and AutoMigrate runs on startup. Building needs CGO (DuckDB links a C library) — already the Go default.
- API route: register another
mux.HandleFunc("GET /api/...")inmain.go, implement it inhandlers.go. - Model: add a struct in
db.goand list it inAutoMigrate. - Page: add a file under
web/src/routes/and register it inweb/src/routes.ts.