[#6] Event Store service: Kafka -> PostgreSQL persistence#118
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
Implements Issue #6 by adding a Kafka → PostgreSQL persistence pipeline to event-store-service. The service consumes user.login.events from Kafka, maps AuditEvents into a StoredAuditEvent JPA-like R2DBC entity (with a SHA-256 payload hash and stable event_hash/event_id), and writes them to the audit.events table via Spring Data R2DBC. An end‑to‑end Testcontainers integration test plus focused unit tests are added.
Changes:
- Add Kafka listener (
UserLoginEventConsumer), persistence service (EventPersistenceService), SHA-256 hashing service, R2DBC entity/repository, and Kafka/Jackson configuration. - Add unit tests for hashing, persistence mapping, consumer dispatch, and a Kafka↔PostgreSQL Testcontainers integration test.
- Update
application.ymldefault JSON type,pom.xml(drop runtime scope onr2dbc-postgresql, addtestcontainers:junit-jupiter),README.md, andGITHUB_ISSUES_PLAN.md.
Reviewed changes
Copilot reviewed 17 out of 17 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| GITHUB_ISSUES_PLAN.md | Mark Issue #6 subtasks as done. |
| backend/event-store-service/pom.xml | Promote r2dbc-postgresql to compile scope; add Testcontainers JUnit Jupiter dependency. |
| backend/event-store-service/README.md | New module documentation covering run & test commands. |
| backend/event-store-service/src/main/resources/application.yml | Switch Kafka default JSON type from abstract AuditEvent to UserLoggedInEvent. |
| backend/event-store-service/src/main/java/.../EventStoreServiceApplication.java | Enable Kafka listeners via @EnableKafka. |
| backend/event-store-service/src/main/java/.../config/JacksonConfig.java | Provide a configured ObjectMapper bean. |
| backend/event-store-service/src/main/java/.../config/KafkaListenerConfig.java | Define explicit consumer factory and listener container factory. |
| backend/event-store-service/src/main/java/.../config/KafkaTopicsProperties.java | Configuration-properties holder for topic names (currently unused). |
| backend/event-store-service/src/main/java/.../consumer/UserLoginEventConsumer.java | @KafkaListener that delegates to persistence service. |
| backend/event-store-service/src/main/java/.../model/StoredAuditEvent.java | R2DBC entity mapped to audit.events. |
| backend/event-store-service/src/main/java/.../repository/StoredAuditEventRepository.java | Reactive CRUD repository. |
| backend/event-store-service/src/main/java/.../service/EventHashService.java | SHA-256 hex digest helper. |
| backend/event-store-service/src/main/java/.../service/EventPersistenceService.java | Maps events to entities, retries, dedupes duplicates, persists. |
| backend/event-store-service/src/test/java/.../service/EventHashServiceTest.java | Unit test for SHA-256 output. |
| backend/event-store-service/src/test/java/.../service/EventPersistenceServiceTest.java | Unit tests for mapping and duplicate-key handling. |
| backend/event-store-service/src/test/java/.../consumer/UserLoginEventConsumerTest.java | Consumer dispatch unit tests. |
| backend/event-store-service/src/test/java/.../EventStoreKafkaToPostgresIntegrationTest.java | Testcontainers-based Kafka→PostgreSQL integration test. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This was referenced May 15, 2026
This was
linked to
issues
May 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Implements Event Store Service for issue #6: consumes
user.login.eventsfrom Kafka and persists immutable events to PostgreSQLaudit.eventsvia R2DBC.What was done
StoredAuditEvent,StoredAuditEventRepository,EventPersistenceService)UserLoginEventConsumer) and listener configurationapplication.yml, ObjectMapper/Kafka config)backend/event-store-service/README.md)#6.1–#6.5as completed inGITHUB_ISSUES_PLAN.mdCloses
Checklist
Testing
mvn -f backend/pom.xml -pl event-store-service test