BackendForFintech
Event-Driven Systems

Event-Driven Architecture for Payments & Lending Platforms

12 min readEvent-Driven Systems2024-04-15

Event-driven architecture decouples services and enables audit streams, replay, and new consumers without changing producers. This note covers when to use it, topic design, versioning, and scaling.

Event-driven architecture
Event Bus (Kafka)Topics • Partitions • Consumer GroupsPayment ServiceProducerWallet ServiceProducerLedger ServiceProducerNotificationsConsumerFraud PipelineConsumerAudit / ReportingConsumerpublishsubscribe

When to use event-driven systems

Use events when multiple consumers need the same data asynchronously (e.g. ledger, notifications, fraud, reporting). Use when you need replay or audit. Avoid for strictly synchronous, consistency-critical paths (e.g. the first debit commit).

Topic structuring

One topic per aggregate or event type (e.g. payments.transaction.completed, ledger.entry.recorded). Partition by key (e.g. account_id) so order is preserved per key. Keep topics focused so consumers can subscribe only to what they need.

Event versioning

Add a version field to event payloads. Consumers handle multiple versions or reject unknown versions. Prefer additive changes; avoid breaking changes. Document schema evolution.

Consumer groups

Scale consumers horizontally with consumer groups. Each partition is consumed by one member. Process idempotently so replay and retries do not duplicate side effects.

Scaling patterns

Add partitions to increase throughput; add consumer instances to process in parallel. Retain events for replay and audit; compact or archive by policy. Monitor lag and dead-letter queues.

Book Architecture Strategy Call

Schedule a call →