A reliable, scalable Golang backend service managing bank accounts and transactions with ACID consistency, asynchronous processing, and comprehensive testing.
- Create bank accounts with initial balances
- Deposit and withdraw funds asynchronously via Kafka message queue
- Maintain ACID-compliant balances in PostgreSQL
- Store detailed transaction logs in MongoDB
- Horizontal scalability with Kafka-backed transaction processing
- RESTful API endpoints for external interaction
- Comprehensive unit, integration, and feature tests
- Golang for backend service
- PostgreSQL for account balances (ACID)
- MongoDB for transaction logs
- Kafka for asynchronous transaction queuing
- Docker Compose for container orchestration
- migrate/migrate for DB migrations
- Go 1.20+
- Docker & Docker Compose
-
Clone the repo
git clone https://github.com/likhithkp/banking-ledger-service.git cd banking-ledger-service -
Start all services with Docker Compose
docker-compose up --build -d
-
Ensure PostgreSQL, MongoDB, Kafka are healthy. Run DB migrations if needed:
docker compose run --rm migrate
-
API will be available at
http://localhost:3001
.
├── config/ # Environment config
├── db/
│ ├── mongo/ # Mongo connection
│ └── psql/ # Postgres connection + migrations
├── handlers/ # HTTP handlers
├── services/ # Kafka consumer/producer
├── routers/ # Routing logic
├── shared/ # Shared models & utils
├── Dockerfile
├── docker-compose.yml
└── .env
POST /accounts— Create new accountPOST /accounts/{id}/transactions— Submit deposit/withdrawGET /accounts/{id}— Fetch account infoGET /accounts/{id}/transactions— Get account's transaction historyGET /health— Health check
transactions— All deposit/withdraw requests- Producer sends to
localhost:9092orkafka:9092in Docker - Consumer listens in background on app boot
To open Mongo shell inside container:
docker exec -it mongodb mongosh -u admin -p password123 --authenticationDatabase admin- Make sure Kafka is addressed as
kafka:9092inside Docker, notlocalhost:9092 - If DB migrations fail, check that folder
db/psql/migrationsexists with.up.sqland.down.sqlfiles - Clean up orphans with:
docker compose down --remove-orphans
MIT License © 2025 likhithkp