Architecture Refactoring of a Consumer Installment System: Background, Goals, Design, Deployment, and Monitoring
This article presents a comprehensive case study of refactoring a consumer installment platform, covering business restructuring, technical debt resolution, design of domain and module layers, code redesign with design patterns, phased deployment, monitoring setup, and the overall benefits achieved.
Background
The business underwent a merger and restructuring, requiring a new architecture to support future product directions. Existing services had become outdated, leading to technical debt, low development efficiency, and insufficient monitoring.
Refactoring Goals
Ensure continuous business operation and iteration.
Improve code structure for easier extension and higher development efficiency.
Gradually replace old interfaces with a new system.
Design
Research : Investigated common microservice architecture solutions and adopted a layered design approach.
Planning : Planned a two‑phase iteration—first refactoring core backend modules, then integrating front‑end changes.
Repairer Model : Adopted a model where the new system isolates legacy edge logic while core code is refactored and gradually takes over via RPC interfaces, minimizing risk.
Domain Design (Horizontal Splitting) : Defined three main domains—Aggregation Business, Basic Services, and Third‑Party Integration—each with clear responsibilities.
Module Design (Vertical Splitting) : Decomposed the installment purchase flow into independent modules (credit, loan, repayment, etc.) following single‑responsibility and dependency‑inversion principles.
Code Design : Replaced a single strategy pattern with a combination of double‑layer templates, strategies, and factories. Example interface and abstract class definitions are shown below.
/**
* 授信接口定义
**/
public interface ICreditService {
/**
* appId,资方定义的一个唯一ID
*/
String getAppId();
/**
* app名称
* @return zz or zlj
*/
String getAppName();
/**
* 获取授信结果
* @return result
*/
CreditResult creditResult(String logStr, Long uid);
} /**
* 标准API对接实现
*/
public abstract class AbstractCreditService implements ICreditService {
protected abstract IBaseApiService getApiThirdService();
@Override
public AppConfig getPartner() {
return commonConfigUtil.getAppConfig(getAppId());
}
@Override
public CreditResult creditResult(String logStr, Long uid) {
CreditResultInput input = new CreditResultInput();
input.setUid(uid);
ResponseProtocol
output = getApiThirdService().creditResult(logStr, input);
String creditStatus = TransformUtil.approvalStatusTransform(output.getData());
return CreditResult.builder().result(creditStatus).build();
}
}Additional interfaces and abstract classes for third‑party integration are also provided, illustrating how to encapsulate partner‑specific logic.
Deployment Process
The migration used a phased approach with one‑way data synchronization, allowing rollback during the gray period to ensure service stability. Two major iteration cycles were executed, each introducing new modules and deprecating old ones.
Monitoring
Implemented alerting via the internal alarm system and Prometheus, complemented by a real‑time dashboard to detect potential issues across modules. Comprehensive logging was also established to facilitate rapid troubleshooting.
Conclusion
The refactoring eliminated technical debt, enhanced system stability, improved user experience, and increased delivery efficiency. It also produced a reusable, portable architecture that can serve as a reliable foundation for future projects.
Architect
Professional architect sharing high‑quality architecture insights. Topics include high‑availability, high‑performance, high‑stability architectures, big data, machine learning, Java, system and distributed architecture, AI, and practical large‑scale architecture case studies. Open to ideas‑driven architects who enjoy sharing and learning.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.