The purpose of this repository is to show my mastery of the following topics:
- Docker
- Graceful shutdown
- Horizontal scaling
- Hexagonal pattern
- Circuit breaker pattern
- Transactional outbox pattern
- Design patterns (Singleton, Bridge, Decorator)
To demonstrate this I built an API to manage user-related operations.
- Create a user and notify it to other systems.
- Update a user and notify it to other systems.
- Make a soft deletion of a user and notify other systems.
- Obtain information of a user by ID.
As the diagram shows, this project is compiled in two parts:
users-httpIt is the binary in charge of manage the http requests (service/sender)users-relayIt is the binary in charge of read and send the messages (message relay)
See the required environment variables
See the database schema described by the .sql files
export $(grep -v ^# .env.example)
make upI decided to follow the Go project layout standard.
I built the package tree following the concepts of the hexagonal architecture pattern.
.
├── cmd
├── internal
│ ├── app
│ │ ├── business (Use cases, business rules, data models and ports)
│ │ ├── input (Everything related to "drive" adapters)
│ │ └── output (Everything related to "driven" adapters)
│ └── container (DI container)
└── pkg (Public and global code, potencially libraries)
According to the theory of hexagonal architecture, it is possible to have n adapters for different external signals (http, gRPC, command line, kafka, serverless).
So I decided to compile a binary to handle each signal. See why this decision