How lucassantoss1701/bank-api works
Project type and purpose
• This is a backend microservice (“Bank API”) written in Go. It exposes REST endpoints to manage bank accounts, query balances, perform transfers, and authenticate users. It follows a layered/clean-architecture style, with domain entities, use-cases, infrastructure adapters, and a main HTTP server.
File structure
• Top-level:
• cmd/server/main.go → application entrypoint, bootstraps configuration, database, web server
• configs/configs.go → configuration loader
• Dockerfile, docker-compose.yaml → containerization and service orchestration
• docs/swagger.{json,yaml} → OpenAPI spec
• internal/
– entity → domain models & repository interfaces
– usecase → application/business logic
– infra/database → DB connection, migrations, repository implementations
– infra/web → HTTP handlers, routing, middleware, response models
README
• Confirms endpoints (/login, /accounts, /transfers), features, how to run via Docker Compose, and OpenAPI URL.
Main components and their relationships
a. Clients & Tools
– External HTTP clients or Swagger UI → send HTTP requests
b. Web/API Layer
– Webserver (router + middleware: auth, logging)
– HTTP Handlers (account_handler, transfer_handler)
c. Application Layer
– Use-Cases (createAccount, login, makeTransfer, etc.)
– Coordinates domain logic and persistence
d. Domain Layer
– Entities (Account, Transfer) and repository interfaces
e. Infrastructure Layer
– Database Connection & Migrations (PostgreSQL)
– Repository Implementations (account_repository, transfer_repository)
f. Configuration & Bootstrapping
– Config loader reads env/flags
– Dependency injection in main.go wires up DB, repositories, use-cases, webserver
g. External Services
– PostgreSQL container
– (Optional) Monitoring, logging sinks
Architectural patterns & design principles
• Clean/Hexagonal Architecture:
• Layers are strictly separated: outer layers depend on inner layers only via interfaces.
• Entities are at the core; use-cases orchestrate them; infra implements interfaces.
• Dependency Injection at startup (main.go).
• Middleware implements cross-cutting concerns (auth, logging).
• Migrations ensure DB schema versioning.
8) Optionally, show “docker-compose” orchestrating API container + Postgres container.
9) Swagger spec file being served by the webserver.