The Clean Layer Architecture: Applying Software Engineering Principles to Machine Learning Systems

Mohamed S. Sarhan · Zenodo (CERN European Organization for Nuclear Research) · 2026

As Machine Learning (ML) models and Artificial Intelligence (AI) systems grow in complexity, they increasingly suffer from architectural entanglement, often resulting in tightly coupled "spaghetti code." This lack of structural organization hinders scalability, security, and maintainability. This paper introduces the Clean Layer architecture, a novel framework that adapts core software engineering paradigms—most notably the separation of concerns—to AI system design. By decoupling AI architectures into distinct, purpose-driven layers (such as Programming, Knowledge, and Security), the framework ensures high modularity. Furthermore, we propose the "Fractal Layering Principle," which recursively applies this clean structure within individual components, integrating semantic search, dynamic caching, and logical composition. The Clean Layer approach significantly reduces systemic complexity, enhances model interpretability, and provides a robust foundation for developing scalable and secure AI applications.

Read the paper · More papers on PaperTik