Skip to content

Architecture Overview

Dustin Catap edited this page Jun 19, 2024 · 6 revisions

The project is structured based on the Clean Architecture principles and from @ResoCoder's Flutter TDD Clean Architecture explanation. It provides a clear and modular structure for building applications by dividing them into distinct layers.

Loading
graph TD
  common["common"]
  common_localization["localization"]
  common_resources["resources"]
  common_utils["utils"]

  core["core"]
  core_data["data"]
  core_domain["domain"]
  core_infrastructure["infrastructure"]
  core_presentation["presentation"]

  features["features"]
  feature1["feature1"]
  feature1_data["data"]
  feature1_data_local["local"]
  feature1_data_remote["remote"]
  feature1_data_repositories["repositories"]
  feature1_domain["domain"]
  feature1_domain_mappers["mappers"]
  feature1_domain_models["models"]
  feature1_domain_services["services"]
  feature1_presentation["presentation"]
  feature1_presentation_views["views"]
  feature1_presentation_view_models["view_models"]

  feature2["feature2"]
  feature2_data["data"]
  feature2_data_local["local"]
  feature2_data_remote["remote"]
  feature2_data_repositories["repositories"]
  feature2_domain["domain"]
  feature2_domain_mappers["mappers"]
  feature2_domain_models["models"]
  feature2_domain_services["services"]
  feature2_presentation["presentation"]
  feature2_presentation_views["views"]
  feature2_presentation_view_models["view_models"]

  common-->common_localization
  common-->common_resources
  common-->common_utils

  core-->core_data
  core-->core_domain
  core-->core_infrastructure
  core-->core_presentation

  features-->feature1
  feature1-->feature1_data
  feature1_data-->feature1_data_local
  feature1_data-->feature1_data_remote
  feature1_data-->feature1_data_repositories
  feature1-->feature1_domain
  feature1_domain-->feature1_domain_mappers
  feature1_domain-->feature1_domain_models
  feature1_domain-->feature1_domain_services
  feature1-->feature1_presentation
  feature1_presentation-->feature1_presentation_views
  feature1_presentation-->feature1_presentation_view_models

  features-->feature2
  feature2-->feature2_data
  feature2_data-->feature2_data_local
  feature2_data-->feature2_data_remote
  feature2_data-->feature2_data_repositories
  feature2-->feature2_domain
  feature2_domain-->feature2_domain_mappers
  feature2_domain-->feature2_domain_models
  feature2_domain-->feature2_domain_services
  feature2-->feature2_presentation
  feature2_presentation-->feature2_presentation_views
  feature2_presentation-->feature2_presentation_view_models

The project foldering is strucutred as follows:

lib
├── common
│   ├── localization
│   ├── resources
│   └── utils
├── core
│   ├── data
│   ├── domain
│   ├── infrastructure
│   └── presentation
└── features
    ├── feature1
    │   ├── data
    │   │   ├── local
    │   │   ├── remote
    │   │   └── repositories
    │   ├── domain
    │   │   ├── mappers
    │   │   ├── models
    │   │   └── services
    │   └── presentation
    │       ├── views
    │       └── view_models
    └── feature2
        ├── data
        │   ├── local
        │   ├── remote
        │   └── repositories
        ├── domain
        │   ├── mappers
        │   ├── models
        │   └── services
        └── presentation
            ├── views
            └── view_models

Layers

Data

This layer is responsible for all the data access operations. It includes classes and functions for interacting with databases, APIs, and other data sources. It's further divided into local (for local databases or file storage), remote (for network or cloud-based data sources), and repositories (which abstract the data source and provide a clean API for data access to the rest of the application).

Domain

This layer contains the business logic of the application. It includes models (which represent the data structures used in the application), services (which encapsulate business operations), and mappers (which convert data between different formats or layers).

Presentation

This layer is responsible for displaying data to the user and handling user interactions. It includes views (which define how data is displayed) and view_models (which manage the data for the views).

Core

This layer typically contains components that are used across the application and that don't belong to any specific feature. It includes data, domain, infrastructure, and presentation, which might contain base classes, interfaces, or common functionality for each respective layer.

Common

This layer is similar to the core layer but is typically used for utilities and resources that are used across the application. It includes localization (for language-specific resources), resources (for other static resources like assets or configuration files), and utils (for utility functions or classes).