Development Workflow
A typical day-to-day development cycle with Sphere follows this pattern:
Core Development Loop
Model Your Data
- Define Ent schemas in
internal/pkg/database/schema/
- Run
make gen/db
to generate database code
- Define Ent schemas in
Define Your API
- Create
.proto
files inproto/
- Use
google.api.http
annotations for HTTP endpoints - Run
make gen/proto
to 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/wire
for dependency injection - Start with
make run
- Test endpoints via Swagger UI (
make run/swag
)
- Run
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 run
For a new project setup:
# 1. Create project
sphere-cli create --name myproject --mod github.com/user/myproject
cd myproject
# 2. Initialize all dependencies and tools
make init
# 3. Start development
make run
For API changes:
# 1. Update .proto files
# 2. Regenerate
make gen/proto
make gen/docs
# 3. Update service implementations
# 4. Test
make run
Generated 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
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
Last updated on