Skip to content

feat: data architecture transformation - event-driven decoupling with shared-events module - #9

Open
devin-ai-integration[bot] wants to merge 2 commits into
mainfrom
devin/1778509610-event-driven-data-arch
Open

devin-ai-integration[bot] wants to merge 2 commits into
mainfrom
devin/1778509610-event-driven-data-arch

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented May 11, 2026

Copy link
Copy Markdown

Summary

Complete data architecture transformation to decouple cross-service data dependencies and introduce event-driven data synchronization across the banking microservices codebase.

Changes

1. New shared-events Maven module (shared-events/)

  • Common Axon Framework event definitions: CustomerCreatedEvent, CustomerUpdatedEvent, AccountCreatedEvent, AccountCreditedEvent, AccountDebitedEvent, AccountTransferredEvent, AccountActivatedEvent, AccountSuspendedEvent, AccountDeletedEvent
  • Shared enums: AccountStatus, Currency, OperationType
  • Base event class with common fields (id, eventDate, eventBy)

2. Removed duplicated customer email from account-service

  • Removed email field from Account entity, AccountAggregate, CreateAccountCommand, AccountCreatedEvent
  • Accounts now reference customers only by customerId
  • Updated AccountEmailCustomerId validation entity to only track customerId
  • Updated AccountCommandRestController to no longer pass email during account creation

3. Refactored notification-service to consume Axon events

  • Added Axon Framework + OpenFeign + JPA dependencies
  • Created AccountEventNotificationHandler that subscribes to all account events via @EventHandler
  • Added CustomerRestClient Feign client to look up customer email from customer-service
  • Added AccountCustomerMapping entity + repository for account-to-customer ID mapping (populated from AccountCreatedEvent)
  • Removed direct REST notification calls from account-service's AccountEventHandlerService
  • Deleted NotificationService, NotificationServiceImpl, NotificationRestClient, NotificationRequestDTO from account-service

4. CustomerEventHandler in account-service

  • New CustomerEventHandler listens for CustomerUpdatedEvent from shared-events
  • Updates account projection timestamps when customer data changes

5. Flyway migration

  • V1__remove_email_from_account.sql removes email column and unique constraint from account tables
  • Configured Flyway with baseline-on-migrate=true for existing databases

6. Updated DTOs and API contracts

  • Account creation API no longer requires/returns email
  • All internal event/command constructors updated to exclude email parameter

7. Comprehensive unit tests (34 tests passing)

  • Updated AccountAggregateTest (8 tests) - removed email from all event/command constructors
  • Updated AccountEventHandlerServiceTest (6 tests) - removed notification service mocks
  • New CustomerEventHandlerTest (2 tests) - tests for customer update projection sync
  • New AccountEventNotificationHandlerTest (8 tests) - tests for all event notification flows including customer lookup, mapping persistence, and error handling

Review & Testing Checklist for Human

  • Verify the Flyway migration V1__remove_email_from_account.sql runs correctly against your database (the DROP COLUMN IF EXISTS syntax is MySQL/MariaDB specific)
  • Verify the shared-events module event class FQCNs are compatible with your Axon Server serialization configuration (if migrating from existing event store data)
  • Test end-to-end flow: create a customer, create an account, verify notification-service receives the event and sends email notification
  • Verify the AccountCustomerMapping in notification-service is correctly populated and used for non-creation events (credit, debit, suspend, etc.)
  • Check that axon.axonserver.enabled configuration is set correctly for your deployment environment

Notes

  • The account-service's internal event classes (in common.event package) are kept for backward compatibility with the Axon event store serialization. The shared-events module provides cross-service event contracts.
  • The local enums in account-service now have conversion methods (toShared()/fromShared()) for interoperability with shared-events enums.
  • The notification-service uses an H2 in-memory database for the AccountCustomerMapping projection - consider switching to a persistent store for production use.
  • Customer-service POM now includes Axon Framework dependency to support publishing CustomerCreatedEvent/CustomerUpdatedEvent in future iterations.

Link to Devin session: https://app.devin.ai/sessions/c77d3461f3134ff08fec52d68f820311
Requested by: @achalc


Devin Review

Status Commit
⚪ Not started

Run Devin Review

💡 Connect your GitHub account to enable automatic code reviews.

Open in Devin Review (Staging)

devin-ai-integration Bot and others added 2 commits May 11, 2026 14:38
- Create shared-events Maven module with common Axon Framework event definitions
  (CustomerCreatedEvent, CustomerUpdatedEvent, AccountCreatedEvent,
  AccountCreditedEvent, AccountDebitedEvent, AccountTransferredEvent,
  AccountActivatedEvent, AccountSuspendedEvent, AccountDeletedEvent)
- Remove duplicated customer email field from Account entity in account-service
- Refactor notification-service to consume Axon events instead of direct REST calls
- Add CustomerEventHandler in account-service for CustomerUpdatedEvent
- Create Flyway migration script for email column removal
- Add Feign client in notification-service to look up customer email
- Add AccountCustomerMapping entity for event-driven email lookup
- Update all affected DTOs and API contracts
- Add comprehensive unit tests (34 total tests passing)
- Remove direct notification REST client coupling from account-service

Co-Authored-By: Achal Channarasappa <achal.channarasappa@cognition.ai>
Co-Authored-By: Achal Channarasappa <achal.channarasappa@cognition.ai>
@devin-ai-integration

Copy link
Copy Markdown
Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant