# wdelawed/enjaztask architecture

> Architecture diagram of the GitHub repository wdelawed/enjaztask, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-13). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/wdelawed/enjaztask
- Repository: https://github.com/wdelawed/enjaztask

## Overview

##### Project Type and Purpose
- This is a Flutter mobile application (with support for Android, iOS, and even a web module) built using a clean architecture approach.
- The purpose is to provide a starting point for building a Flutter app, which likely includes fetching and displaying news articles (as seen in the file names under the news_article and thumbnail models) using a layered pattern.

##### File Structure
- Platform-specific Code:
- Directories “android” and “ios” include all the native build files, configurations, and platform-specific resources.
- Assets:
- Translations and other asset resources are stored under the “assets” folder.
- Application Logic (lib Directory):
- The “lib” directory is structured into clear layers:
- Data Layer ("lib/data"): Contains constants, datasources, exceptions, models (like image, news_article, provider, thumbnail), and repository implementations.
- Domain Layer ("lib/domain"): Contains business logic encapsulated as entities, repositories (interfaces), and usecases (e.g., get_news_articles).
- Presentation Layer ("lib/presentation"): Contains BLoC components (event, state, and bloc handling) and UI pages (list and details for articles).
- The dependency injection configuration is managed in "lib/injection.dart", which ties together all the layers.
- Testing Directories:
- Tests exist in the “test” folder for testing data sources and helper functions, ensuring that individual components interact as expected.
- Web Folder:
- There is a “web” module, which contains typical web app files including “index.html” and manifest, suggesting potential deployment to a web environment.

##### Key Components
a. Mobile Client Components:
- Presentation Layer:
- UI Pages (Articles List, Article Details)
- BLoC for state management (news_article_bloc, along with its associated events and states)
- Domain Layer:
- Use Cases (like “get_news_articles”)
- Domain Entities (such as “news_article”)
- Repository Interfaces (contract definitions for fetching news articles)
- Data Layer:
- Remote Data Source (responsible for fetching data from an external API or service)
- Data Models (image, news_article, provider, thumbnail)
- Repository Implementations (news_articles_repository that implements the repository interface)
- Dependency Injection:
- A dedicated injection file that wires dependencies among the presentation, domain, and data layers.

b. Platform Abstractions:
- Android and iOS Folders:
- Compiled native code and configurations necessary to run the Flutter app on mobile devices.
- Web Folder:
- Illustrates that the app may also be deployed to web, though the core architecture remains in “lib”.

##### Relationships and Data Flow
- Begin at the UI: The user interacts with the UI pages, which trigger events in the BLoC.
- BLoC: Manages state and business logic; it forwards actions to the corresponding use cases in the Domain layer.
- Domain Interaction: Use cases fetch data via the repository interface.
- Data Flow: Repository implementations in the Data layer use the Remote Data Source to get data and then map it to the domain entities.
- Dependency Injection: This mechanism connects the layers, ensuring that each layer gets the required services and implementations.

##### Emphasizing Architectural Patterns
- Clean Architecture: Clearly separate presentation, domain, and data responsibilities.
- BLoC Pattern: For state management and separating UI from business logic.
- Dependency Injection: For loosely coupling the components and allowing easy testing and maintainability.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Presentation Layer"
        UI["UI Pages"]:::presentation
        BLOC["BLoC Components"]:::presentation
    end

    subgraph "Domain Layer"
        USECASE["Use Case: get_news_articles"]:::domain
        ENTITY["Entity: news_article"]:::domain
        REPO_I["Repository Interface: news_article_repository"]:::domain
    end

    subgraph "Data Layer"
        REMOTE["Remote Data Source"]:::data
        MODELS["Data Models"]:::data
        REPO_IMPL["Repository Implementation: news_articles_repository"]:::data
    end

    subgraph "Dependency Injection"
        DI["Injection Configuration"]:::di
    end

    subgraph "Platform Specific"
        ANDROID["Android Platform"]:::platform
        IOS["iOS Platform"]:::platform
        WEB["Web Module"]:::platform
    end

    subgraph "User Flow"
        U["User"]:::user
    end

    U -->|"interacts_with"| UI
    UI -->|"triggers"| BLOC
    BLOC -->|"calls"| USECASE
    USECASE -->|"invokes"| REPO_I
    REPO_I -->|"implemented_by"| REPO_IMPL
    REPO_IMPL -->|"fetches_data_from"| REMOTE
    REMOTE -->|"returns_data_to"| MODELS
    MODELS -->|"mapped_to"| ENTITY

    DI --- UI
    DI --- BLOC
    DI --- USECASE
    DI --- REPO_IMPL

    %% Click Events
    click UI "https://github.com/wdelawed/enjaztask/tree/master/lib/presentation/pages"
    click BLOC "https://github.com/wdelawed/enjaztask/tree/master/lib/presentation/bloc"
    click USECASE "https://github.com/wdelawed/enjaztask/blob/master/lib/domain/usecases/get_news_articles.dart"
    click ENTITY "https://github.com/wdelawed/enjaztask/blob/master/lib/domain/enitities/news_article.dart"
    click REPO_I "https://github.com/wdelawed/enjaztask/blob/master/lib/domain/repositories/news_article_repository.dart"
    click REMOTE "https://github.com/wdelawed/enjaztask/blob/master/lib/data/datasources/remote_data_source.dart"
    click MODELS "https://github.com/wdelawed/enjaztask/tree/master/lib/data/models"
    click REPO_IMPL "https://github.com/wdelawed/enjaztask/blob/master/lib/data/repositories/news_articles_repository.dart"
    click DI "https://github.com/wdelawed/enjaztask/blob/master/lib/injection.dart"
    click ANDROID "https://github.com/wdelawed/enjaztask/tree/master/android"
    click IOS "https://github.com/wdelawed/enjaztask/tree/master/ios"
    click WEB "https://github.com/wdelawed/enjaztask/tree/master/web"

    %% Styles
    classDef presentation fill:#cce5ff,stroke:#004085,stroke-width:2px;
    classDef domain fill:#d4edda,stroke:#155724,stroke-width:2px;
    classDef data fill:#fff3cd,stroke:#856404,stroke-width:2px;
    classDef di fill:#e2e3e5,stroke:#818182,stroke-width:2px;
    classDef platform fill:#f8d7da,stroke:#721c24,stroke-width:2px;
    classDef user fill:#d1ecf1,stroke:#0c5460,stroke-width:2px;
```
