# martineoficial/ebanx-challenge-golang architecture

> Architecture diagram of the GitHub repository martineoficial/ebanx-challenge-golang, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-16). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/martineoficial/ebanx-challenge-golang
- Repository: https://github.com/martineoficial/ebanx-challenge-golang

## Overview

This repository implements a small in-memory account API. An HTTP client sends reset, balance, or event requests; the router dispatches them to handlers, which call account use cases and return plain-text or JSON responses. Deposit, withdrawal, and transfer are distinct domain operations; the service uses a repository contract, backed at startup by a concurrency-safe memory store. The README documents these capabilities and atomic updates; connections beyond the shown calls and wiring are omitted.

Main entry points: [`internal/account/service.go`](https://github.com/martineoficial/ebanx-challenge-golang/blob/main/internal/account/service.go) (Account use cases), [`internal/http/handler.go`](https://github.com/martineoficial/ebanx-challenge-golang/blob/main/internal/http/handler.go) (HTTP handlers), [`cmd/api/main.go`](https://github.com/martineoficial/ebanx-challenge-golang/blob/main/cmd/api/main.go) (Server startup), [`internal/http/router.go`](https://github.com/martineoficial/ebanx-challenge-golang/blob/main/internal/http/router.go) (Route setup)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_transport["HTTP transport"]
  node_startup["Server startup<br/>[main.go]"]
  node_router["Route setup<br/>[router.go]"]
  node_handler["HTTP handlers<br/>[handler.go]"]
  node_event_dispatch["Event dispatch<br/>[handler.go]"]
  node_dto["Event DTOs<br/>[dto.go]"]
end

subgraph group_domain["Account domain"]
  node_service["Account use cases<br/>[service.go]"]
  node_account["Account entity<br/>[account.go]"]
  node_errors["Domain errors<br/>[errors.go]"]
  node_repository_contract["Repository contract<br/>[repository.go]"]
end

subgraph group_storage["Account storage"]
  node_memory_store[("Memory repository<br/>[repository.go]")]
end

node_client(("HTTP client"))

node_client -->|"sends requests"| node_router
node_startup -->|"creates"| node_memory_store
node_startup -->|"injects repository"| node_service
node_startup -->|"starts server with"| node_router
node_router -->|"routes requests"| node_handler
node_handler -->|"calls use cases"| node_service
node_handler -->|"dispatches events"| node_event_dispatch
node_handler -->|"decodes and encodes"| node_dto
node_event_dispatch -->|"calls event operations"| node_service
node_service -->|"uses contract"| node_repository_contract
node_service -->|"updates accounts"| node_account
node_service -->|"returns domain errors"| node_errors
node_memory_store -->|"implements"| node_repository_contract
node_service -.->|"dispatches repository calls"| node_memory_store

click node_startup "https://github.com/martineoficial/ebanx-challenge-golang/blob/main/cmd/api/main.go"
click node_router "https://github.com/martineoficial/ebanx-challenge-golang/blob/main/internal/http/router.go"
click node_handler "https://github.com/martineoficial/ebanx-challenge-golang/blob/main/internal/http/handler.go"
click node_event_dispatch "https://github.com/martineoficial/ebanx-challenge-golang/blob/main/internal/http/handler.go"
click node_dto "https://github.com/martineoficial/ebanx-challenge-golang/blob/main/internal/http/dto.go"
click node_service "https://github.com/martineoficial/ebanx-challenge-golang/blob/main/internal/account/service.go"
click node_account "https://github.com/martineoficial/ebanx-challenge-golang/blob/main/internal/account/account.go"
click node_errors "https://github.com/martineoficial/ebanx-challenge-golang/blob/main/internal/account/errors.go"
click node_repository_contract "https://github.com/martineoficial/ebanx-challenge-golang/blob/main/internal/account/repository.go"
click node_memory_store "https://github.com/martineoficial/ebanx-challenge-golang/blob/main/internal/storage/memory/repository.go"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_startup,node_router,node_handler,node_event_dispatch,node_dto,node_client toneBlue
class node_service,node_account,node_errors,node_repository_contract toneAmber
class node_memory_store toneMint
```

## Components

### HTTP transport

- [Server startup](https://github.com/martineoficial/ebanx-challenge-golang/blob/main/cmd/api/main.go): `cmd/api/main.go`
- [Route setup](https://github.com/martineoficial/ebanx-challenge-golang/blob/main/internal/http/router.go): `internal/http/router.go`
- [HTTP handlers](https://github.com/martineoficial/ebanx-challenge-golang/blob/main/internal/http/handler.go): `internal/http/handler.go`
- [Event dispatch](https://github.com/martineoficial/ebanx-challenge-golang/blob/main/internal/http/handler.go): `internal/http/handler.go`
- [Event DTOs](https://github.com/martineoficial/ebanx-challenge-golang/blob/main/internal/http/dto.go): `internal/http/dto.go`

### Account domain

- [Account use cases](https://github.com/martineoficial/ebanx-challenge-golang/blob/main/internal/account/service.go): `internal/account/service.go`
- [Account entity](https://github.com/martineoficial/ebanx-challenge-golang/blob/main/internal/account/account.go): `internal/account/account.go`
- [Domain errors](https://github.com/martineoficial/ebanx-challenge-golang/blob/main/internal/account/errors.go): `internal/account/errors.go`
- [Repository contract](https://github.com/martineoficial/ebanx-challenge-golang/blob/main/internal/account/repository.go): `internal/account/repository.go`

### Account storage

- [Memory repository](https://github.com/martineoficial/ebanx-challenge-golang/blob/main/internal/storage/memory/repository.go): `internal/storage/memory/repository.go`

### Other components

- **HTTP client**

## Connections

- HTTP client → Route setup: sends requests (evidence: `README.md`)
- Server startup → Memory repository: creates (evidence: `cmd/api/main.go`)
- Server startup → Account use cases: injects repository (evidence: `cmd/api/main.go`)
- Server startup → Route setup: starts server with (evidence: `cmd/api/main.go`)
- Route setup → HTTP handlers: routes requests (evidence: `internal/http/router.go`)
- HTTP handlers → Account use cases: calls use cases (evidence: `internal/http/handler.go`)
- HTTP handlers → Event dispatch: dispatches events (evidence: `internal/http/handler.go`)
- HTTP handlers → Event DTOs: decodes and encodes (evidence: `internal/http/handler.go`)
- Event dispatch → Account use cases: calls event operations (evidence: `internal/http/handler.go`)
- Account use cases → Repository contract: uses contract (evidence: `internal/account/service.go`)
- Account use cases → Account entity: updates accounts (evidence: `internal/account/service.go`)
- Account use cases → Domain errors: returns domain errors (evidence: `internal/account/service.go`)
- Memory repository → Repository contract: implements (evidence: `internal/storage/memory/repository.go`)
- Account use cases → Memory repository: dispatches repository calls (evidence: `README.md`)
