Beyond Decomposition: A LLM-Powered Automated Approach to Refactoring Monoliths Into Microservices
Khaled Sellami, Oussama Jebbar, Ayyoub Gannoun, Mohamed Aymen Saied · 2025
Organizations migrating monolithic applications to microservice architectures often face significant challenges in both decomposition and refactoring phases. While the decomposition step has received considerable automation research, refactoring remains predominantly manual, creating bottlenecks in migration efforts and preventing runtime-based and a more realistic evaluation of decomposition techniques. We propose a fully automated refactoring methodology that complements existing decomposition approaches. Our technique implements an ID-based and DTO-based hybrid design for inter-service communication and leverages Large Language Models (LLMs) for decision making, code analysis and code generation. Taking a monolith's source code and decomposition plan as input, our approach identifies “API classes” that cross service boundaries, selects their appropriate target design among the ID and DTO based methods and then automatically generates the necessary communication components—API contracts, server-side endpoints, and client-side proxies. This approach balances the preservation of the monolith's workflow consistency through the ID-based design and minimizing the overhead and complexity of the cross-service interactions through the DTO-based design. A qualitative evaluation using three benchmark applications demonstrates our approach's feasibility and advantages over related work.