# boodyahmedhamdy/mealano architecture

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

- Interactive diagram: https://gitdiagram.com/boodyahmedhamdy/mealano
- Repository: https://github.com/boodyahmedhamdy/mealano

## Overview

##### Project Type and Purpose
- Mealano is an Android application to assist users in meal planning. The README shows that it has multiple screens (login/signup, onboarding, home, meal details, search, favorite meals, plans, profile, and about) and integrates various services such as Firebase for authentication and realtime data, Retrofit for network calls, and Room for local storage. Its architecture follows the MVP (Model-View-Presenter) pattern.
- The purpose of the application is to offer meal suggestions, enable meal searching (by ingredient, category, area), manage user favorites, and support meal planning through features like adding to calendars.

##### File Structure
- The file tree clearly separates the Android-specific components, with the “app/src/main” folder for the main application logic.
- Presentation Layer: Notice the plentiful fragments and activities under packages (e.g., “home”, “login”, “signup”, “splash”, “onboarding”, “profile”, “meal details”, “favorite”, “search”, “plans”, “about”).
- MVP Implementation: Each feature has its own “contract” package containing definitions for View and Presenter along with separate “presenter” and “view” implementation folders.
- Data Layer: The “datalayer” folder holds datasources defined separately for remote and local access. It further includes repositories for meals, plans, and users.
- Local Data Sources: Look for Room database classes (MealanoDatabase), DAOs, Entities, SharedPreferences management.
- Remote Data Sources: Retrofit API interfaces (MealsApi, MealsApiService) and corresponding implementations.
- Utility and Support: Libraries for networking callbacks, reactive programming (RxJava), UI and utility design, as well as file-based configuration (Gradle build scripts).

a. Main Components:
- Presentation Layer – Contains Activity/Fragment based UI components along with MVP contracts and presenters.
- Data Layer – Separated into:
- Local Data Sources (Room database, DAOs, SharedPreferences)
- Remote Data Sources (APIs via Retrofit, Firebase Authentication)
- Repository Layer – Acts as the mediator between the UI (through presenter classes) and the data sources (both local and remote).
- External Services – Includes Firebase for authentication and data sync, Google services for login, Calendar integration, and possibly external libraries for Reactive (RxJava) and networking (Retrofit).

b. Relationships and Interactions:
- The UI components (Fragments/Activities) interact with Presenters (from the MVP) via defined contracts.
- Presenters retrieve or update data via the Repository abstraction.
- The Repository directs calls to either the Local Data Sources (for caching, shared preferences, local queries) or the Remote Data Sources (to fetch data from APIs/Firebase).
- Utility classes (callbacks, network monitoring) support asynchronous or reactive operations between these layers.

c. Architectural Patterns/Design Principles:
- MVP – Clean separation between view interfaces and presenter logic.
- Repository Pattern – Abstracts data retrieval and persistence logic between remote and local sources.
- Separation of Concerns – Each feature (e.g., login, home, search) is organized into its own package with dedicated MVP, making components modular and maintainable.

