Skip to content

refactor(kafka): consolidate configuration and centralize topic registry - #342

Merged
aniebietafia merged 2 commits into
mainfrom
feat/extract_kafka_configuration
Jul 7, 2026
Merged

aniebietafia merged 2 commits into
mainfrom
feat/extract_kafka_configuration

Conversation

@aniebietafia

@aniebietafia aniebietafia commented Jul 7, 2026 •

Copy link
Copy Markdown
Contributor
  • Created com.xtraction.api.core.kafka package for core infrastructure concerns.
  • Implemented SharedKafkaConsumerConfig to manage consumer factories, standard/batch container factories, and exponential backoff error routing.
  • Implemented SharedKafkaProducerConfig for centralized KafkaTemplate.
  • Added KafkaTopicRegistry to standardize all topic names (e.g., xtraction-* prefixes) and rename legacy promo/notification topics.
  • Declared all topic beans centrally via SharedKafkaTopicConfig.
  • Removed duplicate and legacy configurations: KafkaConsumerConfig, KafkaProducerConfig, PaymentKafkaConsumerConfig, KafkaTopicConfig, and PaymentTopicConfig.
  • Refactored all listeners, consumers, producers, and publishers to use the consolidated module.
  • Implemented google Oauth authentication.

Description

Please include a summary of the changes and the related issue/feature request. List any dependencies that are required for this change.

Fixes # (issue)
Close #224

Type of Change

Please mark options that apply:

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Refactoring (code cleanup, formatting, or performance optimizations with no behavior changes)
  • Documentation update
  • Chore / Maintenance (dependencies update, CI config, etc.)

Verification Details

Automated Tests

Describe the tests that you ran to verify your changes (e.g. mvn test).

  • Unit Tests
  • Integration Tests

Manual Verification

Describe any manual testing performed (e.g. API requests tested via Postman/Bruno, console output logs, database verification).

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new compiler warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

Summary by CodeRabbit

  • New Features

    • Added Google OAuth login support, including account linking and first-time sign-up flow.
    • Improved sign-in handling for accounts that use an external login provider.
    • Standardized messaging setup across the app for more reliable background processing.
  • Bug Fixes

    • Updated notification delivery defaults and topic routing for more consistent message handling.
    • Added clearer handling for OAuth-related login errors.

- Created `com.xtraction.api.core.kafka` package for core infrastructure concerns.
- Implemented `SharedKafkaConsumerConfig` to manage consumer factories, standard/batch container factories, and exponential backoff error routing.
- Implemented `SharedKafkaProducerConfig` for centralized KafkaTemplate.
- Added `KafkaTopicRegistry` to standardize all topic names (e.g., `xtraction-*` prefixes) and rename legacy promo/notification topics.
- Declared all topic beans centrally via `SharedKafkaTopicConfig`.
- Removed duplicate and legacy configurations: `KafkaConsumerConfig`, `KafkaProducerConfig`, `PaymentKafkaConsumerConfig`, `KafkaTopicConfig`, and `PaymentTopicConfig`.
- Refactored all listeners, consumers, producers, and publishers to use the consolidated module.
- Implemented google Oauth authentication.

Signed-off-by: aniebietafia <aniebietafia87@gmail.com>
@coderabbitai

coderabbitai Bot commented Jul 7, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

@aniebietafia, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 48 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Free

Run ID: 89fd84a1-199f-4eae-84fa-d958423bf043

📥 Commits

Reviewing files that changed from the base of the PR and between ab0755f and d3e03d7.

📒 Files selected for processing (1)
  • src/test/resources/application-test.properties
📝 Walkthrough

Walkthrough

This PR centralizes Kafka topic configuration into a new KafkaTopicRegistry and shared consumer/producer/topic config classes, removing multiple legacy topic/config classes across billing, integration, and payment modules. It also adds Google OAuth2 login support (provisioning, success/failure handlers, security wiring, new User fields, migration) and updates the CI deploy workflow.

Changes

Kafka Topic Centralization

