GithubHelp home page GithubHelp logo

architectureexample's Introduction

Architecture Example

Diagram

Diagram

Diagram illustrates how we can separate Core Domain from API, Presentation and UI. Basically, Domain serves as a main layer for any feature (a.k.a business logic that is platform-agnostic).

API is in turn business logic that is platform-specific (i.e. it depends on Foundation, but Core Domain does not depend on anything). Note here that APIClient lives inside API along with RemoteUserLoader and UserMapper since we do not want to depend on other modules (invert the dependency) and force infrastructure components to be plugged-in.

Infrastructure components live at the boundary of the system. It could be URLSession/Alamofire/Any implemention you prefer. Frameworks are just plug-ins and we can easily replace them without affecting the rest of the system.

Presentation is used for not letting UI to depend on Domain. Presentation layer is mainly used for separating UI from domain models (models that have identity, i.e. id property, but UI does not care about that). Thus, Presentation layer simply includes everything UI needs to render (string text and etc).

UI is last piece in the chain and can be swapped easily (since no other layers depend on it). This diagram shows UIKit view controller shown, but the repository includes UserDetailsView which is a SwiftUI view. We can easily swap UIKit for SwiftUI without again not affecting the rest of the systme.

Composition Root is the most important glue part that bridges communication between domain, services and UI. UserViewAdapter is solely responsible for mapping User models into UserItem value objects. Thus, modules stay separated and can be moved to separate frameworks easily if needed. UserFactory just composes the entire object graph, while SceneDelegate uses the static factory to set push the controller to the navigation stack.

architectureexample's People

Contributors

babaev-islom avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.