d. Relevant Technologies:
- Programming Language: Java (with some Gradle Kotlin build scripts)
- UI Frameworks: XML for layout, Material Design Components
- Networking: Retrofit for API calls, RxJava for reactive programming
- Database: RoomDatabase for local storage; Firebase Realtime Database for online data
- Authentication: Firebase Authentication, along with support for Google-based login
- External integrations: Calendar sharing for meal plans

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% UI Layer
    subgraph "UI Layer"
        A["SplashFragment"]:::ui
        B["LoginFragment"]:::ui
        C["SignupFragment"]:::ui
        D["OnBoardingFragments"]:::ui
        E["HomeFragment"]:::ui
        F["MealDetailsFragment"]:::ui
        G["FavoriteFragment"]:::ui
        H["PlansFragment"]:::ui
        I["ProfileFragment"]:::ui
        J["SearchFragment"]:::ui
        K["SearchByFragment"]:::ui
        L["AboutFragment"]:::ui
    end

    %% MVP Layer
    subgraph "MVP Layer"
        M1["Login MVP (View/Presenter)"]:::mvp
        M2["Home MVP (View/Presenter)"]:::mvp
        M3["MealDetails MVP (View/Presenter)"]:::mvp
        M4["Other MVP Modules"]:::mvp
    end

    %% Repository Layer
    subgraph "Repository Layer"
        R1["MealsRepository"]:::repo
        R2["PlansRepository"]:::repo
        R3["UsersRepository"]:::repo
    end

    %% Data Layer
    subgraph "Data Layer"
        subgraph "Local Data Sources"
            L1["MealanoDatabase"]:::local
            L2["MealsDao"]:::local
            L3["PlansDao"]:::local
            L4["MealEntity"]:::local
            L5["PlanEntity"]:::local
            L6["SharedPreferencesManager"]:::local
            L7["MealsLocalDataSource"]:::local
            L8["PlansLocalDataSource"]:::local
            L9["UsersLocalDataSource"]:::local
        end
        subgraph "Remote Data Sources"
            RDS1["MealsRemoteDataSource"]:::remote
            RDS2["PlansRemoteDataSource"]:::remote
            RDS3["UsersRemoteDataSource"]:::remote
            RDS4["MealsApi/Service"]:::remote
        end
    end

    %% External Services
    subgraph "External Services"
        EX1["Firebase"]:::external
        EX2["Google Services & Calendar"]:::external
        EX3["Google Services Config"]:::external
    end

    %% Connections: UI Layer to MVP Layer
    A -->|"triggers"| M4
    B -->|"triggers"| M1
    C -->|"triggers"| M4
    D -->|"triggers"| M4
    E -->|"triggers"| M2
    F -->|"triggers"| M3
    G -->|"triggers"| M4
    H -->|"triggers"| M4
    I -->|"triggers"| M4
    J -->|"triggers"| M4
    K -->|"triggers"| M4
    L -->|"triggers"| M4

    %% MVP Layer to Repository Layer
    M1 -->|"requests"| R3
    M2 -->|"requests"| R1
    M3 -->|"requests"| R1
    M4 -->|"requests"| R1
    M4 -->|"requests"| R2
    M4 -->|"requests"| R3

    %% Repository Layer to Data Layer
    R1 -->|"fetches"| L7
    R1 -->|"fetches"| RDS1
    R2 -->|"fetches"| L8
    R2 -->|"fetches"| RDS2
    R3 -->|"fetches"| L9
    R3 -->|"fetches"| RDS3

    %% Data Layer internal connections
    L1 -->|"contains"| L2
    L1 -->|"contains"| L3
    L1 -->|"contains"| L4
    L1 -->|"contains"| L5

    %% External Services interaction with Remote Data Sources
    RDS1 <-->|"sync"| EX1
    RDS2 <-->|"sync"| EX1
    RDS3 <-->|"sync"| EX1
    RDS1 <-->|"auth"| EX2

    %% External Services configuration
    EX3 -->|"configures"| EX1
    EX3 -->|"configures"| EX2

    %% Click Events for UI Components
    click A "https://github.com/boodyahmedhamdy/mealano/blob/master/app/src/main/java/io/github/boodyahmedhamdy/mealano/splash/view/SplashFragment.java"
    click B "https://github.com/boodyahmedhamdy/mealano/blob/master/app/src/main/java/io/github/boodyahmedhamdy/mealano/login/view/LoginFragment.java"
    click C "https://github.com/boodyahmedhamdy/mealano/blob/master/app/src/main/java/io/github/boodyahmedhamdy/mealano/signup/view/SignupFragment.java"
    click D "https://github.com/boodyahmedhamdy/mealano/tree/master/app/src/main/java/io/github/boodyahmedhamdy/mealano/onboarding"
    click E "https://github.com/boodyahmedhamdy/mealano/blob/master/app/src/main/java/io/github/boodyahmedhamdy/mealano/home/view/HomeFragment.java"
    click F "https://github.com/boodyahmedhamdy/mealano/blob/master/app/src/main/java/io/github/boodyahmedhamdy/mealano/details/view/MealDetailsFragment.java"
    click G "https://github.com/boodyahmedhamdy/mealano/blob/master/app/src/main/java/io/github/boodyahmedhamdy/mealano/favorite/view/FavoriteFragment.java"
    click H "https://github.com/boodyahmedhamdy/mealano/blob/master/app/src/main/java/io/github/boodyahmedhamdy/mealano/plans/view/PlansFragment.java"
    click I "https://github.com/boodyahmedhamdy/mealano/blob/master/app/src/main/java/io/github/boodyahmedhamdy/mealano/profile/view/ProfileFragment.java"
    click J "https://github.com/boodyahmedhamdy/mealano/blob/master/app/src/main/java/io/github/boodyahmedhamdy/mealano/search/view/SearchFragment.java"
    click K "https://github.com/boodyahmedhamdy/mealano/blob/master/app/src/main/java/io/github/boodyahmedhamdy/mealano/searchby/view/SearchByFragment.java"
    click L "https://github.com/boodyahmedhamdy/mealano/blob/master/app/src/main/java/io/github/boodyahmedhamdy/mealano/about/AboutFragment.java"

    %% Click Events for MVP Components
    click M1 "https://github.com/boodyahmedhamdy/mealano/blob/master/app/src/main/java/io/github/boodyahmedhamdy/mealano/login/contract/LoginView.java"
    click M2 "https://github.com/boodyahmedhamdy/mealano/blob/master/app/src/main/java/io/github/boodyahmedhamdy/mealano/home/contract/HomeView.java"
    click M3 "https://github.com/boodyahmedhamdy/mealano/blob/master/app/src/main/java/io/github/boodyahmedhamdy/mealano/details/contract/MealDetailsView.java"

    %% Click Events for Repository Layer
    click R1 "https://github.com/boodyahmedhamdy/mealano/blob/master/app/src/main/java/io/github/boodyahmedhamdy/mealano/datalayer/repos/meals/MealsRepository.java"
    click R2 "https://github.com/boodyahmedhamdy/mealano/blob/master/app/src/main/java/io/github/boodyahmedhamdy/mealano/datalayer/repos/plans/PlansRepository.java"
    click R3 "https://github.com/boodyahmedhamdy/mealano/blob/master/app/src/main/java/io/github/boodyahmedhamdy/mealano/datalayer/repos/users/UsersRepository.java"

    %% Click Events for Local Data Sources
    click L1 "https://github.com/boodyahmedhamdy/mealano/blob/master/app/src/main/java/io/github/boodyahmedhamdy/mealano/datalayer/datasources/local/db/MealanoDatabase.java"
    click L2 "https://github.com/boodyahmedhamdy/mealano/blob/master/app/src/main/java/io/github/boodyahmedhamdy/mealano/datalayer/datasources/local/db/daos/MealsDao.java"
    click L3 "https://github.com/boodyahmedhamdy/mealano/blob/master/app/src/main/java/io/github/boodyahmedhamdy/mealano/datalayer/datasources/local/db/daos/PlansDao.java"
    click L4 "https://github.com/boodyahmedhamdy/mealano/blob/master/app/src/main/java/io/github/boodyahmedhamdy/mealano/datalayer/datasources/local/db/entities/MealEntity.java"
    click L5 "https://github.com/boodyahmedhamdy/mealano/blob/master/app/src/main/java/io/github/boodyahmedhamdy/mealano/datalayer/datasources/local/db/entities/PlanEntity.java"
    click L6 "https://github.com/boodyahmedhamdy/mealano/blob/master/app/src/main/java/io/github/boodyahmedhamdy/mealano/datalayer/datasources/local/SharedPreferencesManager.java"
    click L7 "https://github.com/boodyahmedhamdy/mealano/blob/master/app/src/main/java/io/github/boodyahmedhamdy/mealano/datalayer/datasources/local/meals/MealsLocalDataSource.java"
    click L8 "https://github.com/boodyahmedhamdy/mealano/blob/master/app/src/main/java/io/github/boodyahmedhamdy/mealano/datalayer/datasources/local/plans/PlansLocalDataSource.java"
    click L9 "https://github.com/boodyahmedhamdy/mealano/blob/master/app/src/main/java/io/github/boodyahmedhamdy/mealano/datalayer/datasources/local/users/UsersLocalDataSource.java"

    %% Click Events for Remote Data Sources
    click RDS1 "https://github.com/boodyahmedhamdy/mealano/blob/master/app/src/main/java/io/github/boodyahmedhamdy/mealano/datalayer/datasources/remote/meals/MealsRemoteDataSource.java"
    click RDS2 "https://github.com/boodyahmedhamdy/mealano/blob/master/app/src/main/java/io/github/boodyahmedhamdy/mealano/datalayer/datasources/remote/plans/PlansRemoteDataSource.java"
    click RDS3 "https://github.com/boodyahmedhamdy/mealano/blob/master/app/src/main/java/io/github/boodyahmedhamdy/mealano/datalayer/datasources/remote/users/UsersRemoteDataSource.java"
    click RDS4 "https://github.com/boodyahmedhamdy/mealano/blob/master/app/src/main/java/io/github/boodyahmedhamdy/mealano/datalayer/datasources/remote/api/MealsApi.java"

    %% Click Event for External Services Config
    click EX3 "https://github.com/boodyahmedhamdy/mealano/blob/master/app/google-services.json"

    %% Styles
    classDef ui fill:#f9e79f,stroke:#c0392b,stroke-width:2px;
    classDef mvp fill:#fad7a0,stroke:#d35400,stroke-width:2px;
    classDef repo fill:#a9dfbf,stroke:#27ae60,stroke-width:2px;
    classDef local fill:#aed6f1,stroke:#2980b9,stroke-width:2px;
    classDef remote fill:#f5b7b1,stroke:#c0392b,stroke-width:2px;
    classDef external fill:#d7bde2,stroke:#8e44ad,stroke-width:2px;
```
