# studenikin-k/bank_proto_microservice architecture

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

- Interactive diagram: https://gitdiagram.com/studenikin-k/bank_proto_microservice
- Repository: https://github.com/studenikin-k/bank_proto_microservice

## Overview

This is a Go banking microservices application: clients use an HTTP API gateway for authentication, account access, and transactions, while separate gRPC services own those domains. The transaction service is configured with an account-service client and a worker pool; the account service supports Redis caching and background fee sweeping, and transactions support background recovery. The excerpts show service construction and wiring, but not most handler or service internals; dashed edges mark relationships that are plausible from the component roles but not directly evidenced here.

Main entry points: [`cmd/account_service/main.go`](https://github.com/studenikin-k/bank_proto_microservice/blob/master/cmd/account_service/main.go) (Account runtime), [`cmd/api-gateway/main.go`](https://github.com/studenikin-k/bank_proto_microservice/blob/master/cmd/api-gateway/main.go) (Gateway runtime), [`cmd/transaction_service/main.go`](https://github.com/studenikin-k/bank_proto_microservice/blob/master/cmd/transaction_service/main.go) (Transaction runtime), [`cmd/auth_service/main.go`](https://github.com/studenikin-k/bank_proto_microservice/blob/master/cmd/auth_service/main.go) (Auth runtime)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_gateway["HTTP Gateway"]
  node_gateway_runtime["Gateway runtime<br/>[main.go]"]
  node_gateway_handlers["HTTP handlers"]
  node_auth_middleware["JWT middleware<br/>[auth.go]"]
end

subgraph group_auth["Authentication"]
  node_auth_runtime["Auth runtime<br/>[main.go]"]
  node_auth_handler["Auth gRPC handler<br/>[auth_handler.go]"]
  node_auth_service["Credential and token logic<br/>[auth_service.go]"]
  node_user_repository["User repository<br/>[user_repository.go]"]
  node_user_model["User model<br/>[user.go]"]
  node_auth_db[("Auth database")]
end

subgraph group_accounts["Accounts"]
  node_account_runtime["Account runtime<br/>[main.go]"]
  node_account_handler["Account gRPC handler<br/>[account_handler.go]"]
  node_account_service["Account logic<br/>[account_service.go]"]
  node_account_repository["Account repository"]
  node_account_cache["Redis cache<br/>[redis.go]"]
  node_account_model["Account model<br/>[account.go]"]
  node_account_db[("Account database")]
  node_redis[("Redis")]
end

subgraph group_transactions["Transactions"]
  node_transaction_runtime["Transaction runtime<br/>[main.go]"]
  node_transaction_handler["Transaction gRPC handler"]
  node_transaction_service["Transaction logic and recovery"]
  node_transaction_repository["Transaction repository"]
  node_transaction_worker["Worker pool<br/>[pool.go]"]
  node_transaction_model["Transaction model<br/>[transaction.go]"]
  node_transaction_db[("Transaction database")]
end

node_client(("Banking client"))

node_client -.->|"sends HTTP"| node_gateway_runtime
node_gateway_runtime -->|"creates handlers"| node_gateway_handlers
node_gateway_runtime -->|"configures middleware"| node_auth_middleware
node_gateway_runtime -->|"dials gRPC"| node_auth_runtime
node_gateway_runtime -->|"dials gRPC"| node_account_runtime
node_gateway_runtime -->|"dials gRPC"| node_transaction_runtime
node_gateway_handlers -.->|"calls gRPC"| node_auth_runtime
node_gateway_handlers -.->|"calls gRPC"| node_account_runtime
node_gateway_handlers -.->|"calls gRPC"| node_transaction_runtime
node_auth_runtime -->|"registers server"| node_auth_handler
node_auth_runtime -->|"constructs service"| node_auth_service
node_auth_runtime -->|"constructs repository"| node_user_repository
node_auth_handler -.->|"delegates"| node_auth_service
node_auth_handler -.->|"uses repository"| node_user_repository
node_user_repository -.->|"reads and writes"| node_auth_db
node_account_runtime -->|"registers server"| node_account_handler
node_account_runtime -->|"constructs service"| node_account_service
node_account_runtime -->|"constructs repository"| node_account_repository
node_account_runtime -->|"configures cache"| node_account_cache
node_account_handler -.->|"delegates"| node_account_service
node_account_service -.->|"uses repository"| node_account_repository
node_account_service -.->|"uses cache"| node_account_cache
node_account_repository -.->|"reads and writes"| node_account_db
node_account_cache -.->|"caches data"| node_redis
node_transaction_runtime -->|"registers server"| node_transaction_handler
node_transaction_runtime -->|"constructs service"| node_transaction_service
node_transaction_runtime -->|"constructs repository"| node_transaction_repository
node_transaction_runtime -->|"starts pool"| node_transaction_worker
node_transaction_handler -.->|"delegates"| node_transaction_service
node_transaction_service -.->|"uses repository"| node_transaction_repository
node_transaction_service -.->|"dispatches work"| node_transaction_worker
node_transaction_service -->|"calls account gRPC"| node_account_runtime
node_transaction_repository -.->|"reads and writes"| node_transaction_db

click node_gateway_runtime "https://github.com/studenikin-k/bank_proto_microservice/blob/master/cmd/api-gateway/main.go"
click node_gateway_handlers "https://github.com/studenikin-k/bank_proto_microservice/blob/master/internal/gateway/handlers/gateway_handlers.go"
click node_auth_middleware "https://github.com/studenikin-k/bank_proto_microservice/blob/master/internal/gateway/middleware/auth.go"
click node_auth_runtime "https://github.com/studenikin-k/bank_proto_microservice/blob/master/cmd/auth_service/main.go"
click node_auth_handler "https://github.com/studenikin-k/bank_proto_microservice/blob/master/internal/auth/delivery/grpc/auth_handler.go"
click node_auth_service "https://github.com/studenikin-k/bank_proto_microservice/blob/master/internal/auth/service/auth_service.go"
click node_user_repository "https://github.com/studenikin-k/bank_proto_microservice/blob/master/internal/auth/repository/user_repository.go"
click node_user_model "https://github.com/studenikin-k/bank_proto_microservice/blob/master/internal/auth/models/user.go"
click node_account_runtime "https://github.com/studenikin-k/bank_proto_microservice/blob/master/cmd/account_service/main.go"
click node_account_handler "https://github.com/studenikin-k/bank_proto_microservice/blob/master/internal/account/delivery/grpc/account_handler.go"
click node_account_service "https://github.com/studenikin-k/bank_proto_microservice/blob/master/internal/account/service/account_service.go"
click node_account_repository "https://github.com/studenikin-k/bank_proto_microservice/blob/master/internal/account/repository/account_repository.go"
click node_account_cache "https://github.com/studenikin-k/bank_proto_microservice/blob/master/internal/account/cache/redis.go"
click node_account_model "https://github.com/studenikin-k/bank_proto_microservice/blob/master/internal/account/models/account.go"
click node_transaction_runtime "https://github.com/studenikin-k/bank_proto_microservice/blob/master/cmd/transaction_service/main.go"
click node_transaction_handler "https://github.com/studenikin-k/bank_proto_microservice/blob/master/internal/transaction/delivery/grpc/transaction_handler.go"
click node_transaction_service "https://github.com/studenikin-k/bank_proto_microservice/blob/master/internal/transaction/service/transaction_service.go"
click node_transaction_repository "https://github.com/studenikin-k/bank_proto_microservice/blob/master/internal/transaction/repository/transaction_repository.go"
click node_transaction_worker "https://github.com/studenikin-k/bank_proto_microservice/blob/master/internal/transaction/worker/pool.go"
click node_transaction_model "https://github.com/studenikin-k/bank_proto_microservice/blob/master/internal/transaction/models/transaction.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_gateway_runtime,node_gateway_handlers,node_auth_middleware,node_client toneBlue
class node_auth_runtime,node_auth_handler,node_auth_service,node_user_repository,node_user_model,node_auth_db toneAmber
class node_account_runtime,node_account_handler,node_account_service,node_account_repository,node_account_cache,node_account_model,node_account_db,node_redis toneMint
class node_transaction_runtime,node_transaction_handler,node_transaction_service,node_transaction_repository,node_transaction_worker,node_transaction_model,node_transaction_db toneRose
```

## Components

### HTTP Gateway

- [Gateway runtime](https://github.com/studenikin-k/bank_proto_microservice/blob/master/cmd/api-gateway/main.go): `cmd/api-gateway/main.go`
- [HTTP handlers](https://github.com/studenikin-k/bank_proto_microservice/blob/master/internal/gateway/handlers/gateway_handlers.go): `internal/gateway/handlers/gateway_handlers.go`
- [JWT middleware](https://github.com/studenikin-k/bank_proto_microservice/blob/master/internal/gateway/middleware/auth.go): `internal/gateway/middleware/auth.go`

### Authentication

- [Auth runtime](https://github.com/studenikin-k/bank_proto_microservice/blob/master/cmd/auth_service/main.go): `cmd/auth_service/main.go`
- [Auth gRPC handler](https://github.com/studenikin-k/bank_proto_microservice/blob/master/internal/auth/delivery/grpc/auth_handler.go): `internal/auth/delivery/grpc/auth_handler.go`
- [Credential and token logic](https://github.com/studenikin-k/bank_proto_microservice/blob/master/internal/auth/service/auth_service.go): `internal/auth/service/auth_service.go`
- [User repository](https://github.com/studenikin-k/bank_proto_microservice/blob/master/internal/auth/repository/user_repository.go): `internal/auth/repository/user_repository.go`
- [User model](https://github.com/studenikin-k/bank_proto_microservice/blob/master/internal/auth/models/user.go): `internal/auth/models/user.go`
- **Auth database**

### Accounts

- [Account runtime](https://github.com/studenikin-k/bank_proto_microservice/blob/master/cmd/account_service/main.go): `cmd/account_service/main.go`
- [Account gRPC handler](https://github.com/studenikin-k/bank_proto_microservice/blob/master/internal/account/delivery/grpc/account_handler.go): `internal/account/delivery/grpc/account_handler.go`
- [Account logic](https://github.com/studenikin-k/bank_proto_microservice/blob/master/internal/account/service/account_service.go): `internal/account/service/account_service.go`
- [Account repository](https://github.com/studenikin-k/bank_proto_microservice/blob/master/internal/account/repository/account_repository.go): `internal/account/repository/account_repository.go`
- [Redis cache](https://github.com/studenikin-k/bank_proto_microservice/blob/master/internal/account/cache/redis.go): `internal/account/cache/redis.go`
- [Account model](https://github.com/studenikin-k/bank_proto_microservice/blob/master/internal/account/models/account.go): `internal/account/models/account.go`
- **Account database**
- **Redis**

### Transactions

- [Transaction runtime](https://github.com/studenikin-k/bank_proto_microservice/blob/master/cmd/transaction_service/main.go): `cmd/transaction_service/main.go`
- [Transaction gRPC handler](https://github.com/studenikin-k/bank_proto_microservice/blob/master/internal/transaction/delivery/grpc/transaction_handler.go): `internal/transaction/delivery/grpc/transaction_handler.go`
- [Transaction logic and recovery](https://github.com/studenikin-k/bank_proto_microservice/blob/master/internal/transaction/service/transaction_service.go): `internal/transaction/service/transaction_service.go`
- [Transaction repository](https://github.com/studenikin-k/bank_proto_microservice/blob/master/internal/transaction/repository/transaction_repository.go): `internal/transaction/repository/transaction_repository.go`
- [Worker pool](https://github.com/studenikin-k/bank_proto_microservice/blob/master/internal/transaction/worker/pool.go): `internal/transaction/worker/pool.go`
- [Transaction model](https://github.com/studenikin-k/bank_proto_microservice/blob/master/internal/transaction/models/transaction.go): `internal/transaction/models/transaction.go`
- **Transaction database**

### Other components

- **Banking client**

## Connections

- Banking client → Gateway runtime: sends HTTP
- Gateway runtime → HTTP handlers: creates handlers (evidence: `cmd/api-gateway/main.go`)
- Gateway runtime → JWT middleware: configures middleware (evidence: `cmd/api-gateway/main.go`)
- Gateway runtime → Auth runtime: dials gRPC (evidence: `cmd/api-gateway/main.go`)
- Gateway runtime → Account runtime: dials gRPC (evidence: `cmd/api-gateway/main.go`)
- Gateway runtime → Transaction runtime: dials gRPC (evidence: `cmd/api-gateway/main.go`)
- HTTP handlers → Auth runtime: calls gRPC
- HTTP handlers → Account runtime: calls gRPC
- HTTP handlers → Transaction runtime: calls gRPC
- Auth runtime → Auth gRPC handler: registers server (evidence: `cmd/auth_service/main.go`)
- Auth runtime → Credential and token logic: constructs service (evidence: `cmd/auth_service/main.go`)
- Auth runtime → User repository: constructs repository (evidence: `cmd/auth_service/main.go`)
- Auth gRPC handler → Credential and token logic: delegates
- Auth gRPC handler → User repository: uses repository
- User repository → Auth database: reads and writes
- Account runtime → Account gRPC handler: registers server (evidence: `cmd/account_service/main.go`)
- Account runtime → Account logic: constructs service (evidence: `cmd/account_service/main.go`)
- Account runtime → Account repository: constructs repository (evidence: `cmd/account_service/main.go`)
- Account runtime → Redis cache: configures cache (evidence: `cmd/account_service/main.go`)
- Account gRPC handler → Account logic: delegates
- Account logic → Account repository: uses repository
- Account logic → Redis cache: uses cache
- Account repository → Account database: reads and writes
- Redis cache → Redis: caches data
- Transaction runtime → Transaction gRPC handler: registers server (evidence: `cmd/transaction_service/main.go`)
- Transaction runtime → Transaction logic and recovery: constructs service (evidence: `cmd/transaction_service/main.go`)
- Transaction runtime → Transaction repository: constructs repository (evidence: `cmd/transaction_service/main.go`)
- Transaction runtime → Worker pool: starts pool (evidence: `cmd/transaction_service/main.go`)
- Transaction gRPC handler → Transaction logic and recovery: delegates
- Transaction logic and recovery → Transaction repository: uses repository
- Transaction logic and recovery → Worker pool: dispatches work
- Transaction logic and recovery → Account runtime: calls account gRPC
- Transaction repository → Transaction database: reads and writes
