feat: add validation-service microservice#30
Open
devin-ai-integration[bot] wants to merge 1 commit into
Open
Conversation
…count-service - Scaffold validation-service with Spring Boot 3.3.13, Java 21 - Create validation endpoints for ticker, account, person, and trade-order - Modify trade-service to delegate validation to validation-service - Modify account-service to delegate person validation to validation-service - Update docker-compose.yml with validation-service container - Update nginx ingress config with validation-service proxy - Update C4 architecture diagram with validation-service - Add unit and integration tests for validation-service - Add controller test for trade-service Co-Authored-By: mason.batchelor <masonbatchelor81@gmail.com>
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
feat: add validation-service microservice to centralize validation logic
Summary
Extracts validation logic from
trade-service(validateTicker,validateAccount) andaccount-service(validatePerson) into a newvalidation-servicemicroservice (port 18094). Both consuming services now delegate to validation-service via REST instead of calling downstream services directly.New service:
validation-service/— Spring Boot 3.3.13, Java 21, exposes:GET /validate/ticker/{ticker}— validates against reference-data serviceGET /validate/account/{id}— validates against account-serviceGET /validate/person?username={username}— validates against people-servicePOST /validate/trade-order— combined ticker + account validationModified services:
trade-service— removed validation methods, now calls/validate/trade-orderaccount-service— removedvalidatePerson, now calls/validate/personInfrastructure:
docker-compose.yml— added validation-service container, updated service dependenciesingress/nginx.traderx.conf.template— added/validation-service/proxy routedocs/c4/c4-diagram.dsl— added validationService container and updated relationshipsTests:
Builds pass:
./gradlew buildsucceeds for both validation-service and trade-service.Local Testing Results
All 11 containers start successfully with
docker-compose up --build, including the newvalidation-serviceon port 18094.Validation-service endpoints verified via curl:
GET /validate/ticker/AAPL→{"valid":true,"errors":[]}GET /validate/ticker/INVALID_TICKER→{"valid":false,"errors":["INVALID_TICKER not found in Reference data service."]}POST /validate/trade-orderwith both invalid ticker and account → collects all errors correctlylocalhost:8080/validation-service/routes correctly to validation-serviceSwagger UI loads at
http://localhost:18094/swagger-ui.html:Recording of local testing session:
View original video (rec-d26ddedea55c4d329844ce742563c229-edited.mp4)
Note: The Angular frontend has a pre-existing build error (
TS2345inassign-user.component.ts) unrelated to this PR. All backend services start and function correctly.Review & Testing Checklist for Human
TradeOrderController.javaline ~50: ifrestTemplate.postForObject()returns null,validationResult.getErrors()will NPE in the else branch. Should add null-safe handling.TradeOrderControllerandAccountUserControllermake REST calls to validation-service with no try-catch. If validation-service is unreachable, unhandledRestClientException→ 500 error. Consider adding resilience (circuit breaker, fallback, or graceful error).Map<?, ?>for validation result — Instead of a typed DTO like trade-service'sValidationResult, account-service deserializes the response asMap.class. This is fragile—consider adding aValidationResultDTO to account-service as well.Recommended Test Plan
docker-compose up(verified—all services start)Notes
PersonValidationServiceTestusesMockRestServiceServerwhileTickerValidationServiceTestandAccountValidationServiceTestuse@Mock/@InjectMocks. All build/pass but worth standardizing in future refactoring.