# moohamed154/fruits_hub architecture

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

- Interactive diagram: https://gitdiagram.com/moohamed154/fruits_hub
- Repository: https://github.com/moohamed154/fruits_hub

## Overview

##### Main Components
- UI/Presentation Layer: This layer is represented in the lib/features subdirectories (for example, auth, home, on_boarding, and splash). Each feature contains its own presentation files (views, widgets) including components like signin_view.dart, home_view.dart, etc.
- Business Logic Layer: Look into the presentation “cubits” inside each feature (e.g., signin_cubit, signup_cubit). They manage state and interactions between the UI and underlying data.
- Data Layer: Within each feature’s folder (like lib/features/auth/data), you find models, repositories (e.g., auth_repo_impl.dart), and data source definitions. This layer is responsible for handling data operations.
- Core & Shared Services: The lib/core directory contains utilities, helper functions, core widgets, error management, and app-wide services (like firebase_auth_service, firestore_service, and database_service). This is the supporting backbone that is reused across features.
- External Services/Platform Integrations: The project integrates with Firebase (files like firebase.json, lib/firebase_options.dart, and service implementations for Firebase Auth/Firestore) and also uses shared preferences.

- Presentation/UI Layer: Illustrate the different feature-based UIs (Splash Screen, On-boarding, Auth Views, Home View) and associated widgets.
- Business Logic Layer: Represent the Cubits (state management controllers) that interface between the UI and the data repositories.
- Data Layer: Show the repositories, models, and APIs that fetch or send data, likely indicating Firebase integration.
- Core Services: Encompass utilities, error handling modules, helper functions, and common widgets that support various features.

##### Relationships and Interactions
- UI components send events to the Business Logic Layer (Cubits) which then invoke repository methods.
- Repositories interact with external services (e.g., Firebase Auth, Firestore) to fetch or persist data.
- Responses propagate back up from the Data Layer to update state in the Cubits, thereby updating the UI.

