This project is a Golang API Rest to handle CRUD operations related to customers using RabbitMQ and PostgresQL.
- Go 1.21 or later
- Docker
- Docker Compose
- Additional dependencies as specified in
go.mod
-
Clone this repository:
git clone https://github.com/brendontj/didactic-eureka.git cd didactic-eureka
-
Install dependencies:
go mod download
-
Copy the .env.example file to .env and fill in the environment variables:
cp .env.example .env
-
Start docker container with rabbitmq and postgresql dependencies:
docker-compose up -d
-
Run all migrations:
make migrate
-
Run the core application:
go run cmd/api/main.go
-
Run the worker:
go run worker/main.go
-
Send requests to the API at the following address:
- localhost:8080
curl --request POST \
--url http://localhost:8080/api/v1/customers \
--header 'Content-Type: application/json' \
--data '{
"name": "testName",
"email": "test@gmail.com",
"phone": "123456789",
"birth_date": "1995-06-08",
"document": "123456789",
"address": {
"street": "aStreet",
"number": "aNumber",
"zip_code": "123456789",
"neighborhood": "aNeighborhood",
"city": "aCity",
"state": "aState",
"country": "aCountry",
"complement": "aComplement"
}
}'
curl --request GET \
--url http://localhost:8080/api/v1/customers \
--header 'Content-Type: application/json'
curl --request GET \
--url http://localhost:8080/api/v1/customers/{customerId} \
--header 'Content-Type: application/json'
curl --request PUT \
--url http://localhost:8080/api/v1/customers/{customerId}/version/{customerVersion} \
--header 'Content-Type: application/json' \
--data '{
"name": "newName",
"email": "newEmail@gmail.com",
"phone": "33333333",
"birth_date": "1995-06-20",
"document": "1345679843",
"address": {
"street": "aStreet",
"number": "123",
"zip_code": "123325432",
"neighborhood": "aNeighborhood",
"city": "aCity",
"state": "aState",
"country": "aCountry",
"complement": "aComplement"
}
}'
curl --request DELETE \
--url http://localhost:8080/api/v1/customers/{customerId} \
--header 'Content-Type: application/json'
- Create a new customer
- Find all customers
- Find customer by ID
- Update customer by ID
- Delete customer by ID
- (not implemented) Add logging to the application
- (not implemented) Pagination in the list of customers
- (not implemented) Validation of the domain fields
- (not implemented) Unit and integrations tests
- (not implemented) Api swagger documentation