When to Use This Template
Use the API template when:- Building a REST API - JSON endpoints for web or mobile clients
- Multiple developers - Clear structure everyone can follow
- Production service - Ready for deployment
- Need organization - More than a few routes
What You Get
A complete project structure with:- Feature-based organization - Code grouped by domain
- Configuration management - Environment-based config
- App lifecycle - Clean startup and shutdown
- Example endpoints - Health check, echo, users
Quick Start
Project Structure
Key Features
Feature-Based Organization
Each feature (domain/module) gets its own folder:Configuration Management
Configuration is loaded from environment variables:Application Structure
TheApp struct manages lifecycle:
Example Routes
Health Check
Hello Endpoint
Users API
Echo Endpoint
Why This Structure?
Scalability
As your API grows, add new features without cluttering existing code:Testability
Each feature can be tested independently:Team Collaboration
Clear boundaries mean less merge conflicts:- Developer A works on
feature/users/ - Developer B works on
feature/products/
Maintainability
Find code easily:- βWhereβs the user creation logic?β β
feature/users/ - βWhere are routes defined?β β
app/api/routes.go - βWhereβs the config?β β
app/api/config.go
Comparison with Minimal
| Aspect | minimal | api |
|---|---|---|
| Files | 1 | 10+ |
| Structure | None | Feature-based |
| Config | Hardcoded | Environment variables |
| Suitable for | Learning, prototypes | Production |
| Scalability | Poor | Good |