Skip to content

Midas Core: Kafka Integration, H2 Persistence, Incentive API & Balance REST Endpoint - #303

Open
ptewary02 wants to merge 1 commit into
vagabond-systems:flowfrom
ptewary02:flow
Open

Midas Core: Kafka Integration, H2 Persistence, Incentive API & Balance REST Endpoint#303
ptewary02 wants to merge 1 commit into
vagabond-systems:flowfrom
ptewary02:flow

Conversation

@ptewary02

Copy link
Copy Markdown

Summary
Integrates Midas Core with Kafka for transaction ingestion, adds H2-backed persistence for users and transactions, integrates the external incentive API, and exposes a REST endpoint for querying user balances.
Changes
Kafka Integration

Added spring-kafka dependency and consumer/producer configuration in application.yml, driven by the general.kafka-topic config value
Implemented TransactionListener, a @KafkaListener that consumes and deserializes incoming messages into Transaction objects

H2 Persistence

Added spring-boot-starter-data-jpa and h2 dependencies with an in-memory H2 datasource
Added TransactionRecord entity with @manytoone relationships to UserRecord for both sender and recipient
Added TransactionRecordRepository
Implemented validation and processing logic in DatabaseConduit.processTransaction():

Validates sender/recipient existence and sufficient sender balance
Adjusts both balances and persists a TransactionRecord on success
Discards invalid transactions with no DB changes

Incentive API Integration

Added Incentive DTO mirroring the incentive API response
Added IncentiveClient, which POSTs validated transactions to http://localhost:8080/incentive via RestTemplate and returns the incentive amount
Extended TransactionRecord with an incentive field
Updated processTransaction() to apply the incentive to the recipient's balance only (not deducted from the sender)

Balance REST API

Added BalanceController exposing GET /balance?userId={id}, returning a serialized Balance
Returns Balance(0) for unknown user IDs
Configured server.port: 33400 so the API runs alongside the Kafka listener in the same Spring Boot application

Testing

Verified via TaskOneTests through TaskFiveTests using the embedded Kafka broker and debugger/log inspection
Incentive API (services/transaction-incentive-api.jar) run locally on port 8080 during Task 5/5 verification

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