# sharansrj567/vision-bank architecture

> Architecture diagram of the GitHub repository sharansrj567/vision-bank, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sharansrj567/vision-bank
- Repository: https://github.com/sharansrj567/vision-bank

## Overview

This repository implements a Go banking API. The main workflow starts at the service entry point, configures PostgreSQL-backed storage and HTTP routes, then handles user registration/login and authenticated account or transfer requests. Transfers validate both accounts before a single storage transaction records the transfer, entries, and balance changes. The graph includes the principal API, persistence, authentication, and utility layers. The README is empty, and unsampled SQL, migration, and configuration details are represented only where the tree or shown source supports them.

Main entry points: [`api/server.go`](https://github.com/sharansrj567/vision-bank/blob/main/api/server.go) (HTTP server and routes), [`db/sqlc/store.go`](https://github.com/sharansrj567/vision-bank/blob/main/db/sqlc/store.go) (Store and transfer transaction), [`api/user.go`](https://github.com/sharansrj567/vision-bank/blob/main/api/user.go) (User registration and login), [`token/jwt_maker.go`](https://github.com/sharansrj567/vision-bank/blob/main/token/jwt_maker.go) (JWT token maker)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Service runtime"]
  node_main["Service entry<br/>[main.go]"]
end

subgraph group_api["HTTP API"]
  node_server["HTTP server and routes<br/>[server.go]"]
  node_user_api["User registration and login<br/>[user.go]"]
  node_account_api["Account endpoints<br/>[account.go]"]
  node_transfer_api["Transfer endpoint<br/>[transfer.go]"]
  node_validation["Request validation<br/>[validator.go]"]
end

subgraph group_storage["Persistence"]
  node_store["Store and transfer transaction<br/>[store.go]"]
  node_queries["SQL query operations"]
  node_postgres[("PostgreSQL database")]
end

subgraph group_security["Identity and security"]
  node_middleware["Bearer authentication<br/>[middleware.go]"]
  node_token_maker["JWT token maker<br/>[jwt_maker.go]"]
  node_token_payload["Token payload<br/>[payload.go]"]
  node_password["Password hashing<br/>[password.go]"]
end

subgraph group_utilities["Utilities"]
  node_config["Runtime config<br/>[config.go]"]
  node_currency["Currency support<br/>[currency.go]"]
end

node_client(("API client"))

node_client -->|"sends requests"| node_server
node_main -->|"loads config"| node_config
node_main -->|"creates store"| node_store
node_main -->|"starts server"| node_server
node_server -->|"routes users"| node_user_api
node_server -->|"routes accounts"| node_account_api
node_server -->|"routes transfers"| node_transfer_api
node_server -->|"protects routes"| node_middleware
node_server -->|"creates maker"| node_token_maker
node_server -->|"uses settings"| node_config
node_server -->|"receives store"| node_store
node_user_api -->|"reads and writes users"| node_store
node_user_api -->|"hashes and checks"| node_password
node_user_api -->|"creates access token"| node_token_maker
node_account_api -->|"reads and writes accounts"| node_store
node_account_api -->|"validates currency"| node_currency
node_transfer_api -->|"checks and transfers"| node_store
node_transfer_api -->|"validates currency"| node_currency
node_middleware -->|"verifies token"| node_token_maker
node_token_maker -->|"creates and parses"| node_token_payload
node_store -->|"executes queries"| node_queries
node_queries -->|"runs SQL"| node_postgres
node_store -->|"opens transactions"| node_postgres
node_server -->|"registers currency rule"| node_validation
node_validation -->|"checks support"| node_currency

click node_main "https://github.com/sharansrj567/vision-bank/blob/main/main.go"
click node_config "https://github.com/sharansrj567/vision-bank/blob/main/util/config.go"
click node_server "https://github.com/sharansrj567/vision-bank/blob/main/api/server.go"
click node_user_api "https://github.com/sharansrj567/vision-bank/blob/main/api/user.go"
click node_account_api "https://github.com/sharansrj567/vision-bank/blob/main/api/account.go"
click node_transfer_api "https://github.com/sharansrj567/vision-bank/blob/main/api/transfer.go"
click node_validation "https://github.com/sharansrj567/vision-bank/blob/main/api/validator.go"
click node_middleware "https://github.com/sharansrj567/vision-bank/blob/main/api/middleware.go"
click node_token_maker "https://github.com/sharansrj567/vision-bank/blob/main/token/jwt_maker.go"
click node_token_payload "https://github.com/sharansrj567/vision-bank/blob/main/token/payload.go"
click node_password "https://github.com/sharansrj567/vision-bank/blob/main/util/password.go"
click node_store "https://github.com/sharansrj567/vision-bank/blob/main/db/sqlc/store.go"
click node_queries "https://github.com/sharansrj567/vision-bank/tree/main/db/sqlc"
click node_currency "https://github.com/sharansrj567/vision-bank/blob/main/util/currency.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_main,node_client toneBlue
class node_server,node_user_api,node_account_api,node_transfer_api,node_validation toneAmber
class node_store,node_queries,node_postgres toneMint
class node_middleware,node_token_maker,node_token_payload,node_password toneRose
class node_config,node_currency toneIndigo
```

## Components

### Service runtime

- [Service entry](https://github.com/sharansrj567/vision-bank/blob/main/main.go): `main.go`

### HTTP API

- [HTTP server and routes](https://github.com/sharansrj567/vision-bank/blob/main/api/server.go): `api/server.go`
- [User registration and login](https://github.com/sharansrj567/vision-bank/blob/main/api/user.go): `api/user.go`
- [Account endpoints](https://github.com/sharansrj567/vision-bank/blob/main/api/account.go): `api/account.go`
- [Transfer endpoint](https://github.com/sharansrj567/vision-bank/blob/main/api/transfer.go): `api/transfer.go`
- [Request validation](https://github.com/sharansrj567/vision-bank/blob/main/api/validator.go): `api/validator.go`

### Persistence

- [Store and transfer transaction](https://github.com/sharansrj567/vision-bank/blob/main/db/sqlc/store.go): `db/sqlc/store.go`
- [SQL query operations](https://github.com/sharansrj567/vision-bank/tree/main/db/sqlc): `db/sqlc`
- **PostgreSQL database**

### Identity and security

- [Bearer authentication](https://github.com/sharansrj567/vision-bank/blob/main/api/middleware.go): `api/middleware.go`
- [JWT token maker](https://github.com/sharansrj567/vision-bank/blob/main/token/jwt_maker.go): `token/jwt_maker.go`
- [Token payload](https://github.com/sharansrj567/vision-bank/blob/main/token/payload.go): `token/payload.go`
- [Password hashing](https://github.com/sharansrj567/vision-bank/blob/main/util/password.go): `util/password.go`

### Utilities

- [Runtime config](https://github.com/sharansrj567/vision-bank/blob/main/util/config.go): `util/config.go`
- [Currency support](https://github.com/sharansrj567/vision-bank/blob/main/util/currency.go): `util/currency.go`

### Other components

- **API client**

## Connections

- API client → HTTP server and routes: sends requests (evidence: `api/server.go`)
- Service entry → Runtime config: loads config (evidence: `main.go`)
- Service entry → Store and transfer transaction: creates store (evidence: `main.go`)
- Service entry → HTTP server and routes: starts server (evidence: `main.go`)
- HTTP server and routes → User registration and login: routes users (evidence: `api/server.go`)
- HTTP server and routes → Account endpoints: routes accounts (evidence: `api/server.go`)
- HTTP server and routes → Transfer endpoint: routes transfers (evidence: `api/server.go`)
- HTTP server and routes → Bearer authentication: protects routes (evidence: `api/server.go`)
- HTTP server and routes → JWT token maker: creates maker (evidence: `api/server.go`)
- HTTP server and routes → Runtime config: uses settings (evidence: `api/server.go`)
- HTTP server and routes → Store and transfer transaction: receives store (evidence: `api/server.go`)
- User registration and login → Store and transfer transaction: reads and writes users (evidence: `api/user.go`)
- User registration and login → Password hashing: hashes and checks (evidence: `api/user.go`)
- User registration and login → JWT token maker: creates access token (evidence: `api/user.go`)
- Account endpoints → Store and transfer transaction: reads and writes accounts (evidence: `api/account.go`)
- Account endpoints → Currency support: validates currency
- Transfer endpoint → Store and transfer transaction: checks and transfers (evidence: `api/transfer.go`)
- Transfer endpoint → Currency support: validates currency
- Bearer authentication → JWT token maker: verifies token (evidence: `api/middleware.go`)
- JWT token maker → Token payload: creates and parses (evidence: `token/jwt_maker.go`)
- Store and transfer transaction → SQL query operations: executes queries (evidence: `db/sqlc/store.go`)
- SQL query operations → PostgreSQL database: runs SQL (evidence: `db/sqlc/accounts.sql.go`)
- Store and transfer transaction → PostgreSQL database: opens transactions (evidence: `db/sqlc/store.go`)
- HTTP server and routes → Request validation: registers currency rule (evidence: `api/server.go`)
- Request validation → Currency support: checks support (evidence: `api/validator.go`)