##### Architectural Patterns and Technologies
- Use of state management (BLoC/Cubit pattern) for handling interactions.
- Mention the technologies: Flutter (for UI), Firebase (for backend/authentication), and the integration of platform-specific code for Android, iOS, etc.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "UI/Presentation Layer"
        UI_Splash["Splash Screen UI"]:::presentation
        UI_OnBoarding["On-boarding UI"]:::presentation
        UI_Auth["Auth Feature UI"]:::presentation
        UI_Home["Home Feature UI"]:::presentation
    end

    subgraph "Business Logic Layer"
        BL_AuthCubit["Auth Cubit"]:::business
    end

    subgraph "Data Layer"
        DL_AuthData["Auth Data (Models & Repos)"]:::data
        DL_AuthEntities["Auth Entities"]:::data
    end

    subgraph "Core & Shared Services"
        CORE_Services["Core Services & Utilities"]:::core
        CORE_Routing["Core Helpers & Routing"]:::core
        CORE_Widgets["Core Widgets & Utils"]:::core
    end

    subgraph "External Services/Platform Integrations"
        EXT_Firebase["Firebase Integration"]:::external
        EXT_Platform["Platform-Specific Code"]:::external
    end

    %% UI to Business Logic
    UI_Auth -->|"UserAction"| BL_AuthCubit
    UI_Home -->|"UserAction"| BL_AuthCubit

    %% Business Logic to Data Layer
    BL_AuthCubit -->|"InvokeAuth"| DL_AuthData
    %% Data Layer interacts with External Services
    DL_AuthData -->|"DataFetch"| EXT_Firebase
    EXT_Firebase -->|"Response"| DL_AuthData
    DL_AuthData -->|"Result"| BL_AuthCubit
    BL_AuthCubit -->|"StateUpdate"| UI_Auth
    BL_AuthCubit -->|"StateUpdate"| UI_Home

    %% UI layers utilizing core services and routing
    UI_Splash -->|"Init"| CORE_Routing
    UI_OnBoarding -->|"Init"| CORE_Routing

    UI_Splash -->|"Uses"| CORE_Services
    UI_OnBoarding -->|"Uses"| CORE_Services
    UI_Auth -->|"Uses"| CORE_Services
    UI_Home -->|"Uses"| CORE_Services

    CORE_Routing -->|"Routing"| UI_Splash
    CORE_Routing -->|"Routing"| UI_OnBoarding
    CORE_Routing -->|"Routing"| UI_Auth
    CORE_Routing -->|"Routing"| UI_Home

    UI_Splash -->|"Displays"| CORE_Widgets
    UI_OnBoarding -->|"Displays"| CORE_Widgets
    UI_Auth -->|"Displays"| CORE_Widgets
    UI_Home -->|"Displays"| CORE_Widgets

    %% External Platforms interactions
    EXT_Firebase -->|"Interacts"| EXT_Platform

    %% Click Events for UI/Presentation Layer
    click UI_Splash "https://github.com/moohamed154/fruits_hub/blob/main/lib/features/splash/presentation/views/splash_view.dart"
    click UI_OnBoarding "https://github.com/moohamed154/fruits_hub/blob/main/lib/features/on_boarding/presentation/views/on_boarding_view.dart"
    click UI_Auth "https://github.com/moohamed154/fruits_hub/blob/main/lib/features/auth/presentation/views/signin_view.dart"
    click UI_Auth "https://github.com/moohamed154/fruits_hub/blob/main/lib/features/auth/presentation/views/signup_view.dart"
    click UI_Home "https://github.com/moohamed154/fruits_hub/blob/main/lib/features/home/presentation/views/home_view.dart"

    %% Click Events for Business Logic Layer
    click BL_AuthCubit "https://github.com/moohamed154/fruits_hub/tree/main/lib/features/auth/presentation/cubits/signin_cubit/"
    click BL_AuthCubit "https://github.com/moohamed154/fruits_hub/tree/main/lib/features/auth/presentation/cubits/signup_cubits/"

    %% Click Events for Data Layer
    click DL_AuthData "https://github.com/moohamed154/fruits_hub/blob/main/lib/features/auth/data/repos/auth_repo_impl.dart"
    click DL_AuthData "https://github.com/moohamed154/fruits_hub/tree/main/lib/features/auth/data/models"
    click DL_AuthEntities "https://github.com/moohamed154/fruits_hub/tree/main/lib/features/auth/entities"

    %% Click Events for Core & Shared Services
    click CORE_Services "https://github.com/moohamed154/fruits_hub/tree/main/lib/core/services"
    click CORE_Services "https://github.com/moohamed154/fruits_hub/blob/main/lib/core/services/firebase_auth_service.dart"
    click CORE_Services "https://github.com/moohamed154/fruits_hub/blob/main/lib/core/services/firestore_service.dart"
    click CORE_Services "https://github.com/moohamed154/fruits_hub/blob/main/lib/core/services/database_service.dart"
    click CORE_Services "https://github.com/moohamed154/fruits_hub/blob/main/lib/core/services/get_it_service.dart"
    click CORE_Services "https://github.com/moohamed154/fruits_hub/blob/main/lib/core/services/shared_preferences_singleton.dart"
    click CORE_Routing "https://github.com/moohamed154/fruits_hub/blob/main/lib/core/helper_functions/on_generate_routes.dart"
    click CORE_Widgets "https://github.com/moohamed154/fruits_hub/tree/main/lib/core/widgets"
    click CORE_Widgets "https://github.com/moohamed154/fruits_hub/tree/main/lib/core/utils"

    %% Click Events for External Services/Platform Integrations
    click EXT_Firebase "https://github.com/moohamed154/fruits_hub/blob/main/firebase.json"
    click EXT_Firebase "https://github.com/moohamed154/fruits_hub/blob/main/lib/firebase_options.dart"
    click EXT_Platform "https://github.com/moohamed154/fruits_hub/tree/main/android/"
    click EXT_Platform "https://github.com/moohamed154/fruits_hub/tree/main/ios/"
    click EXT_Platform "https://github.com/moohamed154/fruits_hub/tree/main/web/"

    %% Style Definitions
    classDef presentation fill:#9fdfbf,stroke:#333,stroke-width:2px;
    classDef business fill:#fff3bf,stroke:#333,stroke-width:2px;
    classDef data fill:#fbb4ae,stroke:#333,stroke-width:2px;
    classDef core fill:#cce5ff,stroke:#333,stroke-width:2px;
    classDef external fill:#fce5cd,stroke:#333,stroke-width:2px;
```
