Development Workflow
Sphere projects use the generated Makefile as the day-to-day workflow entrypoint. The CLI creates the project; make, go, buf, Wire, Swag, Docker, and project-local tools do the ongoing work.
Core Development Loop
Model Your Data
- Define Ent schemas in
internal/pkg/database/schema/ - Run
make gen/dbto generate database code
- Define Ent schemas in
Define Your API
- Create
.protofiles inproto/ - Use
google.api.httpannotations for HTTP endpoints - Run
make gen/prototo generate Go handlers
- Create
Implement Business Logic
- Write service implementations in
internal/service/ - Keep logic focused and testable
- Write service implementations in
Wire and Test
- Run
make gen/wirefor dependency injection - Start with
make run - Test endpoints via Swagger UI (
make run/swag)
- Run
Tool Boundaries
sphere-cli: create projects, list templates, rename modules, and optionally generate small skeleton files.make: run the project workflow.buf: manage proto dependencies and generation.go: run, test, build, and manage modules.wire: generate dependency injection code.swag: generate Swagger/OpenAPI files.- Docker or CI/CD: build and deploy images when the template supports it.
Adding New Features
For a new entity:
# 1. Add Ent schema
# 2. Regenerate database code
make gen/db
# 3. Add proto messages and services
# 4. Regenerate API code
make gen/proto
make gen/docs
# 5. Implement service methods
# 6. Wire and run
make gen/wire
make runFor a new project setup:
# 1. Create project
sphere-cli create --name myproject --module github.com/user/myproject
cd myproject
# 2. Initialize all dependencies and tools
make init
# 3. Start development
make runFor API changes:
# 1. Update .proto files
# 2. Regenerate
make gen/proto
make gen/docs
# 3. Update service implementations
# 4. Test
make runGenerated Artifacts
make gen/db→ Ent client and schemasmake gen/proto→ Go handlers, types, and routingmake gen/docs→ OpenAPI/Swagger documentationmake gen/wire→ Dependency injection wiringmake gen/dts→ TypeScript client SDKs
Generated artifacts should be safe to clean and recreate. Keep handwritten business logic in internal/service/** and internal/biz/**, and keep API contracts in proto/**.
Best Practices
- Keep services thin: Move complex business logic to
internal/biz/ - Test early: Use generated Swagger UI to verify endpoints
- Iterate fast: Small changes → quick regeneration cycles
- Version APIs: Use proto package versioning for breaking changes
- Keep tool ownership clear: Add project workflow to the Makefile instead of expanding the CLI into a build or deployment platform
Last updated on