How hrtsegv/flagship works
Flagship is a self-hosted feature-flag control plane plus a Go SDK. The main workflow is project → environment → boolean-flag management over HTTP, followed by SDK configuration recovery and live synchronization; applications evaluate flags locally. The server wires use-case services to PostgreSQL, with in-memory repositories also available. The README documents broader roadmap capabilities, including targeting, rollouts, audit history, authentication, and a dashboard, but these are not implemented in the sampled source. Evidence for SDK behavior and some unsampled integrations is limited to README statements.
Main entry points: server.go HTTP API · sync.go Stream synchronization · flag_service.go Flag and configuration use cases · postgres PostgreSQL repositories
Components 22
Control plane
- HTTP API
internal/httpapi/server.go - Project routes
internal/httpapi/project_handlers.go - Environment routes
internal/httpapi/environment_handlers.go - Flag and sync routes
internal/httpapi/flag_handlers.go - Health probes
internal/httpapi/health.go - Server assembly
cmd/flagship/main.go - SSE transport
sse.go
Management services
- Project management
internal/app/project_service.go - Environment management
internal/app/environment_service.go - Flag and configuration use cases
internal/app/flag_service.go - Domain model and validation
internal/domain/validation.go
Persistence
- PostgreSQL repositories
internal/postgres - In-memory repositories
internal/memory
Go SDK
- Local flag client
client.go - Versioned snapshot
snapshot.go - Snapshot recovery
fetch.go - Stream synchronization
sync.go - Configuration events
event.go - Reconnect backoff
backoff.go
Other components
- Team / operator
- Application
- PostgreSQL
Connections 28
- Team / operator → HTTP API: manages resources
README.md - HTTP API → Project routes: routes requests
internal/httpapi/server.go - HTTP API → Environment routes: routes requests
internal/httpapi/server.go - HTTP API → Flag and sync routes: routes requests
internal/httpapi/server.go - HTTP API → Health probes: routes probes
internal/httpapi/server.go - Project routes → Project management: calls
internal/httpapi/project_handlers.go - Environment routes → Environment management: calls
internal/httpapi/environment_handlers.go - Flag and sync routes → Flag and configuration use cases: calls
internal/httpapi/flag_handlers.go - Project management → Domain model and validation: validates
internal/app/project_service.go - Environment management → Domain model and validation: validates
internal/app/environment_service.go - Flag and configuration use cases → Domain model and validation: validates
internal/app/flag_service.go - Server assembly → HTTP API: constructs
cmd/flagship/main.go - Server assembly → PostgreSQL repositories: configures repositories
cmd/flagship/main.go - Server assembly → PostgreSQL: connects
cmd/flagship/main.go - Project management → PostgreSQL repositories: stores projects
- Environment management → PostgreSQL repositories: stores environments
- Flag and configuration use cases → PostgreSQL repositories: stores flags and events
- Flag and configuration use cases → In-memory repositories: uses repository interface
README.md - Application → Local flag client: evaluates flags
README.md - Local flag client → Versioned snapshot: reads configuration
README.md - Local flag client → Configuration events: applies updates
README.md - Application → Stream synchronization: starts sync
README.md - Stream synchronization → SSE transport: connects to stream
README.md - Stream synchronization → Snapshot recovery: recovers snapshot
README.md - Snapshot recovery → Versioned snapshot: installs snapshot
README.md - Stream synchronization → Configuration events: applies stream events
README.md - Stream synchronization → Reconnect backoff: retries with
README.md - SSE transport → Flag and sync routes: serves event stream
internal/httpapi/flag_handlers.go