aws-event-driven-finops-platform
Banking event mesh on AWS where cost is a requirement, not a report
git clone https://github.com/fernando-moretes/app-aws-event-driven-finops-platform.gitListen to guide
generated on playGenerated only on first play
Powered by Amazon Polly + OmniVoice
A reference architecture for an event-driven banking platform on AWS, where the choice between EventBridge, SQS, Kinesis and MSK is decided by cost, ordering and volume — with event contracts, ADRs, tests for the decision logic and a static frontend on Vercel.
Why this repository exists
After years operating financial platforms on AWS, the question I saw answered wrong most often was not "which event service should we use?" — it was "what does this cost per month when volume doubles, and who operates it when the queue lags?". Most reference diagrams put EventBridge, SQS, Kinesis and MSK side by side as if they were interchangeable. They are not. Each one has a different billing model, a different ordering guarantee and a different operational cost.
This repository models a fictional bank as an event mesh and uses that scenario to make the differences concrete. The domain is deliberately recognizable: AccountOpened, PixPaymentRequested, TransactionAuthorized, FraudRiskScored, StatementGenerated. Every event has a documented contract, and every routing decision has an ADR explaining why that service and not another.
What it is not: a deployable core banking system. It is a reference for making defensible decisions — the Python code tests the service-selection logic, the documentation records the trade-offs, and the frontend in frontend/ presents all of it at finops.moretes.com. If you need a system to actually process Pix payments, this repository shows how to think; it does not ship the system.
What is covered
pytest coverage.docs/architecture.md.The fictional bank's event mesh
How the five domain events flow through the event services, serverless processing, and the state and observability layer.
- EventBridge · roteamento de domínio
- SQS · buffer e desacoplamento
- Kinesis Data Streams · streaming ordenado
- MSK · Kafka alto volume
- Lambda · handlers por evento
- Step Functions · orquestração Pix / fraude
- DynamoDB · idempotência + estado
- CloudWatch + X-Ray · métricas e traces
How service selection works
The core of the repository is the decision rule: given an event with expected volume, ordering requirement and retention, which event service is the cheapest one that still meets the requirement? The answer changes per event, which is why the logic lives in Python with tests, not on a slide.
| Service | Use when | Dominant cost | Trade-off |
|---|---|---|---|
| EventBridge | content-based routing across domains, moderate volume, no strict ordering | per event published | higher latency than a direct queue; no cheap native replay |
| SQS | buffer between producer and consumer, retry and DLQ, ordering only per group (FIFO) | per request | FIFO throughput bounded by MessageGroupId |
| Kinesis Data Streams | per-partition ordering, multiple consumers, replay within retention | per shard-hour | a shard is a fixed cost even with no traffic |
| MSK | sustained high volume, an existing Kafka ecosystem, long retention | per broker-hour + storage | a cluster to operate at 2 AM |
The rule that falls out of this: PixPaymentRequested goes through EventBridge because it must reach several domains; TransactionAuthorized goes to Kinesis because per-account order matters and the volume justifies the shard; MSK only enters when sustained volume makes broker-hours cheaper than shards — and never before, because the cost of operating a Kafka cluster does not show up on the invoice, it shows up on the on-call rotation.
pytest -q validates exactly these decisions. Change an event's expected volume and the test tells you whether the chosen service is still the right one.
Install and use
- 1
Clone and install the Python package
git clone https://github.com/fernando-moretes/app-aws-event-driven-finops-platformand, at the root,python -m pip install -e . pytest. The-einstalls in editable mode so changes to the decision logic show up without reinstalling. - 2
Run the decision-logic tests
pytest -q. This is the repository's real entry point: the tests describe which events go to which service and why. Read them before reading any diagram. - 3
Read the architecture and ADRs
docs/architecture.mdholds the five event contracts and the routing decisions.OPERATIONS.mdcovers GitFlow, Vercel secrets and the security pipeline. - 4
Build the frontend locally
cd frontend && npm ci && npm run lint && npm run build. It is static HTML/CSS/JS — the build exists for lint and packaging, not for a framework. - 5
Deploy to Vercel, if you want
Point a Vercel project at the
frontend/directory. The required secrets and branch flow are inOPERATIONS.md; there is no backend to deploy.
git clone https://github.com/fernando-moretes/app-aws-event-driven-finops-platform
cd app-aws-event-driven-finops-platform
# Lógica de seleção de serviço (Python) / Service-selection logic (Python)
python -m pip install -e . pytest
pytest -q
# Frontend estático para a Vercel / Static frontend for Vercel
cd frontend
npm ci
npm run lint
npm run buildSecurity, observability and pipeline
A banking reference architecture that ignores security and observability is not a reference — it is a drawing. Three decisions in this repository exist so it can be taken seriously by people who work under BACEN, PCI-DSS or LGPD.
Idempotency as the default, not as a patch: every consumer writes an idempotency key to DynamoDB before producing a side effect. In Pix, a redelivered event without that protection becomes a double transfer; in a queue with retry, redelivery is not an exception, it is normal behavior.
End-to-end traceability: X-Ray propagates the trace from PixPaymentRequested to StatementGenerated, through Step Functions. Without it, the 2 AM incident becomes a search across five uncorrelated log groups.
Security in the pipeline, not in review: CodeQL for static analysis, Trivy for vulnerabilities in dependencies and images, Gitleaks for leaked secrets, dependency review and npm audit for the supply chain. The only hard gate is a secret in a commit — the rest informs. The frontend being static and framework-free is not just aesthetics: it shrinks the surface those tools need to watch to a handful of files.
The cost that matters here is the cost of maintaining: every one of those tools produces false positives, breaks on updates and needs someone to read the report. I picked the ones that fit GitHub Actions without their own infrastructure, because a pipeline nobody maintains is worse than none.
What this repository does not deliver
There is no Terraform or CloudFormation that stands up the event mesh in an AWS account. The Python code tests the decision logic; the frontend documents the outcome. If you copy the diagram to production without recalculating volume, retention and shard limits for your case, you will pay for idle Kinesis or operate an MSK that never needed to exist.
Frequently asked questions
Why four event services instead of standardizing on one?
Because standardizing has a cost. A bank that puts everything on MSK pays broker-hours for low-volume events; one that puts everything on EventBridge has no ordering for TransactionAuthorized. The repository exists to show the criteria, not to crown a winner.
Are the banking events real?
The domain is fictional. The names follow Brazilian banking domain-event conventions (Pix, statement, authorization) so the trade-offs are recognizable, but no contract here represents any institution's system.
Why is the frontend plain HTML and not Next.js?
Because the frontend is documentation, not an application. A static site without a framework has fewer dependencies for Trivy and npm audit to flag, builds in seconds and costs zero on Vercel. Adding a framework here would be maintenance cost with no function.
Can I use the decision logic in my project?
Yes, the repository is public. But treat the logic as a starting point: volume thresholds and the price per shard, request and broker change by region and over time. Recalculate with your region's current prices before deciding.
References
Who it is for
Use this repository when: you need to justify the choice between EventBridge, SQS, Kinesis and MSK to whoever signs the invoice, you want an example of event contracts and ADRs in a financial domain, or you are assembling a DevSecOps pipeline for a small project and want to see CodeQL, Trivy and Gitleaks together without dedicated infrastructure. Do not use it as a deployment base: there is no IaC, and the cost thresholds must be recalculated for your region and your volume. The value is in the criteria and the tests that protect them — not in the diagram.
Architecture, AWS, AI and market deep dives — straight to your inbox. Free.
No spam · unsubscribe anytime