A production-ready, strictly typed implementation of Hexagonal Architecture (Ports and Adapters) using Domain-Driven Design (DDD) principles in Go.
This project focuses on type safety, separation of concerns, and long-term maintainability, moving away from tightly coupled dependencies towards a robust domain-centric core.
This project was made using Hexagonal structure to keep a strict separation between business rules and side effects. With Domain-Driven Design (DDD) adherence to the core business logic was enforced. The domain becomes the source of truth not the database schema.
With dependency inversion all the dependencies only flow inward. The domain layer is plain go package, with no dependency with chi, postgres or third-party libraries. So the business logic is more or less "immortal". All the frameworks may change overtime and the implementations may have breaking changes but that doesn't affect the core business logic. Also allows a plug and play like nature where any component of the project can be switched without disrupting the main business logic.
Core Libraries
| Libraries | Purpose | Repo |
|---|---|---|
| Chi | Routing | link |
| Validator | DTO Validation | link |
| pgx | Postgres Drover | link |
| sqlx | Data binding from DB to domain | link |
| go-redis | Redis client library | link |
| godotenv | ENV management | link |
| swaggo | Swagger documentation | link |
✅ Implemented | 🔄 In Progress/Planned
| Aread | Features and Best Practices | Status |
|---|---|---|
| API Design & Architecture | RESTful API design Domain Driven Design, Hexagonal architecture Open API 2.0 specifications Event Streaming with NATS (JetStream) |
✅ ✅ ✅ ✅ |
| Database | PostgreSQL Raw SQL quries for performance SQL version control and schema Migrations Base ERROR maping Optimized indexing Redis of cacheing |
✅ ✅ ✅ ✅ ✅ ✅ |
| Security | Parameterized sql queries to prevent SQL injection DTO for controlled client data User input and query param validation JWT-ES256 ECDSA asymmetric key pairs Token blacklist with Redis Multidevice session management |
✅ ✅ ✅ ✅ ✅ 🔄 |
| Core Operations & Observability | UUID V7 as public ID and serialized ID as internal Custom AppError interface for error handling Centralized configuration management with godotenv Structured logging with slog context timeout middleware Event/audit table with NATS event Streaming |
✅ ✅ ✅ ✅ 🔄 ✅ |