Core Concepts
Learn the module, controller, service, and dependency boundaries used by Gorix applications.
Modules
A module is the boundary of a feature. It groups controllers, services, infrastructure providers, and configuration that belong together.
Good module boundaries are based on business capability rather than technical type. Prefer PaymentModule or IdentityModule over a global ControllersModule.
Controllers
Controllers translate transport-level input into application calls. Their responsibilities should remain small:
- declare method and path metadata;
- bind path, query, header, and body values;
- validate incoming data;
- call a service;
- map the result to an HTTP response.
Services
Services contain application behavior and orchestrate domain operations. They should not depend directly on HTTP request or response objects.
type UserService struct {
repository UserRepository
}
func (s *UserService) FindByID(ctx context.Context, id string) (*User, error) {
return s.repository.FindByID(ctx, id)
}
Dependency boundaries
Depend on narrow interfaces close to the consumer. Infrastructure packages can implement those interfaces and be registered by the module.
Application bootstrap
The root application registers modules, validates framework conventions, loads configuration, and starts the HTTP server. Production mode may disable development-only structure validation to reduce startup work.
