Skip to content

About

No description, website, or topics provided.

Resources

Stars

3 stars

Watchers

0 watching

Forks

Latest commit

 

History

29 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BankStackAI

A microservices banking platform with an AI layer on top: core banking services (customers, accounts, bill pay, settlement) built with Spring Boot + Kafka + Postgres, plus an MCP tool server, a RAG service, and a multi-agent orchestrator built with Spring AI + Ollama.

🔬 Runtime walkthrough — a real bill payment and a real AI-agent request traced hop by hop through the running cluster, with the actual HTTP payloads, Kafka messages, database rows and audit lines at every step.

🧭 Agent gateway flow — how one natural-language message moves through the multi-agent gateway packages, and which parts of that path are harness, which are guardrails, and which are the governed tool boundary.

Architecture

%%{init: {"flowchart": {"rankSpacing": 80, "nodeSpacing": 42, "curve": "basis"}}}%%
flowchart TD
    subgraph Edge["🔐 Identity"]
        AUTH0["Auth0<br/>OAuth2 / JWT"]
    end

    subgraph AI["🧠 AI layer"]
        AGENT["multi-agent :8096"]
        MCP["mcp-server :8095"]
        RAG["rag-service :8098"]
    end

    subgraph Models["🤖 Model runtime"]
        OLLAMA["Ollama<br/>llama3.2 / qwen2.5<br/>nomic-embed"]
    end

    subgraph Core["🏦 Core banking services"]
        PAY["payment-orchestrator :8086"]
        ACCT["account-service :8084"]
        BILLER["biller-service :8088"]
        CUST["customer-service :8083"]
        AUTHU["auth-user :8094"]
        WORKER["billpay-worker :8090"]
        SETTLE["settlement-service :8080"]
    end

    subgraph Infra["🗄️ Infrastructure"]
        KAFKA[("Kafka<br/>billpay.* / bill.batch.*")]
        PG[("Postgres + pgvector<br/>one DB per service")]
    end

    AGENT -->|"MCP (streamable HTTP)"| MCP
    AGENT -->|"chat / extraction"| OLLAMA
    MCP -->|REST| RAG
    RAG -->|"embeddings + chat"| OLLAMA
    RAG -->|"vector search"| PG
    AUTHU ~~~ PG
    %% ^ invisible link: pulls Postgres left so the Infrastructure box
    %%   sits at the bottom middle instead of hugging the right edge

    MCP -->|REST| PAY
    MCP -->|REST| ACCT
    MCP -->|REST| CUST

    PAY -->|REST| BILLER
    PAY -->|REST| ACCT
    ACCT -->|Feign| CUST
    CUST -->|Feign| AUTHU
    AUTHU -->|"Management API"| AUTH0
    AUTH0 -.->|"JWKS: every service validates JWTs"| PAY
    AUTH0 -.-> AGENT

    %% invisible links: rank the leaf services into a second column so the
    %% diagram grows downwards, and keep billpay-worker on the biller/account row
    WORKER ~~~ CUST
    CUST ~~~ SETTLE

    PAY -->|"produce/consume"| KAFKA
    WORKER -->|"consume/produce"| KAFKA
    SETTLE -->|consume| KAFKA
    CUST -->|produce| KAFKA

    classDef box fill:#ece7fb,stroke:#7e6bc4,stroke-width:1px,color:#1b1b2f
    class AGENT,MCP,RAG,OLLAMA,AUTH0,PAY,ACCT,BILLER,CUST,AUTHU,WORKER,SETTLE,KAFKA,PG box

    style Edge fill:#dbeeff,stroke:#63c0f5,stroke-width:2px,color:#1b1b2f
    style AI fill:#ece2f7,stroke:#9f77cd,stroke-width:2px,color:#1b1b2f
    style Models fill:#fbe2e5,stroke:#e26d7a,stroke-width:2px,color:#1b1b2f
    style Core fill:#fdf3d0,stroke:#e9b306,stroke-width:2px,color:#1b1b2f
    style Infra fill:#dcf5da,stroke:#3fd73c,stroke-width:2px,color:#1b1b2f
Loading

Bill-pay flow: payment-orchestrator receives a payment request, emits billpay.requested → billpay-worker enqueues and batches → bill.batch.ready → orchestrator submits the batch to biller-service → bill.batch.submitted → settlement-service settles. Retries / DLQ ride on bill.batch.retry|resubmit|dlq.

AI flow: multi-agent takes a natural-language request, uses Ollama to reason and extract intents, calls tools exposed by mcp-server over MCP, which fans out to the core services; rag-service answers knowledge questions with pgvector hybrid search.

Cross-cutting: the dotted edges from Auth0 stand in for every service — all of them validate incoming JWTs against Auth0's JWKS endpoint via commons-security. Likewise each service owns its own Postgres database; only the shared pgvector store is drawn.

Services

Service Module Port Swagger UI
auth-user AuthUser 8094 http://localhost:8094/swagger-ui/index.html
customer-service CusomerService 8083 http://localhost:8083/swagger-ui/index.html
account-service AccountService 8084 http://localhost:8084/swagger-ui/index.html
payment-orchestrator PaymentOrchestrator 8086 http://localhost:8086/swagger-ui/index.html
biller-service BillerService 8088 http://localhost:8088/swagger-ui/index.html
billpay-worker BillPayWorkerService 8090 http://localhost:8090/swagger-ui/index.html
settlement-service SettlementService 8080 — (no @RestController; Kafka only)
mcp-server BankStackMCPServer 8095 http://localhost:8095/swagger-ui/index.html
multi-agent BankStackMultiAgent 8096 http://localhost:8096/swagger-ui/index.html
rag-service BankStackRag 8098 http://localhost:8098/swagger-ui/index.html

