7a2b1a0a87770e98ad59ae62046479a021af746c
First building block for parallel-safe BDD scenario isolation (T12 plan, ADR-0025 follow-up). PR #28 had to revert BDD_SCHEMA_ISOLATION because SetupScenarioSchema created an empty schema without migrations -- the production server's repo never saw it. This PR adds the missing piece: a factory that opens a *PostgresRepository connected via an arbitrary DSN AND runs AutoMigrate against it, so a per-scenario schema actually gets the users table. Public API additions in pkg/user/postgres_repository.go: - NewPostgresRepositoryFromDSN(cfg, dsn) (*PostgresRepository, error) Opens the repo from an explicit DSN (overrides cfg's host/port/etc), runs AutoMigrate -- creates tables in whatever schema the DSN's search_path points to. - BuildSchemaIsolatedDSN(cfg, schemaName) string Builds a DSN with `search_path=<schemaName>` from a base config. The existing NewPostgresRepository(cfg) is unchanged. Existing Close() method is reused. Integration test in postgres_repository_isolated_test.go proves: - AutoMigrate creates `users` table in the per-scenario schema (not public) - A CreateUser through the isolated repo writes into the per-scenario schema - public.users sees ZERO rows for the test username - The per-scenario schema users table sees exactly 1 row Test skips gracefully when DLC_DATABASE_HOST is not set. Out of scope (T12 stage 2/2 next): - Wiring this factory into pkg/bdd/testserver/SetupScenarioSchema - Spawning a fresh server.Server per scenario (requires NewServerWithUserRepo) - Removing -p 1 from scripts/run-bdd-tests.sh after parallel safety is achieved Per code-reviewer skill SOLID/DDD section : - SRP : factory has single responsibility (open + migrate, no business logic) - OCP : the new factory extends the package without changing existing callers - Cognitive load : 1 file, 50 lines added, 1 dedicated test file 🤖 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
♻️ refactor(frontend): split HealthDashboard into smart wrapper + dumb View for state-based stories (#33)
dance-lessons-coach
Go web service demonstrating idiomatic package structure, versioned JSON API, and production-ready features.
Features
- Versioned JSON API (
/api/v1,/api/v2) - Chi router with graceful shutdown
- Zerolog structured logging (console and JSON modes)
- Viper configuration (file + env vars)
- Readiness endpoint for Kubernetes / service mesh
- OpenTelemetry / Jaeger distributed tracing
- OpenAPI / Swagger UI (embedded in binary)
- PostgreSQL user service with JWT auth
- BDD + unit tests
Quick Start
git clone https://gitea.arcodange.lab/arcodange/dance-lessons-coach.git
cd dance-lessons-coach
./scripts/build.sh # produces ./bin/server and ./bin/greet
./scripts/start-server.sh start
curl http://localhost:8080/api/health
curl http://localhost:8080/api/v1/greet/Alice
Stop: ./scripts/start-server.sh stop
Greet CLI
go run ./cmd/greet # Hello world!
go run ./cmd/greet Alice # Hello Alice!
Configuration
All options are available via config.yaml or DLC_* environment variables.
| Env var | Default | Description |
|---|---|---|
DLC_SERVER_PORT |
8080 |
Listening port |
DLC_SERVER_HOST |
0.0.0.0 |
Bind address |
DLC_LOGGING_JSON |
false |
JSON log format |
DLC_LOGGING_OUTPUT |
stderr | Log file path |
DLC_SHUTDOWN_TIMEOUT |
30s |
Graceful shutdown window |
DLC_API_V2_ENABLED |
false |
Enable /api/v2 routes |
DLC_CONFIG_FILE |
./config.yaml |
Override config path |
See config.example.yaml for a full template.
API
| Method | Path | Description |
|---|---|---|
| GET | /api/health |
Liveness check |
| GET | /api/ready |
Readiness check (503 during shutdown) |
| GET | /api/version |
Version info (?format=plain|full|json) |
| GET | /api/v1/greet/ |
Default greeting |
| GET | /api/v1/greet/{name} |
Named greeting |
| POST | /api/v2/greet |
V2 greeting with validation |
| GET | /swagger/ |
Swagger UI |
Testing
go test ./... # unit + integration tests
./scripts/test-graceful-shutdown.sh # lifecycle + JSON logging validation
./scripts/test-opentelemetry.sh # tracing end-to-end
Gitea Client
AI agent helper script at .vibe/skills/gitea-client/scripts/gitea-client.sh.
Auth setup:
echo "your_token" > ~/.gitea_token
chmod 600 ~/.gitea_token
export GITEA_API_TOKEN_FILE="$HOME/.gitea_token"
Get a token at https://gitea.arcodange.lab → Profile → Settings → Applications.
Architecture
Key decisions are documented in adr/. See AGENTS.md for the full development reference (commands, config, ADR index, commit conventions).
License
MIT
Description
Languages
Go
71.2%
Shell
21.7%
Gherkin
3.9%
TypeScript
1.4%
Vue
0.5%
Other
1.2%