Layer / File(s) Summary
Registry and shared configs
core/kafka/KafkaTopicRegistry.java, core/kafka/config/SharedKafkaConsumerConfig.java, SharedKafkaProducerConfig.java, SharedKafkaTopicConfig.java
New centralized topic constants, retry/DLQ helpers, and shared consumer/producer/topic Spring configurations.
Removed legacy configs
PaymentTopicConfig.java, PaymentKafkaConsumerConfig.java, KafkaTopicConfig.java, KafkaConsumerConfig.java
Deleted duplicate topic/consumer configuration classes superseded by the registry.
Billing/payment wiring
PaymentEventListener.java, PaymentEventPublisher.java, ReceiptEventPublisher.java, ReceiptMessageListener.java, PromoCodeGeneration*.java
Listeners/publishers switched to registry constants and shared batch container factory.
Extraction/search wiring
OcrEventPublisher.java, OcrMessageListener.java, ElasticsearchIndexConsumer.java, ElasticsearchEventPublisher.java, VisionOcrEventPublisher.java
Topic references updated to registry constants.
Integration/notification/user wiring
EmailKafkaConsumer.java, EventPublisherService.java, KafkaErrorHandler.java, *ProducerService.java, NotificationConfig.java, NotificationKafkaConsumer.java, UserEventListener.java, application-example.properties
Topics/default values updated to registry constants and new naming.

Google OAuth2 Login

Layer / File(s) Summary
Data types, error code, migration
AuthProvider.java, GoogleOAuth2UserInfo.java, OAuth2Properties.java, ErrorCode.java, V63__add_oauth_fields_to_users.sql
New OAuth provider types, OAUTH_ACCOUNT error code, and DB migration for auth fields.
User model/repository
User.java, UserRepository.java
New auth fields, relaxed constraints, provider-aware isEnabled(), new lookup method.
Provisioning service
OAuth2UserProvisioningService.java, OAuth2UserProvisioningImpl.java
Provision/link/create logic with post-creation side effects.
Service and handlers
CustomOAuth2UserService.java, OAuth2AuthenticationSuccessHandler.java, OAuth2AuthenticationFailureHandler.java
Google attribute mapping, JWT/cookie issuance, redirect handling.
Security wiring and login guard
SecurityConfig.java, LoginUserImpl.java
OAuth2 login configuration, endpoint permits, session policy change, OAuth-only account guard.

Miscellaneous

Layer / File(s) Summary
CI deploy workflow split
.github/workflows/deploy.yml
Splits build and deploy into separate jobs with job outputs.
Ignore/task file cleanup
.gitignore, .agents/task.md
Ignores .agents directory; clears prior task checklist.

Estimated code review effort: 4 (Complex) | ~75 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant SecurityConfig
  participant CustomOAuth2UserService
  participant OAuth2UserProvisioningImpl
  participant OAuth2AuthenticationSuccessHandler
  Client->>SecurityConfig: initiate Google OAuth2 login
  SecurityConfig->>CustomOAuth2UserService: loadUser(OAuth2UserRequest)
  CustomOAuth2UserService->>OAuth2UserProvisioningImpl: provisionOAuth2User(GoogleOAuth2UserInfo)
  OAuth2UserProvisioningImpl-->>CustomOAuth2UserService: User (provisioned/linked)
  CustomOAuth2UserService-->>SecurityConfig: OAuth2User
  SecurityConfig->>OAuth2AuthenticationSuccessHandler: onAuthenticationSuccess
  OAuth2AuthenticationSuccessHandler-->>Client: redirect with access token and refresh cookie
Loading
sequenceDiagram
  participant Publisher
  participant KafkaTopicRegistry
  participant Kafka
  participant Consumer
  Publisher->>KafkaTopicRegistry: resolve topic constant
  Publisher->>Kafka: send message to resolved topic
  Consumer->>KafkaTopicRegistry: resolve topic constant for `@KafkaListener`
  Kafka->>Consumer: deliver message
Loading

Related issues: None referenced in the provided diff.

Related PRs: None referenced in the provided diff.

Suggested labels: kafka, oauth2, security, database-migration, ci

Suggested reviewers: Backend maintainers familiar with Kafka messaging and Spring Security OAuth2 configuration.

Poem
A rabbit hopped through topics old,
Renamed each one in registry gold.
Then Google waved and said "log in!"
Tokens baked in cookies, crisp and thin.
Migration hums, new columns bloom—
Hop, hop, deploy job leaves the room. 🐇


Note

🎁 Summarized by CodeRabbit Free

Your organization is on the Free plan. CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please upgrade your subscription to CodeRabbit Pro by visiting https://app.coderabbit.ai/login.

Comment @coderabbitai help to get the list of available commands.

…o the end of test configuration file

Signed-off-by: aniebietafia <aniebietafia87@gmail.com>
@github-actions github-actions Bot added the tests label Jul 7, 2026
@aniebietafia
aniebietafia merged commit 6e75e70 into main Jul 7, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

1 participant