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