MCPcopy Index your code
hub / github.com/GSabadini/go-clean-architecture

github.com/GSabadini/go-clean-architecture @1.11.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release 1.11.0 ↗ · + Follow
385 symbols 1,223 edges 68 files 29 documented · 8% updated 2y ago★ 7461 open issues

Browse by type

Functions 277 Types & classes 108
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Welcome to Go Clean Architecture

Version Build License: MIT Build

  • 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.

Clean Architecture

Example create account use case

Clean Architecture

Requirements/dependencies

  • Docker
  • Docker-compose

Getting Started

  • Environment variables
make init
  • Starting API in development mode
make up
  • Run tests in container
make test
  • Run tests local (it is necessary to have golang installed)
make test-local
  • Run coverage report
make test-report
make test-report-func
  • View logs
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

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

{
    "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

curl -i --request GET 'http://localhost:3001/v1/accounts'

Response

[
    {
        "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

curl -i --request GET 'http://localhost:3001/v1/accounts/{{account_id}}/balance'

Response

{
    "balance": 1
}
  • Creating new transfer

Request

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

{
    "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

curl -i --request GET 'http://localhost:3001/v1/transfers'

Response

[
    {
        "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

License

Copyright © 2020 GSabadini. This project is MIT licensed.

Extension points exported contracts — how you extend this code

Core symbols most depended-on inside this repo

Shape

Method 204
Struct 82
Function 73
Interface 21
TypeAlias 5

Languages

Go100%

Modules by API surface

infrastructure/database/postgres_handler.go22 symbols
domain/account.go18 symbols
adapter/repository/sql.go18 symbols
infrastructure/log/logrus.go16 symbols
infrastructure/log/logger_mock.go14 symbols
domain/transfer.go13 symbols
usecase/create_transfer_test.go11 symbols
infrastructure/http_server.go11 symbols
infrastructure/database/mongo_handler.go11 symbols
usecase/create_transfer.go10 symbols
infrastructure/router/gin.go10 symbols
usecase/find_account_balance.go9 symbols

Datastores touched

(mongodb)Database · 1 repos

For agents

$ claude mcp add go-clean-architecture \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page