Skip to content

Extract Restaurant Service into independent microservice#186

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

Extract Restaurant Service into independent microservice#186
devin-ai-integration[bot] wants to merge 1 commit intomasterfrom
devin/1776690005-extract-restaurant-service

Conversation

@devin-ai-integration
Copy link
Copy Markdown

Summary

Extracts the Restaurant Service from the FTGO monolith into a standalone Spring Boot microservice with its own database, replacing direct in-process JPA access from the Order Service with HTTP REST calls.

New module: ftgo-restaurant-service-standalone

  • Spring Boot application (RestaurantServiceMain) on port 8085
  • Own domain entities (Restaurant, RestaurantMenu, MenuItem) copied from ftgo-domain
  • REST controller exposing POST /restaurants and GET /restaurants/{id} (includes menu items + address in response)
  • Own Flyway migration (V1__create_restaurant_db.sql) for restaurants and restaurant_menu_items tables
  • Dockerfile for containerized deployment
  • Dedicated MySQL database (ftgo_restaurant)

Order Service decoupling:

  • OrderService now uses RestaurantServiceClient (RestTemplate-based HTTP client) instead of RestaurantRepository
  • Order entity: replaced @ManyToOne Restaurant with plain Long restaurantId + String restaurantName fields
  • New DTOs: RestaurantDTO, MenuItemDTO in order service for HTTP communication
  • Flyway V3 migration: adds restaurant_name column to orders, backfills from restaurants table, drops FK constraint

Infrastructure:

  • Docker Compose: new ftgo-restaurant-service container, ftgo-application depends on it and receives RESTAURANT_SERVICE_URL env var
  • MySQL init: creates ftgo_restaurant database
  • build-and-restart-application.sh now builds both services
  • End-to-end tests route /restaurants calls to the standalone service port (8085)

Monolith cleanup:

  • ftgo-application no longer imports RestaurantServiceConfiguration
  • ftgo-application/build.gradle removes ftgo-restaurant-service dependency

Review & Testing Checklist for Human

  • DistanceOptimizedCourierAssignmentStrategy is now permanently degraded: the removal of order.getRestaurant() calls means restaurantLat/restaurantLng are always null, so distance-based courier assignment is effectively disabled — all assignments fall through to load-balanced. Decide whether this regression is acceptable or if restaurant location should be passed through another mechanism (e.g., stored on Order, or fetched via HTTP).
  • Flyway V3 migration assumes FK constraint is named orders_restaurant_id: verify this matches the actual constraint name created by V1. If it doesn't match, the migration will fail at deploy time.
  • JSON serialization of Money type across the HTTP boundary: RestaurantDTO/MenuItemDTO use Money for price. Verify the standalone service serializes Money the same way the order service deserializes it (both need MoneyModule registered, or compatible JSON shape).
  • OrderService.estimateDeliveryTime() now makes a synchronous HTTP call to the Restaurant Service on every invocation. Previously this was an in-memory entity access. Consider latency impact and failure handling (currently wraps in a generic RuntimeException).
  • Old ftgo-restaurant-service library module still exists in settings.gradle and still depends on ftgo-domain Restaurant entities. The entities were copied to the standalone module but not removed from ftgo-domain. This is intentional to keep the old module compiling, but creates duplicated domain code.

Recommended test plan:

  1. Run docker-compose up and verify both ftgo-application (8081) and ftgo-restaurant-service (8085) start successfully
  2. POST /restaurants to port 8085, then GET /restaurants/{id} — confirm menu items and address are returned
  3. Create an order via port 8081 referencing the restaurant — confirm the order is created and restaurantName is populated
  4. Verify GET /orders/{id} returns restaurantName correctly
  5. If an existing database exists, verify the V3 Flyway migration runs cleanly (especially the DROP FOREIGN KEY statement)

Notes

  • The end-to-end test module has a pre-existing dependency resolution failure (eventuate-util-test:0.1.0.RELEASE not found due to JCenter shutdown), so test compilation could not be fully verified.
  • All main source and order-service test code compiles successfully (./gradlew compileJava passes when excluding end-to-end test modules).

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

- Create ftgo-restaurant-service-standalone module with Spring Boot app,
  own domain entities, REST controller, Flyway migrations, and Dockerfile
- Replace direct RestaurantRepository usage in OrderService with HTTP
  RestaurantServiceClient calling Restaurant Service REST API
- Replace @manytoone Restaurant FK in Order entity with plain restaurantId
  and restaurantName fields
- Add Restaurant Service to Docker Compose with dedicated database
- Add Flyway migration V3 to drop FK constraint and add restaurant_name
- Update ftgo-application to remove restaurant service aggregation
- Update end-to-end tests to support separate restaurant service port
- Update build-and-restart script to include restaurant service
- Update MySQL init to create ftgo_restaurant database
- Update test mothers to use DTOs instead of domain entities

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