refactor: replace via framework with chi + templ + datastar #2
Reference in New Issue
Block a user
Delete Branch "refactor/remove-via"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
viameta-framework with direct dependencies: chi (routing), templ (HTML templates), datastar (SSE/reactivity), SCS (sessions), embedded NATS (pub/sub)features/{auth,lobby,c4game,snakegame}/) with handler factory pattern (HandleX(deps) http.HandlerFunc)ui/package (gomponents-based views) and allviaimports fromgo.modDetails
The
viaframework wrapped chi, gomponents, datastar, SCS sessions, and embedded NATS into one opinionated package. This PR replaces all of those with direct dependencies, giving us full control over each layer.New packages
features/common/layouts/— base HTML layout with Datastar JS CDNfeatures/common/components/— shared components (BackToLobby, NicknamePrompt, etc.)features/auth/— login/register pages and handlersfeatures/lobby/— lobby page with tab switching (Connect 4 / Snake)features/c4game/— Connect 4 board, status, chat components and SSE handlersfeatures/snakegame/— Snake board, status, chat components and SSE handlers (with 60fps drain pattern)nats/— embedded NATS server setupsessions/— SCS session manager setuprouter/— chi router wiring with hot-reload support in dev modeKey migration decisions
c.Signal()→ datastardata-signals/data-bindc.Action()→ dedicated POST endpoints withdata-on:clickc.View()+c.Sync()→ initial GET render + SSEPatchElementTemplfragmentsc.Subscribe/Publish→ NATSnc.ChanSubscribe/nc.Publishdata-show) instead of server round-tripsChatMessagedomain type moved fromuipackage togamepackageVerified
go build ./...passesgo mod tidycleanMigrate from the via meta-framework to direct dependencies: - chi for routing, templ for HTML templates, datastar for SSE/reactivity - Feature-sliced architecture (features/{auth,lobby,c4game,snakegame}/) - Shared layouts and components (features/common/) - Handler factory pattern (HandleX(deps) http.HandlerFunc) - Embedded NATS server (nats/), SCS sessions (sessions/), chi router wiring (router/) - Move ChatMessage domain type from ui package to game package - Remove old ui/ package (gomponents-based via/h views) - Remove via dependency from go.mod entirelyRemove /api/ prefix and consolidate route groups: - /api/lobby/* -> /games, /snake, /logout (top-level) - /game/{game_id} + /api/game/{game_id}/* -> /games/{id}/* - /snake/{game_id} + /api/snake/{game_id}/* -> /snake/{id}/* - /api/auth/* -> /auth/* - Standardize snake join page to use return_url= (was return=)