Technical Refactoring of ZhiZhi Consumer Installment System: Architecture, Design, and Implementation
This article details the background, goals, design decisions, code architecture, deployment process, monitoring setup, and outcomes of a comprehensive backend refactoring effort for the ZhiZhi consumer installment platform, illustrating how modularization, design patterns, and incremental migration improve maintainability and performance.
Background : Rapid product iteration and business restructuring at ZhiZhi consumer installment revealed technical debt, weak module boundaries, monolithic code, and insufficient monitoring, prompting the need for a new architecture to support future growth.
Refactor Goals : Ensure uninterrupted business operation, improve code structure for extensibility and developer efficiency, and gradually replace legacy interfaces with a new system.
Design :
Research : Investigated common fintech architecture patterns and adopted a layered approach.
Planning : Split the migration into two iterations—first refactoring core backend modules, then integrating frontend changes.
Fixer Mode : Maintained legacy edge logic while isolating core code for migration, using RPC interfaces to transition responsibilities with minimal risk.
Domain Design (Horizontal Split) : Defined three main domains—Aggregation Business, Base Services, and Third‑Party Integration—each with clear responsibilities.
Module Design (Vertical Split) : Decomposed the installment purchase flow into independent modules (credit acquisition, usage, repayment) following single‑responsibility and dependency‑inversion principles.
Code Design : Applied a combination of template, strategy, and factory patterns to separate base services from third‑party adapters. Key interfaces and abstract classes were introduced to standardize credit services.
Key code snippets:
/**
* 授信接口定义
*/
public interface ICreditService {
/** appId,资方定义的唯一ID */
String getAppId();
/** app名称 */
String getAppName();
/** 获取授信结果 */
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<CreditResultOutput> output = getApiThirdService().creditResult(logStr, input);
String creditStatus = TransformUtil.approvalStatusTransform(output.getData());
return CreditResult.builder().result(creditStatus).build();
}
} /**
* 标准API对接
*/
public interface IBaseApiService {
/** 获取appId */
String getAppId();
/** 获取授信结果 */
ResponseProtocol<CreditResultOutput> creditResult(CreditResultInput input);
} /**
* 合作方,标准API对接实现
*/
public abstract class AbstractBaseApiService implements IBaseApiService {
@Override
public ResponseProtocol<CreditResultOutput> creditResult(CreditResultInput input) {
// 通用加解密
return getDataResponse(logStr, getAppConf().getUrl4CreditResult(), input, CreditResultOutput.class);
}
}Deployment Process : Adopted a phased rollout with one‑way data synchronization, allowing gradual deprecation of the old system and safe rollback during gray releases.
Monitoring : Integrated ZhiZhi alert mechanisms and Prometheus dashboards to track module health and log activity for rapid issue diagnosis.
Conclusion : The refactor eliminated technical debt, enhanced system stability, improved user experience, and increased delivery efficiency, while delivering a modular, reusable architecture that can serve as a reference solution for similar fintech projects.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Zhuanzhuan Tech
A platform for Zhuanzhuan R&D and industry peers to learn and exchange technology, regularly sharing frontline experience and cutting‑edge topics. We welcome practical discussions and sharing; contact waterystone with any questions.
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.
