# elamaran15/bankly architecture

> Architecture diagram of the GitHub repository elamaran15/bankly, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-07-19). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/elamaran15/bankly
- Repository: https://github.com/elamaran15/bankly

## Overview

##### Project Type and Purpose
- This is a banking microservice application built with Spring Boot and Spring Cloud.
- It follows a distributed architecture: multiple domain services (User, Transaction, Payment), a service registry (Eureka), an API Gateway, an event bus (Kafka/Zookeeper), centralized tracing (Zipkin), and backing stores (PostgreSQL per service).

##### Key Directories and Their Roles
- apigatewayservice: Spring Cloud Gateway handling all external HTTP traffic, authentication/filtering, routing to downstream services.
- eurekaservice: Spring Cloud Eureka server for service registration and discovery.
- userservice, transactionservice, paymentservice: three independent Spring Boot microservices, each with its own domain logic, REST controllers, data repositories (Liquibase/Flyway changelogs), and PostgreSQL schema.
- db-init/init.sql: initial DB setup for shared or common schemas if any.
- docker-compose.yml & k8s/: container and Kubernetes deployment definitions for all services, databases, Kafka, Zookeeper, Zipkin, ingress, secrets, PVCs.

##### Main Components
- API Gateway
- Eureka Service Registry
- User Service (Spring Boot + Postgres)
- Transaction Service (Spring Boot + Postgres + External API client)
- Payment Service (Spring Boot + Postgres + Kafka producer/consumer)
- Kafka Cluster (with Zookeeper)
- Zipkin Tracing Server
- PostgreSQL instances (one per service or shared)
- Kubernetes Cluster (namespaces, ingress) or Docker-Compose network if drawing local stack

##### Relationships and Data Flows
- Client → Ingress Controller (K8s) or direct → API Gateway
- API Gateway → Eureka (to resolve downstream service instances)
- API Gateway → User/Transaction/Payment services (synchronous HTTP calls)
- Transaction Service → ExternalApiClient → User Service & Payment Service (sync)
- Payment Service → Kafka Producer (“transaction-processed” topic)
- Transaction Service → Kafka Consumer (“transaction-processed” topic)
- Zipkin collects traces from all HTTP and Kafka traffic via Sleuth instrumentation
- Each service reads/writes its own PostgreSQL database via JDBC

##### Architectural Patterns and Technologies
- Microservices architecture with clear service boundaries
- Service Discovery (Eureka) with client‐side load balancing
- API Gateway pattern for cross‐cutting concerns (auth, routing)
- Event‐driven integration (Kafka topics, Zookeeper coordination)
- Distributed tracing (Spring Cloud Sleuth + Zipkin)
- Database per service pattern with Liquibase/Flyway changelogs

## Diagram (Mermaid)

```mermaid
flowchart TD
  subgraph "Kubernetes Cluster"
    direction TB
    Ingress["Ingress Controller"]:::ingress
    Gate["API Gateway"]:::gateway
    Eureka["Eureka Service Registry"]:::infra
    Ingress -->|"HTTP/REST"| Gate
    Gate -->|"Service Discovery"| Eureka

    subgraph "Microservices"
      direction TB
      User["User Service"]:::service
      Transaction["Transaction Service"]:::service
      Payment["Payment Service"]:::service
    end

    Gate -->|"HTTP/REST"| User
    Gate -->|"HTTP/REST"| Transaction
    Gate -->|"HTTP/REST"| Payment

    Transaction -->|"HTTP/REST ExternalApiClient"| User
    Transaction -->|"HTTP/REST ExternalApiClient"| Payment

    subgraph "Platform"
      direction TB
      Zookeeper["Zookeeper"]:::messaging
      Kafka["Kafka Broker"]:::messaging
      Zipkin["Zipkin Tracing Server"]:::infra
    end

    Payment -->|"Kafka Topic: transaction-processed"| Kafka
    Transaction -->|"Kafka Topic: transaction-processed"| Kafka

    subgraph "Databases"
      direction TB
      PostgresUser["PostgreSQL (User)"]:::database
      PostgresTrans["PostgreSQL (Transaction)"]:::database
      PostgresPay["PostgreSQL (Payment)"]:::database
    end

    User -->|"JDBC"| PostgresUser
    Transaction -->|"JDBC"| PostgresTrans
    Payment -->|"JDBC"| PostgresPay

    User -->|"Tracing"| Zipkin
    Transaction -->|"Tracing"| Zipkin
    Payment -->|"Tracing"| Zipkin
    Gate -->|"Tracing"| Zipkin
  end

  subgraph "Setup"
    DBInit["DB Init (init.sql)"]:::infra
  end
  DBInit --> PostgresUser
  DBInit --> PostgresTrans
  DBInit --> PostgresPay

  click Gate "https://github.com/elamaran15/bankly/tree/main/apigatewayservice/src/main/java/com/bankly/apigatewayservice"
  click Eureka "https://github.com/elamaran15/bankly/tree/main/eurekaservice/src/main/java/com/bankly/eurekaservice"
  click User "https://github.com/elamaran15/bankly/tree/main/userservice/src/main/java/com/bankly/userservice"
  click Transaction "https://github.com/elamaran15/bankly/tree/main/transactionservice/src/main/java/com/bankly/transactionservice"
  click Payment "https://github.com/elamaran15/bankly/tree/main/paymentservice/src/main/java/com/bankly/paymentservice"
  click Kafka "https://github.com/elamaran15/bankly/blob/main/k8s/kafka.yaml"
  click Zookeeper "https://github.com/elamaran15/bankly/blob/main/k8s/zookeeper.yaml"
  click Zipkin "https://github.com/elamaran15/bankly/blob/main/k8s/zipkin.yaml"
  click PostgresUser "https://github.com/elamaran15/bankly/blob/main/k8s/postgres.yaml"
  click PostgresTrans "https://github.com/elamaran15/bankly/blob/main/k8s/postgres.yaml"
  click PostgresPay "https://github.com/elamaran15/bankly/blob/main/k8s/postgres.yaml"
  click DBInit "https://github.com/elamaran15/bankly/blob/main/db-init/init.sql"

  classDef ingress fill:#CCE5FF,stroke:#3399FF
  classDef gateway fill:#CCE5FF,stroke:#0066CC
  classDef service fill:#D0E9C6,stroke:#3C763D
  classDef database fill:#DFF0D8,stroke:#3C763D
  classDef messaging fill:#FCF8E3,stroke:#8A6D3B
  classDef infra fill:#F2F2F2,stroke:#666
```
