How bxcodec/golang-ddd-modular-monolith-with-hexagonal works
This is a Go modular-monolith example with payment and payment-settings bounded contexts. The principal workflow is an HTTP request entering the REST command, reaching a module controller and service, then reading or writing PostgreSQL through a repository; payment creation also consults payment settings. A separate CLI command runs payment updates through a cron adapter. The README documents migrations and the architectural capabilities, but their runtime wiring is not shown in the sampled source, so those links are omitted. Some controller and cron-to-service calls are likewise not evidenced by the excerpts.
Main entry points: factory/factory.go Payment wiring · rest.go REST bootstrap · service.go Payment service · factory/factory.go Settings wiring
Components 20
Application runtime
- REST bootstrap
cmd/rest.go - Update command
cmd/cron_update_payment.go
Payment context
- Payment wiring
modules/payment/factory/factory.go - Payment REST
modules/payment/internal/adapter/controller/rest.go - Payment service
modules/payment/internal/service/service.go - Payment model
modules/payment/payment.go - Payment ports
modules/payment/internal/ports/paymentrepository.go - Payment repository
modules/payment/internal/adapter/repository/paymentrepository.go - Payment updater
modules/payment/internal/adapter/cron/payment_updater.go
Settings context
- Settings wiring
modules/payment-settings/factory/factory.go - Settings REST
modules/payment-settings/internal/adapter/controller/rest.go - Settings service
modules/payment-settings/internal/service/service.go - Settings model
modules/payment-settings/settings.go - Settings port
modules/payment-settings/internal/ports/paymentsettingsrepository.go - Settings repository
modules/payment-settings/internal/adapter/repository/paymentsettingsrepository.go
Shared infrastructure
- PostgreSQL
- HTTP middleware
pkg/middlewares/error_handler.go - Schema migrations
migrations
Other components
- HTTP client
- CLI user
Connections 20
- HTTP client → REST bootstrap: sends HTTP
README.md - CLI user → Update command: runs command
README.md - REST bootstrap → Settings wiring: initializes
cmd/rest.go - REST bootstrap → Payment wiring: initializes
cmd/rest.go - REST bootstrap → HTTP middleware: configures
cmd/rest.go - Payment wiring → Payment service: constructs
modules/payment/factory/factory.go - Payment wiring → Payment repository: constructs
modules/payment/factory/factory.go - Payment wiring → Payment REST: registers
modules/payment/factory/factory.go - Payment wiring → Payment updater: constructs
modules/payment/factory/factory.go - Settings wiring → Settings service: constructs
modules/payment-settings/factory/factory.go - Settings wiring → Settings repository: constructs
modules/payment-settings/factory/factory.go - Settings wiring → Settings REST: registers
modules/payment-settings/factory/factory.go - Payment service → Payment ports: uses contracts
modules/payment/internal/service/service.go - Payment service → Payment repository: calls persistence
modules/payment/internal/service/service.go - Payment service → Settings service: queries settings
- Settings service → Settings port: uses contract
modules/payment-settings/internal/service/service.go - Settings service → Settings repository: calls persistence
modules/payment-settings/internal/service/service.go - Payment repository → PostgreSQL: reads writes
modules/payment/internal/adapter/repository/paymentrepository.go - Settings repository → PostgreSQL: reads writes
modules/payment-settings/internal/adapter/repository/paymentsettingsrepository.go - Schema migrations → PostgreSQL: defines schema
README.md