Shared libraries: commons-dto, commons-security (OAuth2 resource-server setup), commons-observability. BankStackEval is an offline evaluation harness; SpringAiOllamaPOC is a scratch POC — neither is deployed.

Local development

Prerequisites: JDK 17, Maven, Docker (OrbStack or Docker Desktop), direnv (loads .env with Auth0 credentials), and Ollama with llama3.2, qwen2.5:1.5b, nomic-embed-text pulled if you want the AI services to answer.

# 1. Infrastructure: Kafka :9092, Postgres (pgvector) :5432, kafka-ui :8079
docker compose up -d

# 2. Build everything (shared libs first — order matters)
./scripts/build-all.sh

# 3. Run any service
cd AccountService && mvn spring-boot:run

Tests (Postgres must be running for the JPA context tests):

for m in */; do (cd "$m" && [ -f pom.xml ] && mvn test); done

Note: VS Code's Java extension used to overwrite Maven's target/classes with its own (broken) builds, which made mvn test fail randomly with "No qualifying bean of type …Mapper". Autobuild is disabled in .vscode/settings.json — leave it off, or run mvn clean test.

Docker & Kubernetes

Each service has a runtime-only Dockerfile that copies the jar built by Maven.

./scripts/build-all.sh          # build jars
./scripts/build-images.sh       # docker build bankstack/<service>:local for all 10 services

Deploy to a local cluster (OrbStack: orb start k8s; also works on minikube/k3s — build or load the images into the cluster's runtime first):

kubectl apply -k k8s/            # namespace, Postgres, Kafka (KRaft), 10 services
./k8s/create-auth0-secret.sh     # bankstack-auth0 secret from .env (auth-user needs it)
kubectl -n bankstack get pods

Details:

  • k8s/infra/postgres.yaml runs pgvector Postgres and creates the per-service databases on first start (mirrors postgres-init.sql).
  • k8s/infra/kafka.yaml runs single-node Kafka in KRaft mode (no ZooKeeper).
  • k8s/infra/kafka-ui.yaml is the browser view of the saga's Kafka side (topics, messages, consumer groups, lag) — the counterpart of the kafka-ui service in docker-compose.yml.
  • The AI services reach Ollama on the host via host.docker.internal:11434.

Ports in the cluster

Every pod gets its own IP, so there is nothing to remap: each service listens on the same port it uses locally, and Postgres and Kafka keep their standard 5432 and 9092. Those ports are reachable only from inside the cluster, by service name — postgres:5432, kafka:9092, http://account-service:8084 — which is why the -prod profiles use DNS names where the dev profiles use localhost.

Nothing is published to the host. To reach a service from Postman, DBeaver or a browser, open a tunnel:

./scripts/port-forward-all.sh    # 9 REST services on their own ports + Postgres on 5433

# or one at a time
kubectl -n bankstack port-forward svc/account-service 8084:8084
kubectl -n bankstack port-forward svc/postgres 5433:5432    # 5433: leave 5432 for docker compose
kubectl -n bankstack port-forward svc/kafka-ui 8079:8080
Target In-cluster address Suggested local port
auth-user auth-user:8094 8094
customer-service customer-service:8083 8083
account-service account-service:8084 8084
biller-service biller-service:8088 8088
payment-orchestrator payment-orchestrator:8086 8086
billpay-worker billpay-worker:8090 8090
settlement-service settlement-service:8080 — (no REST surface)
mcp-server mcp-server:8095 8095
multi-agent multi-agent:8096 8096
rag-service rag-service:8098 8098
Postgres postgres:5432 5433
Kafka kafka:9092 — (advertises kafka:9092; a tunnel is unusable from the host)
kafka-ui kafka-ui:8080 8079

port-forward-all.sh covers the nine REST services plus Postgres on 5433 — the one tunnel that remaps a port, so it does not collide with a docker compose Postgres already on 5432. It runs in the foreground and Ctrl+C closes every tunnel together; to reconnect, just run it again.

If a port is already bound the script skips that one and prints the kill command to free it, rather than letting kubectl fail silently into /dev/null. That happens when a previous run was killed without its trap firing (closing the terminal, kill -9) and orphaned its kubectl children.

Kafka is left out and cannot usefully be added: the broker advertises kafka:9092, which does not resolve outside the cluster, so a tunnel to it is unusable. kafka-ui is left out too — there is no kafka-ui Service in k8s/ today, only the docker compose one on :8079.

Because the cluster runs its own Postgres and Kafka, docker compose up -d is not needed for the k8s path — and running both binds 5432/9092 twice.

CI/CD

One workflow: .github/workflows/ci.yml

  1. build-test — builds all modules in dependency order and runs mvn test for every module against a Postgres service container (every push / PR).
  2. images — on main pushes, builds the 10 service images and pushes them to GHCR as ghcr.io/<owner>/bankstack/<service>:<sha> and :latest.
  3. deploy — applies k8s/ with the freshly pushed image tags via kustomize. Runs only if a KUBE_CONFIG repo secret (base64-free kubeconfig content) is configured; otherwise it is skipped — deploy to the local OrbStack cluster from your machine with the commands above.

📖 Browse the API reference — every service's OpenAPI spec, no setup required.

About

No description, website, or topics provided.

Resources

Stars

3 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages