Problem Statement
Legacy monolithic applications become hard to maintain and update because all features are tightly coupled. Any change risks breaking unrelated parts, and rewriting the entire system at once is risky and costly.
This diagram shows client requests routed through an API Gateway that directs some requests to new microservices and others to the legacy monolith, enabling gradual replacement.
### Before: Monolithic code handling all requests class LegacySystem: def handle_request(self, request): if request.type == 'old_feature': return self.old_feature(request) # All features handled here def old_feature(self, request): # Implementation of old feature return f"Handled {request.type} in legacy system" ### After: Strangler fig pattern with routing class APIGateway: def __init__(self): self.new_service = NewMicroservice() self.legacy = LegacySystem() def handle_request(self, request): if request.type == 'new_feature': return self.new_service.handle(request) else: return self.legacy.handle_request(request) class NewMicroservice: def handle(self, request): # New feature implementation return f"Handled {request.type} in new service" ### Explanation: # Before, the legacy system handled all requests in one place. # After, the API Gateway routes new feature requests to the new microservice, # while legacy requests continue to the old system, enabling gradual migration.