# ducshntrong/foodrecipeapp architecture

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

- Interactive diagram: https://gitdiagram.com/ducshntrong/foodrecipeapp
- Repository: https://github.com/ducshntrong/foodrecipeapp

## Overview

##### Main Components
- UI/Presentation Layer: Represent the activities (e.g., MainActivity, LoginActivity, SignupActivity, etc.) and fragments (e.g., HomeFragment, ProfileFragment, CategoryFragment, etc.). Also include adapters which help populate RecyclerViews.
- ViewModel Layer: Highlight the view models (e.g., HomeViewModel, CategoryAcViewModel, DetailModel) that connect the UI to the underlying data.
- Data/Repository Layer: Show the repository components such as MealRepository that mediate between data sources.
- Data Sources:
- Network/API Component: Represent Retrofit and API interfaces (FoodApi, Retrofit class) that handle remote HTTP connections.
- Local Database: Illustrate Room database with its DAOs (MealDao) and the MealDatabase.
- External Services: Include Firebase (for authentication and, possibly, recipe CRUD operations) and third-party libraries (Glide, Coroutines).

##### Relationships and Interactions
- Optionally, indicate a two-way data binding or observer pattern (via LiveData) between the UI and ViewModels.
- Demonstrate Firebase as an external cloud service that interacts with several components (for user management and possibly additional data operations).

##### Architectural Patterns and Design Principles
- Separation of concerns: the UI layer handles display logic only, the ViewModel processes business logic and state management, and the repository/data sources handle data fetching, persistence, and conversion.

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph "UI/Presentation Layer"
    UI1["Activities (MainActivity, LoginActivity, SignupActivity, etc.)"]:::ui
    UI2["Fragments (HomeFragment, ProfileFragment, CategoryFragment, etc.)"]:::ui
    UI3["Adapters (MealsAdapter, CategoryAdapter, etc.)"]:::ui
end

subgraph "ViewModel Layer"
    VM["ViewModel Classes (HomeViewModel, CategoryAcViewModel, DetailModel)"]:::viewmodel
end

subgraph "Data/Repository Layer"
    REPO["MealRepository"]:::repository
end

subgraph "Data Sources"
    subgraph "Network/API Component"
        API1["FoodApi"]:::network
        API2["Retrofit"]:::network
    end
    subgraph "Local Database"
        DAO["MealDao"]:::localdb
        DB["MealDatabase"]:::localdb
    end
end

subgraph "External Services"
    FB["Firebase"]:::external
end

%% Connections from UI to ViewModel
UI1 -->|"LiveData"| VM
UI2 -->|"LiveData"| VM
UI3 -->|"UI Binding"| VM

%% Connection from ViewModel to Repository
VM -->|"DataRequest"| REPO

%% Connections from Repository to Data Sources
REPO -->|"FetchRemoteData"| API1
REPO -->|"Utilizes"| API2
REPO -->|"QueryLocalDB"| DAO
REPO -->|"Access/Store"| DB

%% Interactions with External Services
UI1 -->|"Auth/CRUD"| FB
REPO -->|"CRUDOps"| FB

classDef ui fill:#ADD8E6,stroke:#000,stroke-width:2px;
classDef viewmodel fill:#98FB98,stroke:#000,stroke-width:2px;
classDef repository fill:#FFD700,stroke:#000,stroke-width:2px;
classDef network fill:#FFA500,stroke:#000,stroke-width:2px;
classDef localdb fill:#FFB6C1,stroke:#000,stroke-width:2px;
classDef external fill:#DDA0DD,stroke:#000,stroke-width:2px;

click UI1 "https://github.com/ducshntrong/foodrecipeapp/tree/master/app/src/main/java/com/example/foodrecipesapp/activity/"
click UI2 "https://github.com/ducshntrong/foodrecipeapp/tree/master/app/src/main/java/com/example/foodrecipesapp/fragments/"
click UI3 "https://github.com/ducshntrong/foodrecipeapp/tree/master/app/src/main/java/com/example/foodrecipesapp/adapter/"
click VM "https://github.com/ducshntrong/foodrecipeapp/tree/master/app/src/main/java/com/example/foodrecipesapp/ViewModel/"
click REPO "https://github.com/ducshntrong/foodrecipeapp/blob/master/app/src/main/java/com/example/foodrecipesapp/data/room/MealRepository.kt"
click API1 "https://github.com/ducshntrong/foodrecipeapp/blob/master/app/src/main/java/com/example/foodrecipesapp/retrofit/FoodApi.kt"
click API2 "https://github.com/ducshntrong/foodrecipeapp/blob/master/app/src/main/java/com/example/foodrecipesapp/retrofit/Retrofit.kt"
click DAO "https://github.com/ducshntrong/foodrecipeapp/blob/master/app/src/main/java/com/example/foodrecipesapp/data/room/MealDao.kt"
click DB "https://github.com/ducshntrong/foodrecipeapp/blob/master/app/src/main/java/com/example/foodrecipesapp/data/room/MealDatabase.kt"
click FB "https://github.com/ducshntrong/foodrecipeapp/blob/master/app/google-services.json"
```
