Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gsabadini/go-clean-architecture
Simple API for banking routines using a Clean Architecture in Golang :credit_card: :moneybag: :money_with_wings:
https://github.com/gsabadini/go-clean-architecture
api architecture banking clean-architecture cleanarchitecture go go-clean-architecture golang golang-cleanarchitecture golang-clear-arch hexagonal-architecture onion-architecture payments
Last synced: 3 days ago
JSON representation
Simple API for banking routines using a Clean Architecture in Golang :credit_card: :moneybag: :money_with_wings:
- Host: GitHub
- URL: https://github.com/gsabadini/go-clean-architecture
- Owner: GSabadini
- License: mit
- Created: 2020-02-17T22:06:40.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2024-03-13T23:12:21.000Z (10 months ago)
- Last Synced: 2025-01-10T18:15:36.704Z (10 days ago)
- Topics: api, architecture, banking, clean-architecture, cleanarchitecture, go, go-clean-architecture, golang, golang-cleanarchitecture, golang-clear-arch, hexagonal-architecture, onion-architecture, payments
- Language: Go
- Homepage:
- Size: 18.8 MB
- Stars: 701
- Watchers: 17
- Forks: 93
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Welcome to Go Clean Architecture
- The Go Clean Architecture is a user-friendly solution designed for a range of banking tasks, including account creation, account listing, checking the balance of specific accounts, facilitating transfers between accounts, and compiling transfer records.
## Architecture
- This represents an endeavor to implement a clean architecture. In the event that you're not yet familiar with it, I'd like to provide you with a [reference](https://blog.cleancoder.com/uncle-bob/2012/08/13/the-clean-architecture.html).![Clean Architecture](clean.png)
## Example create account use case
![Clean Architecture](create_account.png)
## Requirements/dependencies
- Docker
- Docker-compose## Getting Started
- Environment variables
```sh
make init
```- Starting API in development mode
```sh
make up
```- Run tests in container
```sh
make test
```- Run tests local (it is necessary to have golang installed)
```sh
make test-local
```- Run coverage report
```sh
make test-report
```
```sh
make test-report-func
```- View logs
```sh
make logs
```## API Request
| Endpoint | HTTP Method | Description |
| --------------- | :---------------------: | :-----------------: |
| `/v1/accounts` | `POST` | `Create accounts` |
| `/v1/accounts` | `GET` | `List accounts` |
| `/v1/accounts/{{account_id}}/balance` | `GET` | `Find balance account` |
| `/v1/transfers`| `POST` | `Create transfer` |
| `/v1/transfers`| `GET` | `List transfers` |
| `/v1/health`| `GET` | `Health check` |## Test endpoints API using curl
- #### Creating new account
`Request`
```bash
curl -i --request POST 'http://localhost:3001/v1/accounts' \
--header 'Content-Type: application/json' \
--data-raw '{
"name": "Test",
"cpf": "070.910.584-24",
"balance": 100
}'
````Response`
```json
{
"id":"5cf59c6c-0047-4b13-a118-65878313e329",
"name":"Test",
"cpf":"070.910.584-24",
"balance":1,
"created_at":"2020-11-02T14:50:46Z"
}
```
- #### Listing accounts`Request`
```bash
curl -i --request GET 'http://localhost:3001/v1/accounts'
````Response`
```json
[
{
"id": "5cf59c6c-0047-4b13-a118-65878313e329",
"name": "Test",
"cpf": "070.910.584-24",
"balance": 1,
"created_at": "2020-11-02T14:50:46Z"
}
]
```- #### Fetching account balance
`Request`
```bash
curl -i --request GET 'http://localhost:3001/v1/accounts/{{account_id}}/balance'
````Response`
```json
{
"balance": 1
}
```- #### Creating new transfer
`Request`
```bash
curl -i --request POST 'http://localhost:3001/v1/transfers' \
--header 'Content-Type: application/json' \
--data-raw '{
"account_origin_id": "{{account_id}}",
"account_destination_id": "{{account_id}}",
"amount": 100
}'
````Response`
```json
{
"id": "b51cd6c7-a55c-491e-9140-91903fe66fa9",
"account_origin_id": "{{account_id}}",
"account_destination_id": "{{account_id}}",
"amount": 1,
"created_at": "2020-11-02T14:57:35Z"
}
```- #### Listing transfers
`Request`
```bash
curl -i --request GET 'http://localhost:3001/v1/transfers'
````Response`
```json
[
{
"id": "b51cd6c7-a55c-491e-9140-91903fe66fa9",
"account_origin_id": "{{account_id}}",
"account_destination_id": "{{account_id}}",
"amount": 1,
"created_at": "2020-11-02T14:57:35Z"
}
]
```## Git workflow
- Gitflow## Code status
- Development## Author
- Gabriel Sabadini Facina - [GSabadini](https://github.com/GSabadini)## License
Copyright © 2020 [GSabadini](https://github.com/GSabadini).
This project is [MIT](LICENSE) licensed.