Skip to content

Keshavkumar96/Clean-MVVM

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

CleanMVVM

A modern iOS application built using Clean Architecture + MVVM + Domain-Driven Design (DDD).

🏗️ Architecture

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.

Directory Structure

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

Layer Explanation

  • 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 APIEndpoint and NetworkManagerProtocol, 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), and Repository 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 Feature APIEndpoints (URLs, headers, requests).
    • Presentation Layer: Contains Views (UI) and ViewModels (State Management). ViewModels communicate exclusively with the Domain layer UseCases.

About

iOS - SwiftUI application built using clean MVVM architecture

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages