Codenic Clean Architecture
  • Introduction
  • The Clean Architecture
    • Presentation Layer
    • Domain Layer
    • Infrastructure Layer
  • Tutorial
    • Overview
    • Creating a Flutter Modular Project
      • Tips for Managing a Modular Project
    • Implementing the Domain Layer
      • Core Dependencies
      • Creating an Entity
      • Creating a Failure
      • Creating a Repository Interface
      • Creating Use Cases
        • CRUD Operations (Runner)
        • Data Streams (Watcher)
    • Implementing the Infrastructure Layer
      • External Dependencies
      • Creating a Data Model
      • Creating a Data Source
      • Implementing a Repository
    • Implementing the Presentation Layer
      • External Dependencies
      • Dependency Injection and Service Locator
      • Widgets
        • Snackbar Handler
        • Global Blocs Widget
        • Note Widgets
  • Packages
    • Codenic Bloc Use Case
      • Runner
      • Watcher
    • Codenic Logger
      • Usage
      • Example
      • Modifying the Logger
      • Integrating Firebase Crashlytics to the logger
    • Codenic Exception Converter
      • Failure Object
      • Exception Converter
      • Exception Converter Suite
      • Example
Powered by GitBook
On this page
  • Data Source
  • Models
  • Repository (Implementation)
  1. The Clean Architecture

Infrastructure Layer

This infrastructure layer deals with the APIs, databases and other infrastructure-related dependency integrations in the system.

PreviousDomain LayerNextOverview

Last updated 2 years ago

Data Source

A Data Source represents a remote or local data storage within the system, such as a Database, Rest API or local files. They accept and return data in the form of Models which are specific to the Data Source.

Models

A Model, also referred to as a Data Transfer Object (DTO), is a data representation for a particular Data Source. They are translated into to make them comprehensible to the application. Alternatively, Entities are converted into Models when it needs to be processed by the target Data Source.

Repository (Implementation)

The Repository Implementation provides the logic implementation for the , which defines the functions and capabilities of a specific data repository. It is responsible for managing the data and ensuring that it is properly formatted and structured for use in the application.

Among its main tasks is to manage the in-flow and out-flow of data between Data Source and the application, ensuring that the Data Source Models are converted into and vice-versa, and every exception encountered is converted into their respective objects.

Why do we need to convert Models into Entities and Exceptions into Failures?

Essentially, this is to decouple the from the Infrastructure Layer.This helps to ensure that the Presentation Layer is independent of the specifics of the Infrastructure Layer, making the application more flexible and adaptable to change.

For example, if we need to make changes to the Infrastructure Layer, such as switching from one database to another, the data models and exceptions provided by the new database may change. By converting these models and exceptions into Entities and Failures, respectively, we can ensure that these changes are contained within the Infrastructure Layer and do not affect the Presentation Layer.

Presentation Layer
Entities
Repository Interface
Entities
Failure