Skip to content

Extract Consumer Service into standalone microservice (strangler fig pattern)#185

Open
devin-ai-integration[bot] wants to merge 1 commit intomasterfrom
devin/1776690094-extract-consumer-service
Open

Extract Consumer Service into standalone microservice (strangler fig pattern)#185
devin-ai-integration[bot] wants to merge 1 commit intomasterfrom
devin/1776690094-extract-consumer-service

Conversation

@devin-ai-integration
Copy link
Copy Markdown

Summary

Extracts the Consumer Service from the FTGO monolith into an independent Spring Boot microservice, following the same strangler fig pattern used for the Restaurant Service extraction. This breaks the direct compile dependency between OrderService and ConsumerService.

Key changes:

  • New ftgo-consumer-service-standalone module: Standalone Spring Boot app (port 8082) with its own Consumer entity, ConsumerRepository, ConsumerService, REST controller (POST /consumers, GET /consumers/{id}, POST /consumers/{id}/validate-order), Flyway migration, Dockerfile, and dedicated MySQL database (ftgo_consumer_service).
  • HTTP proxy in order-service: Replaced the direct ConsumerService Java import in OrderService with a ConsumerServiceProxy interface + ConsumerServiceProxyHttpClient implementation using RestTemplate. The compile project(":ftgo-consumer-service") dependency is removed from ftgo-order-service/build.gradle.
  • Monolith decoupling: ftgo-application no longer imports ConsumerServiceConfiguration; consumer service URL is injected via consumer.service.url property.
  • Infrastructure: Consumer service added to docker-compose.yml with its own container, MySQL schema created in mysql/schema.sql, build script updated.
  • Old ftgo-consumer-service module updated: Gets its own local Consumer/ConsumerRepository copies (previously in ftgo-domain) and switches from DomainConfiguration to CommonConfiguration since those entities were removed from ftgo-domain.

Review & Testing Checklist for Human

  • Money serialization across HTTP boundary: ConsumerServiceProxyHttpClient sends a Money object inside a Map<String, Object> via RestTemplate. The standalone consumer service's ValidateOrderRequest must deserialize this correctly. Verify that the MoneyModule (custom Jackson serializer) is registered in the standalone consumer service's Spring context — the broad @SpringBootApplication(scanBasePackages = "net.chrisrichardson.ftgo") may or may not pick it up. If not, the /validate-order endpoint will fail at runtime with a deserialization error.
  • FtgoApplicationTest viability: The test removed ConsumerServiceConfiguration from its @Import but OrderConfiguration now creates a ConsumerServiceProxyHttpClient bean that needs a running consumer service (or a mock). This test will likely fail in its current form — it may need a test profile that provides a mock ConsumerServiceProxy or an embedded consumer service.
  • Docker Compose end-to-end verification: Spin up docker-compose up, create a consumer via POST :8082/consumers, then create an order via POST :8081/orders and verify the order creation flow calls the consumer service over HTTP successfully. Check container logs for connection errors.
  • ValidateOrderRequest class completeness: Verify it has a no-arg constructor and proper getters/setters for Jackson deserialization (the full class was not visible in the truncated diff).
  • Broad component scan in standalone service: @SpringBootApplication(scanBasePackages = "net.chrisrichardson.ftgo") scans all shared modules. Confirm no conflicting bean definitions or unwanted auto-configurations are picked up.

Recommended test plan: Run docker-compose up --build, wait for health checks to pass, then exercise the full order creation flow (create consumer → create restaurant → create order) and verify the monolith successfully calls the consumer service over HTTP for validation.

Notes

  • The Gradle build succeeds for all modules except ftgo-end-to-end-tests-common, which has a pre-existing dependency resolution failure (eventuate-util-test:0.1.0.RELEASE not found) unrelated to this PR.
  • The JDBC driver class for ftgo-application in docker-compose.yml was updated from com.mysql.jdbc.Driver to com.mysql.cj.jdbc.Driver to match the MySQL 8 connector already in use.
  • Consumer.java and ConsumerRepository.java now exist in both ftgo-consumer-service and ftgo-consumer-service-standalone — this duplication is intentional during the strangler fig transition. The old module remains in the Gradle build but is no longer imported by ftgo-application.

Link to Devin session: https://app.devin.ai/sessions/cbb2c366f0d74cbfb1fe30170cef4647
Requested by: @bcmake

- Create ftgo-consumer-service-standalone module with Spring Boot app
- Move Consumer entity and ConsumerRepository from ftgo-domain to both
  standalone and original consumer-service modules
- Add REST API endpoints: POST /consumers, GET /consumers/{id},
  POST /consumers/{id}/validate-order
- Create ConsumerServiceProxy interface and HTTP client implementation
  in ftgo-order-service to replace direct ConsumerService dependency
- Update OrderService and OrderConfiguration to use proxy
- Remove compile project(':ftgo-consumer-service') from order-service
- Remove consumer-service dependency from ftgo-application
- Add Consumer Service to docker-compose.yml with own MySQL database
- Add Flyway migration for consumers table
- Update end-to-end tests for separate consumer service port
- Add Dockerfile for standalone consumer service
- Update build-and-restart script to include consumer service

Co-Authored-By: benc <Benc@windsurf.com>
@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.

0 participants