Tasks 2–5: Kafka ingestion, H2/JPA persistence, Incentive API integration, and /balance endpoint #92
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.
Implements Tasks 2–5 of the Forage J.P. Morgan SE simulation by building out Midas Core—a Spring Boot service that ingests, validates, persists, and enriches transactions, and exposes balances via a small read API.
Task 2 – Kafka Integration
Task 3 – H2/JPA Persistence
Task 4 – Incentive REST API
Task 5 – Read API (/balance)
Changes (by area):
Kafka (Task 2):
src/main/java/com/jpmc/midascore/config/KafkaConfig.java
Consumer/producer factories, JSON (de)serializers, and ConcurrentKafkaListenerContainerFactory (topic from application.yml).
src/main/java/com/jpmc/midascore/component/TransactionListener.java
@KafkaListener that receives Transaction and delegates to the service layer (used for TaskTwoTests debugging).
Domain & Persistence (Task 3):
src/main/java/com/jpmc/midascore/service/TransactionService.java
Validation → balance updates → persistence (later extended for Task 4).
src/main/java/com/jpmc/midascore/entity/TransactionRecord.java
JPA entity: sender, recipient (many-to-one), amount, incentive.
src/main/java/com/jpmc/midascore/repository/TransactionRepository.java
Repository for TransactionRecord.
External REST (Task 4):
src/main/java/com/jpmc/midascore/config/RestConfig.java
RestTemplate bean (short timeouts).
src/main/java/com/jpmc/midascore/foundation/Incentive.java
DTO for Incentive API response.
Read API (Task 5):
GET /balance?userId= → returns Balance { amount } JSON.
Config:
Kafka topic property; incentive API URL; JPA/H2 settings; server port for tests.
(Existing scaffold files such as foundation/Transaction.java, foundation/Balance.java, entity/UserRecord.java, repository/UserRepository.java, and MidasCoreApplication.java remain in place.)
Notes: