# Phase 1: Project Scaffold & SQLite Store **Status:** ⬜ Not Started **Parent plan:** [PLAN.md](./PLAN.md) **Domain:** backend ## Objective Initialize the Go project, establish the directory structure, and implement the SQLite store with schema, migrations, and CRUD operations for all entities. ## Tasks - [ ] Task 1: Initialize Go module (`go mod init`), create directory structure per PLAN.md - [ ] Task 2: Add core dependencies to go.mod (sqlite, chi, yaml, uuid, cron) - [ ] Task 3: Define SQLite schema — tables for projects, stages, registries, settings, instances, deploys, deploy_logs - [ ] Task 4: Implement store initialization with auto-migration (create tables if not exist) - [ ] Task 5: Implement projects CRUD (Create, GetByID, GetAll, Update, Delete) - [ ] Task 6: Implement stages CRUD (Create, GetByProjectID, Update, Delete) - [ ] Task 7: Implement registries CRUD (Create, GetByID, GetAll, Update, Delete) - [ ] Task 8: Implement settings Get/Update (single-row config pattern) - [ ] Task 9: Implement instances CRUD (Create, GetByStageID, GetByID, Update, Delete, UpdateStatus) - [ ] Task 10: Implement deploys CRUD (Create, GetByProjectID, GetRecent, GetByID) + deploy_logs append - [ ] Task 11: Create `cmd/server/main.go` entry point (minimal — just opens DB, defers close) ## Files to Modify/Create - `go.mod` — module definition and dependencies - `go.sum` — dependency checksums - `cmd/server/main.go` — entry point - `internal/store/store.go` — DB connection, schema, migrations - `internal/store/projects.go` — project queries - `internal/store/stages.go` — stage queries - `internal/store/registries.go` — registry queries - `internal/store/settings.go` — settings queries - `internal/store/instances.go` — instance queries - `internal/store/deploys.go` — deploy history queries ## Acceptance Criteria - `go mod tidy` succeeds - All store CRUD functions are implemented with proper error handling - Schema covers all entities from the architecture plan - Entry point compiles (may not fully run until later phases wire everything) ## Notes - Use `modernc.org/sqlite` for CGo-free SQLite - Use `go-chi/chi/v5` for routing (will be wired in Phase 8) - Settings table uses a single-row pattern (one row, upsert on update) - Instance status should be an enum-like string: "running", "stopped", "failed", "removing" - Deploy status: "pending", "pulling", "starting", "configuring_proxy", "health_checking", "success", "failed", "rolled_back" ## Review Checklist - [ ] All tasks completed - [ ] Code follows Go conventions (gofmt, proper error returns) - [ ] No unintended side effects - [ ] Schema is normalized and covers all planned entities - [ ] CRUD functions handle not-found cases properly ## Handoff to Next Phase