0bb52f9ec6
Create structured plan files with 12 phases covering the full implementation: scaffold, store, crypto, Docker/NPM clients, registry poller, webhook, deployer, API layer, SvelteKit frontend, embedding, and hardening.
2.9 KiB
2.9 KiB
Phase 11: Frontend Embed & Real-Time Updates
Status: ⬜ Not Started Parent plan: PLAN.md Domain: fullstack
Objective
Build SvelteKit to static files, embed into the Go binary with go:embed, serve from Go, and implement SSE for real-time deploy progress and instance status updates.
Tasks
- Task 1: Configure SvelteKit static adapter to output to
web/build/ - Task 2: Add
//go:embed web/builddirective in Go — serve static files - Task 3: Create Go handler for serving embedded SPA — serve index.html for all non-API routes (SPA fallback)
- Task 4: Implement SSE endpoint for deploy logs —
GET /api/deploys/:id/logsstreams deploy progress in real-time - Task 5: Implement SSE endpoint for instance status —
GET /api/eventsstreams instance status changes - Task 6: Create event bus/broadcaster in Go — publish events from deployer, subscribe from SSE handlers
- Task 7: Frontend: connect to SSE for deploy progress — update deploy log view in real-time
- Task 8: Frontend: connect to SSE for instance status — update dashboard/project views without refresh
- Task 9: Handle SSE reconnection in frontend — auto-reconnect with backoff on disconnect
- Task 10: Build script/Makefile —
make buildbuilds frontend then Go binary
Files to Modify/Create
web/svelte.config.js— ensure static adapter outputs toweb/build/internal/api/static.go— embedded static file server with SPA fallbackinternal/api/sse.go— SSE endpoints for deploy logs and instance eventsinternal/events/bus.go— event bus for publishing/subscribing to eventsweb/src/lib/sse.ts— SSE client helper with auto-reconnectweb/src/routes/+layout.svelte— wire up global SSE connection for instance statusMakefile— build frontend + backendcmd/server/main.go— wire embedded static serving and event bus
Acceptance Criteria
make buildproduces a single Go binary with embedded frontend- Go binary serves the SvelteKit SPA on all non-API routes
- Deploy progress streams in real-time via SSE
- Instance status updates appear without page refresh
- SSE reconnects automatically after network hiccups
Notes
go:embedrequires the embedded directory to be relative to the Go source file- SPA fallback: any request that doesn't match
/api/*getsindex.html - Event bus: simple pub/sub with channels — no external dependency needed
- SSE format:
data: {"type": "deploy_log", "payload": {...}}\n\n - Keep SSE connections lightweight — use context cancellation for cleanup
Review Checklist
- All tasks completed
- Single binary serves both API and frontend
- SSE handles multiple concurrent clients
- No goroutine leaks on SSE disconnect
- Build process is reproducible (Makefile)