# hashan-samarakkody/foodies architecture

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

- Interactive diagram: https://gitdiagram.com/hashan-samarakkody/foodies
- Repository: https://github.com/hashan-samarakkody/foodies

## Overview

##### Project Type and Purpose
- The project is an Android mobile application written in Java.
- Its primary purpose is to help users discover, manage, and share recipes. Key features include Google-based authentication, recipe CRUD operations (create, read, update, delete), social sharing, favorites, ratings, multimedia upload (photos/videos), and search functionality.
- Firebase services (Authentication, Realtime Database, and Cloud Storage) are integral to the backend functionality.

##### File Structure
- The “app” directory is the heart of the project and follows the standard Android project conventions (with subdirectories like src/main, src/test, and build directories).
- Under “app/src/main/java/com/example/foodies,” you see separate packages such as UI, Adapters, and HelperClass, indicating a separation of concerns where the UI layer is responsible for screen activities (e.g., SplashActivity, LoginActivity, MainActivity, OthersRecipeDetailActivity, etc.) while Adapters are used to bind data for lists and RecyclerViews.
- Data-binding components (placed under databinding folders in src and generated build files) suggest the project leverages Android’s data binding feature for UI updates.
- Gradle configuration files (build.gradle.kts, settings.gradle.kts) indicate that the project is set up for continuous integration and publishing, supported by GitHub workflows.
- The file tree also contains directories related to testing (androidTest and test folders) showing that unit and instrumentation tests are in place.

##### README for Additional Insights
- The README explains installation instructions, Firebase setup steps, and outlines key functionalities through detailed screenshots.
- It emphasizes Firebase integration (Realtime Database, Authentication, Cloud Storage) and Google sign-in which connects the mobile UI elements with backend services.
- The README clearly delineates the workflow for cloning, SDK setup, and using Android Studio to build the project.

a. Main Components:
- Mobile Client (Android App):
- UI/Presentation Layer: Activities (Splash, Login, Main, Recipe Details, etc.) and Fragments (if used).
- Data Binding Layer: Integrating between UI elements and underlying data models.
- Adapters and Helper Classes: For handling list displays and utility functions.
- Firebase Cloud Services:
- Firebase Authentication: Handling Google sign-in and user authentication.
- Firebase Realtime Database: Storing and retrieving recipes and user data.
- Firebase Cloud Storage: Managing multimedia uploads (images/videos).

b. Relationships and Interactions:
- The Android App (client) sends user-generated actions (e.g., add recipe, delete, share) from the various UI components.
- These actions trigger network requests (using classes such as NetworkUtils) that communicate with Firebase services.
- For authentication, the UI layer interacts with Firebase Authentication using Google Sign-in APIs.
- Recipe data is read from and written to the Firebase Realtime Database.
- Multimedia (photos and videos) are uploaded to Firebase Cloud Storage.
- Data Binding ensures UI components automatically update as data changes.

c. Architectural Patterns & Technologies in Use:
- The application follows standard Android architecture patterns, separating presentation (UI), business logic (Adapters, Helpers), and data access (Firebase services).
- Data binding is used to minimize boilerplate code and keep the UI in sync with data.
- Firebase SDKs are crucial external libraries integrating authentication, database, and storage features.
- Gradle and CI workflows (.github/workflows) indicate modern build automation practices.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Global User
    User["User"]:::user

    %% Mobile Client Subgraph
    subgraph "Mobile Client"
        UIPresentation["UI/Presentation Layer"]:::ui
        Splash["Splash Activity"]:::activity
        Login["Login Activity"]:::activity
        Main["Main Activity"]:::activity
        RecipeDetail["Recipe Details Activity"]:::activity
        DataBinding["Data Binding Layer"]:::db
        Adapters["Business Logic – Adapters"]:::logic
        Helpers["Utility/Helper Classes"]:::helper

        %% Grouping UI activities under Presentation Layer
        UIPresentation --> Splash
        UIPresentation --> Login
        UIPresentation --> Main
        UIPresentation --> RecipeDetail

        %% Data Binding connection (used for UI updates)
        Splash -->|"bindsTo"| DataBinding
        Login -->|"bindsTo"| DataBinding
        Main -->|"bindsTo"| DataBinding
        RecipeDetail -->|"bindsTo"| DataBinding

        %% Business logic supports UI
        Adapters -->|"feedsData"| UIPresentation
        Helpers -->|"supports"| UIPresentation
    end

    %% Firebase Services Subgraph
    subgraph "Firebase Services"
        FirebaseAuth["Firebase Authentication"]:::firebase
        FirebaseDB["Firebase Realtime Database"]:::firebase
        FirebaseStorage["Firebase Cloud Storage"]:::firebase
    end

    %% Build and Testing Subgraph
    subgraph "Build & Testing"
        BuildCI["Build, CI and Dependency Config"]:::build
        Testing["Testing Components"]:::testing
    end

    %% User interactions with Mobile Client
    User -->|"initiates"| UIPresentation

    %% UI interactions with Firebase Services
    Login -->|"GoogleSignIn"| FirebaseAuth
    Main -->|"CRUD_Operations"| FirebaseDB
    RecipeDetail -->|"CRUD_Operations"| FirebaseDB
    Main -->|"UploadMedia"| FirebaseStorage

    %% Link User to Build and Testing (project setup and quality assurance)
    User --- BuildCI
    User --- Testing

    %% Click Events for Component Mapping
    click UIPresentation "https://github.com/hashan-samarakkody/foodies/tree/master/app/src/main/java/com/example/foodies/UI"
    click DataBinding "https://github.com/hashan-samarakkody/foodies/tree/master/app/build/generated/data_binding_base_class_source_out/debug/out/com/example/foodies/databinding"
    click Adapters "https://github.com/hashan-samarakkody/foodies/tree/master/app/src/main/java/com/example/foodies/Adapters"
    click Helpers "https://github.com/hashan-samarakkody/foodies/tree/master/app/src/main/java/com/example/foodies/HelperClass"
    click BuildCI "https://github.com/hashan-samarakkody/foodies/blob/master/build.gradle.kts"
    click Testing "https://github.com/hashan-samarakkody/foodies/tree/master/app/src/test/java/com/example/foodies"

    %% Styles
    classDef ui fill:#FFD700,stroke:#333,stroke-width:2px;
    classDef activity fill:#FFB6C1,stroke:#333,stroke-width:2px;
    classDef db fill:#98FB98,stroke:#333,stroke-width:2px;
    classDef logic fill:#87CEFA,stroke:#333,stroke-width:2px;
    classDef helper fill:#FF8C00,stroke:#333,stroke-width:2px;
    classDef firebase fill:#ADD8E6,stroke:#333,stroke-width:2px;
    classDef build fill:#D3D3D3,stroke:#333,stroke-width:2px;
    classDef testing fill:#FFA07A,stroke:#333,stroke-width:2px;
    classDef user fill:#90EE90,stroke:#333,stroke-width:2px;
```
