Skip to content

[#6] Event Store service: Kafka -> PostgreSQL persistence#118

Merged
igorsatsyuk merged 2 commits into
mainfrom
feature/#6-event-store-service
May 15, 2026
Merged

[#6] Event Store service: Kafka -> PostgreSQL persistence#118
igorsatsyuk merged 2 commits into
mainfrom
feature/#6-event-store-service

Conversation

@igorsatsyuk

@igorsatsyuk igorsatsyuk commented May 15, 2026

Copy link
Copy Markdown
Owner

Description

Implements Event Store Service for issue #6: consumes user.login.events from Kafka and persists immutable events to PostgreSQL audit.events via R2DBC.

What was done

  • Added reactive persistence layer (StoredAuditEvent, StoredAuditEventRepository, EventPersistenceService)
  • Added Kafka consumer (UserLoginEventConsumer) and listener configuration
  • Added SHA-256 hash calculation service for persisted payloads
  • Added/updated service configuration (application.yml, ObjectMapper/Kafka config)
  • Added migration readiness and module documentation (backend/event-store-service/README.md)
  • Added unit + integration tests, including Testcontainers Kafka -> PostgreSQL e2e scenario
  • Marked #6.1#6.5 as completed in GITHUB_ISSUES_PLAN.md

Closes

Checklist

  • Code follows style guidelines
  • Self-review completed
  • Tests added/updated
  • Documentation updated

Testing

mvn -f backend/pom.xml -pl event-store-service test

Copilot AI review requested due to automatic review settings May 15, 2026 11:37

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.yml default JSON type, pom.xml (drop runtime scope on r2dbc-postgresql, add testcontainers:junit-jupiter), README.md, and GITHUB_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.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 17 out of 17 changed files in this pull request and generated no new comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants