Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gsabadini/go-transactions
Implementação de arquitetura limpa utilizando Golang :bulb:
https://github.com/gsabadini/go-transactions
architecture clean-architecture clean-code cleanarchitecture docker go golang golang-cleanarchitecture golang-clear-arch hexagonal-architecture onion-architecture
Last synced: 5 days ago
JSON representation
Implementação de arquitetura limpa utilizando Golang :bulb:
- Host: GitHub
- URL: https://github.com/gsabadini/go-transactions
- Owner: GSabadini
- Created: 2020-10-15T14:42:41.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2023-11-13T19:16:43.000Z (about 1 year ago)
- Last Synced: 2023-11-13T20:28:40.209Z (about 1 year ago)
- Topics: architecture, clean-architecture, clean-code, cleanarchitecture, docker, go, golang, golang-cleanarchitecture, golang-clear-arch, hexagonal-architecture, onion-architecture
- Language: Go
- Homepage:
- Size: 225 KB
- Stars: 5
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Go Transactions :bank:
## Arquitetura
- A arquitetura é baseada nos conceitos de Arquitetura Limpa propostas por Uncle Bob. Para mais detalhes clique [aqui](https://blog.cleancoder.com/uncle-bob/2012/08/13/the-clean-architecture.html).![Clean Architecture](clean.png)
## Requisitos
- Docker
- Docker-compose## Começando
- Iniciar aplicação na porta `:3001`
```sh
make start
```- Rodar os testes utilizando um container
```sh
make test
```- Rodar os testes utilizando a máquina local
```sh
make test-local
```- Gerar coverage
```sh
make coverage
```- Ver os logs da aplicação
```sh
make logs
```- Destruir aplicação
```sh
make down
```## API Endpoint
| Endpoint | Método HTTP | Descrição |
| :----------------: | :-------------------: | :-------------------: |
| `/v1/accounts` | `POST` | `Criar conta` |
| `/v1/accounts/{:accountId}` | `GET` | `Buscar conta por ID` |
| `/v1/transactions` | `POST` | `Criar transação` |
| `/v1/health` | `GET` | `Health check` |## Operações
| ID | Descrição | Tipo |
| :------------------------------------: | :-----------------: | :------: |
| `1` | `COMPRA A VISTA` | `DEBIT` |
| `2` | `COMPRA PARCELADA` | `DEBIT` |
| `3` | `SAQUE` | `DEBIT` |
| `4` | `PAGAMENTO` | `CREDIT` |## Testar API usando curl
- #### Criar conta
| Parâmetro | Obrigatório | Tipo | Regras
| :----------: | :----------: | :--------: | :---------:
| `document` | `Sim` | `Object` | |
| `document.number` | `Sim` | `String` | `Máximo 30 caracteres` |
| `available_credit_limit` | `Sim` | `Float` | |`Request`
```bash
curl -i --request POST 'http://localhost:3001/v1/accounts' \
--header 'Content-Type: application/json' \
--data-raw '{
"document": {
"number": "12345678900"
},
"available_credit_limit": 100
}'
````Response`
```json
{
"id": "1a4028ea-3c18-4714-b650-d1058ae7a053",
"document": {
"number": "12345678900"
},
"available_credit_limit": 100,
"created_at": "2020-10-17T02:28:05Z"
}
```- #### Buscar conta por ID
`Request`
```bash
curl -i --request GET 'http://localhost:3001/v1/accounts/{:acountId}'
````Response`
```json
{
"id": "1a4028ea-3c18-4714-b650-d1058ae7a053",
"document": {
"number": "12345678900"
},
"available_credit_limit": 100,
"created_at": "2020-10-17T02:28:05Z"
}
```- #### Criar transação
| Parâmetro | Obrigatório | Tipo | Regras |
| :-------------: | :----------: | :--------: | :--------: |
| `account_id` | `Sim` | `String` | |
| `operation_id` | `Sim` | `String` | |
| `amount` | `Sim` | `Float` | `Maior que zero`|`Request`
```bash
curl -i --request POST 'http://localhost:3001/v1/transactions' \
--header 'Content-Type: application/json' \
--data-raw '{
"account_id": "deeb291c-18a0-45c3-b28b-df7ebcabe4f8",
"operation_id": "3",
"amount": 100
}'
````Response`
```json
{
"id": "22985ca3-c777-4ab2-b433-ba3b6844578d",
"account_id": "deeb291c-18a0-45c3-b28b-df7ebcabe4f8",
"operation": {
"id": "3",
"description": "SAQUE",
"type": "DEBIT"
},
"amount": -100,
"balance": -100,
"created_at": "2020-10-17T22:17:40Z"
}
```## Regras
- Todos os valores monetários são representados em centavos.