A miniature event-driven transaction processor inspired by Monzo, built with Go, Kafka (RedPanda), Python, and PostgreSQL. Deployed to AWS.
- π― Project Overview
- ποΈ Architecture
- π Project Structure
- π Quick Start
- π Analytics Dashboard
- π οΈ Development Commands
- π Data Models
- π§ Technology Stack
- π Roadmap
- π Learning Goals
- π Resources
- π€ Interview Talking Points
- π Documentation
- π License
- π€ Author
FlowBank demonstrates a distributed system for processing banking transactions using event-driven architecture. Inspired by Monzo's architecture, it showcases modern microservices patterns, real-time data processing, interactive analytics, and fraud detection - all deployed to AWS.
- β‘ Event-Driven Architecture - Asynchronous transaction processing via Kafka
- π Real-Time Analytics Dashboard - Live data visualization
- ποΈ Microservices Design - Independent Go services (Producer, Consumer, API) and a Python fraud detection service
- π Real-Time Fraud Detection - Python FastAPI microservice scoring transactions against three detection rules
- π ACID Transactions - PostgreSQL with row-level locking and atomic updates
- π³ Fully Dockerized - One-command local deployment with Docker Compose
- π Polyglot Architecture - Go and Python microservices working together on the same Kafka topics
- βοΈ Cloud Deployed - Live on AWS Elastic Beanstalk with RDS PostgreSQL and Aiven Kafka
- π Production Patterns - Proper error handling, logging, separation of concerns
ββββββββββββββββ ββββββββββββββββ ββββββββββββββββ
β Producer βββββββββ>β RedPanda βββββββββ>β Consumer β
β (Go) β Publish β (Kafka) β Consume β (Go) β
ββββββββββββββββ ββββββββ¬ββββββββ ββββββββ¬ββββββββ
β β
β Consume βΌ
β ββββββββββββββββ
ββββββββββββββββββ>β Fraud β
β Detection β
β (Python) β
ββββββββ¬ββββββββ
β
βΌ
ββββββββββββββββ ββββββββββββββββ
β Dashboard β<ββββββββββ Query βββββββββββββββββ PostgreSQL β
β (Go API) β β (Storage) β
ββββββββββββββββ ββββββββββββββββ
ββββββββββββββββ ββββββββββββββββ ββββββββββββββββ
β Producer βββββββββ>β Aiven βββββββββ>β Consumer β
β (Go / ECR) β Publish β Kafka β Consume β (Go / ECR) β
ββββββββββββββββ ββββββββ¬ββββββββ ββββββββ¬ββββββββ
β β
β Consume βΌ
β ββββββββββββββββ
ββββββββββββββββββ>β Fraud β
β Detection β
β (Python/ECR) β
ββββββββ¬ββββββββ
β
βΌ
ββββββββββββββββ ββββββββββββββββ
β Dashboard β<ββββββββββ Query βββββββββββββββββ AWS RDS β
β (Go API/ECR) β β PostgreSQL β
ββββββββββββββββ ββββββββββββββββ
All services hosted on AWS Elastic Beanstalk (t3.small EC2)
Container images stored in AWS ECR
Data Flow:
- Producer generates realistic banking transactions every 3 seconds
- Kafka buffers and distributes events across partitions
- Go Consumer validates, processes, and persists to database with overdraft protection
- Python Fraud Detection consumes the same Kafka topic, scores each transaction against three fraud rules, and writes results to the
fraud_scorestable - API serves transaction and fraud score data via REST endpoints
- Dashboard visualizes metrics and flagged transactions in real-time with auto-refresh
flowbank/
βββ cmd/
β βββ producer/ # Generates fake banking transactions
β βββ consumer/ # Processes transactions from Kafka
β βββ api/ # REST API for querying data
βββ internal/
β βββ kafka/ # Kafka producer/consumer helpers + TLS config
β βββ db/ # Database connection and queries
β βββ model/ # Data models (Transaction, User, FraudScore)
β βββ service/ # Business logic layer
βββ fraud-detection/ # Python fraud detection microservice
β βββ app/
β β βββ main.py # FastAPI entry point
β β βββ consumer.py # Kafka consumer logic
β β βββ detector.py # Fraud scoring rules
β β βββ database.py # PostgreSQL connection and writes
β β βββ models.py # Pydantic schemas
β βββ requirements.txt
βββ deploy/
β βββ docker-compose.yml # Local development
β βββ Dockerfile.* # Service Dockerfiles
β βββ init.sql # Database schema
βββ docker-compose.yml # Production (AWS) - uses ECR images
βββ web/
β βββ dashboard.html # Analytics dashboard UI
βββ docs/ # Additional documentation
βββ go.mod
βββ Makefile
βββ README.md
| Endpoint | URL |
|---|---|
| Dashboard | /dashboard |
| API Health | /health |
| Fraud Scores | /api/v1/fraud-scores |
| Analytics | /api/v1/analytics |
See docs/QUICKSTART.md for the full guide. Start there.
- Docker & Docker Compose
- Go 1.26+ (optional, for local development)
- Make (optional, for convenience)
# Clone the repository
git clone https://github.com/IbsYoussef/FlowBank.git
cd FlowBank
# Start all services
make up
# View logs (optional)
make logsLocal Access Points:
- π Dashboard: http://localhost:8080/dashboard
- π₯ API Health: http://localhost:8080/health
- πΎ PostgreSQL:
localhost:5432(user:flowbank_user, pass:flowbank_pass, db:flowbank)
curl http://localhost:8080/health# Coming soon: curl http://localhost:8080/users# Coming soon: curl http://localhost:8080/users/{user_id}/transactions- Open http://localhost:8090
- Navigate to Topics β transactions
- View real-time messages
make ps
# All services should show as "Up" and "healthy"make db-shell
# View users
SELECT * FROM users;
# View recent transactions
SELECT * FROM transactions ORDER BY created_at DESC LIMIT 10;
# Check transaction stats
SELECT status, COUNT(*) FROM transactions GROUP BY status;
# View fraud scores
SELECT * FROM fraud_scores ORDER BY scored_at DESC LIMIT 10;Option A: Dashboard (Recommended)
open http://localhost:8080/dashboardOption B: Producer Logs
make logs-producerOption C: Consumer Logs
make logs-consumerLocal: http://localhost:8080/dashboard Live: flowbank-prod.eba-fcdmxpas.eu-west-2.elasticbeanstalk.com/dashboard
- π 4 Interactive Charts - Transaction type distribution, money flow, top merchants, hourly volume
- π΄ Live Transaction Feed - Real-time updates every 5 seconds
- π¨ Flagged Transactions Panel - Suspicious and high-risk transactions with risk badges
- π° Key Metrics - Total transactions, money in/out, average amount
- π± Responsive Design - Works on desktop, tablet, mobile
| Endpoint | Method | Description |
|---|---|---|
/health |
GET | Service health check |
/api/v1/accounts/{id} |
GET | User account details with balance |
/api/v1/analytics |
GET | Aggregated dashboard analytics |
/api/v1/fraud-scores |
GET | Recent fraud scores with transaction details |
/dashboard |
GET | Analytics dashboard UI |
Example:
# Get user account details
curl http://localhost:8080/api/v1/accounts/a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11 | jq
# Get analytics data
curl http://localhost:8080/api/v1/analytics | jq
# View dashboard in browser
open http://localhost:8080/dashboard| Command | Description |
|---|---|
make help |
Show all available commands |
make deps |
Install Go dependencies |
make build |
Build Docker images |
make up |
Start all services |
make down |
Stop all services |
make restart |
Restart services |
make logs |
Tail logs from all services |
make clean |
Remove containers and volumes |
make db-shell |
Open PostgreSQL shell |
make kafka-topics |
List Kafka topics |
make test |
Run Go tests |
type Transaction struct {
ID uuid.UUID
UserID uuid.UUID
Amount int64 // in cents
Type string // "debit" or "credit"
Description string
MerchantName string
Status string // "pending", "completed", "failed"
CreatedAt time.Time
}type User struct {
ID uuid.UUID
Email string
Name string
Balance int64 // in cents
CreatedAt time.Time
UpdatedAt time.Time
}type FraudScore struct {
TransactionID string
RiskScore string // "low", "medium", "high"
Status string // "clean", "suspicious", "flagged"
TriggeredRules []string // e.g. ["high_frequency", "high_value"]
Confidence float64
ProcessingTimeMs float64
ScoredAt time.Time
}| Component | Technology | Version |
|---|---|---|
| Language (Backend) | Go | 1.26 |
| Language (Fraud Detection) | Python | 3.14 |
| Fraud Detection Framework | FastAPI | 0.136 |
| Messaging (Local) | Kafka / RedPanda | 7.6.1 |
| Messaging (Production) | Aiven Kafka | 4.1 |
| Database (Local) | PostgreSQL | 16 |
| Database (Production) | AWS RDS PostgreSQL | 16 |
| Frontend | Chart.js | 4.4.0 |
| Containerisation | Docker & Compose | Latest |
| Container Registry | AWS ECR | - |
| Hosting | AWS Elastic Beanstalk | - |
- Project structure and Docker setup
- Implement Kafka producer/consumer
- Build transaction generator (Producer)
- Build transaction processor (Consumer)
- Implement REST API endpoints
- Real-time analytics dashboard
- Add validation and business logic
- Add comprehensive logging
- Fraud detection microservice (Python/FastAPI)
- Real-time fraud scoring dashboard panel
- Cloud deployment (AWS Elastic Beanstalk + RDS + Aiven Kafka)
- CI/CD pipeline (GitHub Actions β ECR β Elastic Beanstalk)
- Service status indicators on dashboard
- Data variety improvements (more merchants, realistic fraud scenarios)
- Pagination on transaction and fraud feeds
- Metrics and observability (Prometheus/Grafana)
- Add unit and integration tests
- ECS migration for better container orchestration
This project demonstrates understanding of:
- β Event-Driven Architecture - Asynchronous communication via message queues
- β Microservices Design - Loosely coupled, independently deployable services
- β Polyglot Systems - Go and Python microservices sharing the same Kafka topics
- β Database Transactions - ACID compliance, row-level locking, atomic updates
- β RESTful API Design - Clean endpoints with proper status codes
- β Fraud Detection - Rule-based scoring with duplicate, high-value and frequency detection
- β Data Visualization - Real-time dashboards with Chart.js
- β Docker & Containerisation - Multi-service orchestration
- β Cloud Deployment - AWS Elastic Beanstalk, ECR, RDS
- β Go Best Practices - Project structure, error handling, concurrency
- β Python Best Practices - FastAPI, Pydantic, async patterns
- β SQL Optimisation - Aggregated queries, proper indexing
- RedPanda Documentation
- PostgreSQL Documentation
- FastAPI Documentation
- Go Project Layout
- Aiven Kafka Documentation
- Why event-driven? Decouples services, enables async processing, scales horizontally
- Why Kafka over REST? Buffering, replay capability, better for high throughput
- Why PostgreSQL? ACID compliance crucial for financial data, rich querying
- Why Go? Performance, simple concurrency model, excellent for backend services
- Why a separate Python service? Demonstrates polyglot microservices - the right tool for the right job. Python's ecosystem for data processing and ML is stronger than Go's
- Why FastAPI? Async by default, automatic API docs, Pydantic validation matches the type-safe approach used in Go
- Why additive architecture? Zero changes to existing Go services - new consumer on the same Kafka topic. Shows understanding of open/closed principle
- Three detection rules: Duplicate transactions, high-value threshold, high-frequency - each independently configurable and extensible
- Why Elastic Beanstalk over raw EC2? Managed platform handles scaling, health checks, rolling deployments. Focus on application not infrastructure
- Why ECR? Pre-built images mean the EC2 instance just pulls and runs - no build timeouts or memory pressure on small instances
- Why Aiven Kafka? Managed Kafka avoids running resource-heavy Zookeeper + Kafka containers alongside application services on a single instance
- Why RDS? Managed PostgreSQL with automatic backups, SSL, and failover. Financial data needs durability guarantees
- Cassandra for write-heavy workloads with eventual consistency
- Redis for caching frequently accessed data
- WebSockets for instant dashboard updates (vs 5-second polling)
- gRPC for inter-service communication in production
- Idempotency keys for exactly-once processing
- Dead-letter queues for failed messages
- Circuit breakers for resilience
- Rate limiting and authentication
- Distributed tracing (Jaeger)
- Metrics and alerting (Prometheus/Grafana)
- ML-based fraud scoring to replace rule-based approach
- CI/CD pipeline (GitHub Actions β ECR β Elastic Beanstalk)
- Service status indicators on dashboard
- Data variety improvements (more merchants, realistic fraud scenarios)
- Pagination on transaction and fraud feeds
- ECS migration for better container orchestration
- UI polish and pagination on dashboard scrolling sections (transaction feed, flagged transactions panel)
Start here: docs/QUICKSTART.md
| Document | Description |
|---|---|
| QUICKSTART.md | Get the system running in 5 minutes |
| ARCHITECTURE.md | System design deep dive, local vs production |
| COMMAND-REFERENCE-LIST.md | All make and docker commands |
| DEPENDENCIES.md | Dependency decisions for Go and Python |
| IMPROVEMENTS.md | Planned enhancements and polish items |
This project is licensed under the MIT License - see the LICENSE file for details.
MIT License
Copyright (c) 2026 IbsYoussef
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
IbsYoussef
π GitHub
β Star this repo if you found it helpful!
