Core Banking Lab is an engineering sandbox inspired by real-world core banking systems. It explores safe concurrent operations, observability, authentication, CI/CD, and Kubernetes orchestration — simulating high-reliability financial infrastructure.
  • Go 85.7%
  • Shell 8.2%
  • HCL 3.9%
  • PLpgSQL 2.2%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2025-11-02 16:59:27 -03:00
.github/workflows Refactor: Change in-memory DB -> PostgreSQL (#83) 2025-11-02 00:27:15 -03:00
cmd/api refactor: Phase 1 - Restructure project to golang-standards layout 2025-11-01 14:44:34 -03:00
deployments/docker-compose/postgres/init Refactor: Change in-memory DB -> PostgreSQL (#83) 2025-11-02 00:27:15 -03:00
docs Refactor: Change NATS -> Kafka (#84) 2025-11-02 16:39:51 -03:00
infra Improve deployment reliability with health checks and image fallback (#80) 2025-08-14 21:41:55 -03:00
internal Refactor: Change NATS -> Kafka (#84) 2025-11-02 16:39:51 -03:00
k8s Fix StorageClass compatibility for different K8s environments (#81) 2025-08-15 00:53:26 +00:00
monitoring Add new kubernetes metrics and new dashboards (#71) 2025-08-13 03:52:50 +00:00
scripts Refactor: Change NATS -> Kafka (#84) 2025-11-02 16:39:51 -03:00
test Refactor: Change NATS -> Kafka (#84) 2025-11-02 16:39:51 -03:00
.dockerignore Optimize Docker build performance and reduce CI/CD build times (#50) 2025-08-12 15:52:59 -03:00
.gitignore Refactor: Change in-memory DB -> PostgreSQL (#83) 2025-11-02 00:27:15 -03:00
CLAUDE.md Refactor: Change NATS -> Kafka (#84) 2025-11-02 16:39:51 -03:00
docker-compose.yml feat: Enhance Kafka UI configuration with monitoring features 2025-11-02 16:56:13 -03:00
Dockerfile.api Refactor: Change NATS -> Kafka (#84) 2025-11-02 16:39:51 -03:00
go.mod Refactor: Change NATS -> Kafka (#84) 2025-11-02 16:39:51 -03:00
go.sum Refactor: Change NATS -> Kafka (#84) 2025-11-02 16:39:51 -03:00
LICENSE Portfolio-focused documentation simplification (#33) 2025-08-11 02:34:38 -03:00
README.md feat: Enhance Kafka UI configuration with monitoring features 2025-11-02 16:56:13 -03:00
REFACTORING_PLAN.md Refactor: Change NATS -> Kafka (#84) 2025-11-02 16:39:51 -03:00
test-postgres.sh Refactor: Change in-memory DB -> PostgreSQL (#83) 2025-11-02 00:27:15 -03:00

Core Banking Lab

A concurrent banking API demonstrating thread-safe financial operations and production-grade Go architecture.

Go Version License: MIT Tests

What This Demonstrates

This project showcases advanced backend engineering skills through a banking API that handles concurrent financial operations safely:

  • Event-Driven Architecture: Kafka-based async processing with at-least-once delivery
  • Consumer Idempotency: Deterministic deduplication preventing duplicate operations
  • Thread-Safe Concurrency: Deadlock-free money transfers using ordered mutex locking
  • Production Architecture: Clean Diplomat pattern with separated concerns
  • Security Hardening: Rate limiting, input validation, audit logging
  • Comprehensive Testing: 30+ integration tests including idempotency scenarios

Key Technical Achievements

🔒 Concurrency Safety

Implements fine-grained locking strategy with per-account mutexes for all banking operations (deposits, withdrawals, transfers, balance queries). Uses ordered lock acquisition to prevent deadlocks in multi-account operations and atomic read-modify-write cycles to ensure balance consistency across concurrent transactions.

Performance Results: Successfully processed 100+ concurrent operations with zero data races, zero deadlocks, and error rate < 0.001%. Future benchmarking planned to measure peak throughput under production load conditions.

🏗️ Clean Architecture

Follows golang-standards/project-layout with clear separation of concerns:

cmd/api/              # Application entry point
internal/
  ├── api/            # HTTP layer (handlers, middleware, routes)
  ├── domain/         # Business logic (account operations, models)
  ├── infrastructure/ # External systems (database, events)
  ├── config/         # Configuration management
  └── pkg/            # Shared utilities (errors, logging, telemetry)
test/                 # Test suites (integration, unit)
  • Domain Layer: Pure business logic isolated from infrastructure
  • API Layer: HTTP handlers and middleware
  • Infrastructure Layer: Database and event broker adapters
  • Shared Utilities: Reusable components across layers

This ensures the core banking logic remains isolated, testable, and independent of external dependencies.

Quick Start

# Run the API
git clone https://github.com/fandangolas/core-banking-lab.git
cd core-banking-lab
go run cmd/api/main.go

# Or full stack with Docker
docker-compose up --build

Services:

API Example

# Create accounts
curl -X POST http://localhost:8080/accounts -d '{"owner": "Alice"}'
curl -X POST http://localhost:8080/accounts -d '{"owner": "Bob"}'

# Deposit money
curl -X POST http://localhost:8080/accounts/1/deposit -d '{"amount": 10000}'

# Transfer (thread-safe, atomic)
curl -X POST http://localhost:8080/accounts/transfer \
  -d '{"from": 1, "to": 2, "amount": 5000}'

Testing

# Run all tests
go test ./...

# Run unit tests only
go test ./test/unit/...

# Run integration tests only
go test ./test/integration/...

# Test for race conditions
go test -race ./...

# Test specific concurrent scenario
go test ./test/integration/account -run TestConcurrentTransfer

Test Coverage: 43 tests passing covering concurrent operations, error handling, and edge cases.

Stack

  • Backend: Go 1.23 + Gin + Structured Logging
  • Message Broker: Apache Kafka (KRaft mode)
  • Database: PostgreSQL 16 with connection pooling
  • Monitoring: Prometheus + Grafana
  • Infrastructure: Docker + Docker Compose + Kubernetes
  • Testing: Testify + httptest + Concurrent scenarios

Documentation


This project demonstrates production-grade Go development with focus on concurrent programming, clean architecture, and comprehensive testing.