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

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages