A modern iOS application built using Clean Architecture + MVVM + Domain-Driven Design (DDD).
This project is strictly structured into modular layers. The outermost circle is the App / DI Composition Root, the innermost circle is the Domain layer, with specific features independently owning their logic.
CleanMVVM/
├── App/ <-- Strict Entry Points Only
│ ├── CleanMVVMApp.swift
│ └── ContentView.swift
│
├── DI/ <-- The Composition Root
│ ├── AppDIContainer.swift <-- Global / Shared Dependencies
│ └── ProductListDIContainer.swift<-- Feature Dependencies
│
├── Core/
│ └── Network/ <-- Generic App Infrastructure
│ ├── NetworkManager.swift
│ └── APIEndpoint.swift <-- Only the Protocol lives here
│
└── Features/
├── ProductList/ <-- Feature-Specific Module
│ ├── Domain/
│ │ ├── Entities/
│ │ │ └── Product.swift
│ │ ├── Repository/
│ │ │ └── ProductListRepositoryProtocol.swift
│ │ └── Usecase/
│ │ └── fetchProductListUseCase.swift
│ │
│ ├── Presentation/
│ │ ├── View/
│ │ │ └── ProductListView.swift
│ │ └── ViewModel/
│ │ └── ProductListViewModel.swift
│ │
│ └── Data/
│ ├── API/
│ │ └── ProductListEndpoint.swift <-- Feature specific API
│ ├── DTO/
│ │ └── ProductDTO.swift
│ ├── Mappers/
│ │ └── ProductMapper.swift
│ └── Repository/
│ └── ProductListRepository.swift
│
└── Authentication/ <-- A brand new feature (Example)!
├── Domain/
├── Presentation/
└── Data/
├── Repository/
└── API/
├── LoginEndpoint.swift <-- Implements APIEndpoint
└── RegisterEndpoint.swift <-- Implements APIEndpoint
- App / DI (Composition Root): The only layer that knows about all other features. It wires the network, domain, and data layers together via Dependency Injection containers, allowing the features themselves to remain perfectly decoupled.
- Core: App-wide generic infrastructure. For networking, it provides
APIEndpointandNetworkManagerProtocol, but holds zero knowledge about the business logic (like Products or Users). - Features (Domain-Driven):
- Domain Layer: The heart of the feature. Contains
Entities(internal models),UseCases(business rules), andRepository Protocols. It has zero dependencies on the outside world. - Data Layer: Implements the Domain's Repository protocols. Contains
DTOs(Network decodables),Mappers(translating DTOs into Entities), and FeatureAPIEndpoints(URLs, headers, requests). - Presentation Layer: Contains
Views(UI) andViewModels(State Management). ViewModels communicate exclusively with the Domain layerUseCases.
- Domain Layer: The heart of the feature. Contains