Package Structure
The framework provides the following core packages:application
Core lifecycle management:
Application, Domain interface, Runner, startup taskshttpserver
HTTP server with
HTTPServer, HandlerGroup, and Middleware supportdatabase
PostgreSQL integration with migrations using
sqlx and lib/pq driverqueue
Background job processing with
Processor[T] and Handler[T] interfacesscheduler
Periodic task execution for cron-like functionality
log
Structured logging with context support
auth
Built-in authentication domain (reference implementation)
session
Session management domain
Domain-Driven Design Pattern
A domain represents a bounded context in your application. It aggregates all components needed for a specific business capability.
Domain Interface
All domains must implement theapplication.Domain interface defined in application/domain.go:4:
Component Responsibilities
Reference Implementation: Auth Domain
Theauth package provides a complete domain example. See auth/domain.go:7 for the full implementation:
Package Organization
A typical domain package structure:Architectural Principles
Dependencies Flow Inward
Dependencies Flow Inward
Repositories depend only on the database. Services depend on repositories. Handlers depend on services. This creates a clean dependency graph.
Domains are Self-Contained
Domains are Self-Contained
Each domain manages its own database schema, migrations, business rules, and API. Domains can depend on other domains via their service interfaces.
No Global State
No Global State
Except for
log.Logger, the framework avoids global state. All dependencies are explicitly passed through constructors.Interface-Based Design
Interface-Based Design
Components depend on interfaces, not concrete types. This enables testing with mocks and allows swapping implementations.
Quick Reference
For common tasks, refer to this mapping:Next Steps
Application Lifecycle
Learn how to bootstrap and run your application
Domains
Deep dive into creating and registering domains
HTTP Routing
Set up HTTP endpoints and route groups
Middleware
Add request processing with middleware