# ashansandeepa1/mypet-android-native-app architecture

> Architecture diagram of the GitHub repository ashansandeepa1/mypet-android-native-app, 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/ashansandeepa1/mypet-android-native-app
- Repository: https://github.com/ashansandeepa1/mypet-android-native-app

## Overview

The MyPet project is an Android application focused on providing a rich user experience for pet lovers, enabling pet management, access to pet care tips, marketplace functionality, and integration with Firebase services for backend functionality.

##### Project Type and Purpose
- The project is a mobile (Android) application developed using Java in Android Studio.
- It caters to pet management, including features like user login, pet details and health records, buying/selling, pet care tips, and a medical center locator.
- The app integrates with Firebase Firestore for data storage and Firebase Authentication for secure login.

##### File Structure
- The top-level “app” directory contains the bulk of the Android app code. Inside, the “src” folder is organized into different build types (e.g., “main”, “androidTest”, “test”), with the “main” directory including:
- Java code (under com/ashan/mypet) where activities (e.g., LoginActivity, MainActivity, RegisterActivity, etc.) and fragments (e.g., HomeFragment, ProfileFragment, MedicalFragment) are defined.
- AndroidManifest.xml defines the application’s components.
- Resources under “res” (layouts, drawables, menus, navigation) for UI design.
- The presence of Gradle build files (build.gradle.kts, settings.gradle.kts, gradlew) confirms the Gradle build system, and external configuration such as google-services.json for Firebase integration.
- Therefore the architecture separates the UI, application logic, and third-party services (Firebase).

##### Main Components
a. Android Application Layer:
- Activities and Fragments: These represent UI and navigation components (LoginActivity, MainActivity, HomeFragment, ProfileFragment, etc.).
- UI Elements: Layout files, menus, drawables, and navigation graphs (nav_graph.xml) that govern user interactions.
b. Business Logic and Data Handling:
- Java classes for data management (like Pet, HealthRecord, adapters for UI lists) that handle app-specific operations.
- Integration points for fetching, updating, or managing data.
c. Firebase Backend Services:
- Firebase Authentication: Handles secure user logins and registrations.
- Firebase Firestore: Serves as the database to store pet details, user profiles, health records, buying/selling items, etc.
d. Build and Integration:
- Gradle build configuration manages dependencies and project structure.
- Google Services JSON connects the app with Firebase services.

##### Architectural Patterns and Design Principles
- The project appears to follow a layered architecture where the UI (activities and fragments) interacts with business logic, and in turn, this business logic communicates with external backend services (Firebase).
- Even if not explicitly stated, the modularized code (separation of UI elements, data models, adapter classes) suggests adherence to separation of concerns and possibly an MVC or MVVM pattern.
- The navigation component aids in maintaining clear separation between different screens of the app.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Android Application"
        subgraph "UI Layer"
            A1["Activities & Fragments (UI)"]:::client
            A2["UI Elements: Layouts"]:::client
            A3["UI Elements: Menus"]:::client
            A4["UI Elements: Navigation"]:::client
        end
        subgraph "Business Logic Layer"
            B1["Pet & Health Records Management"]:::client
            B2["Data Models & Adapters"]:::client
        end
        A1 -->|"userActions"| B1
        A2 -->|"uiFlow"| A1
        A3 -->|"uiFlow"| A1
        A4 -->|"uiFlow"| A1
        B1 -->|"dataUpdate"| B2
    end

    subgraph "Build & Integration"
        G1["app/build.gradle.kts"]:::build
        G2["build.gradle.kts"]:::build
        G3["settings.gradle.kts"]:::build
    end

    subgraph "Firebase Services"
        F1["Firebase Authentication"]:::backend
        F2["Firebase Firestore"]:::backend
        F3["Firebase Integration"]:::backend
    end

    B1 -->|"authRequest"| F1
    B2 -->|"dataSync"| F2
    F1 -->|"authResponse"| B1
    F2 -->|"dataResponse"| B2

    %% Click Events for Components
    click A1 "https://github.com/ashansandeepa1/mypet-android-native-app/tree/main/app/src/main/java/com/ashan/mypet/"
    click A2 "https://github.com/ashansandeepa1/mypet-android-native-app/tree/main/app/src/main/res/layout"
    click A3 "https://github.com/ashansandeepa1/mypet-android-native-app/tree/main/app/src/main/res/menu"
    click A4 "https://github.com/ashansandeepa1/mypet-android-native-app/tree/main/app/src/main/res/navigation"
    click B2 "https://github.com/ashansandeepa1/mypet-android-native-app/tree/main/app/src/main/java/com/ashan/mypet/"
    click F3 "https://github.com/ashansandeepa1/mypet-android-native-app/blob/main/app/google-services.json"
    click G1 "https://github.com/ashansandeepa1/mypet-android-native-app/blob/main/app/build.gradle.kts"
    click G2 "https://github.com/ashansandeepa1/mypet-android-native-app/blob/main/build.gradle.kts"
    click G3 "https://github.com/ashansandeepa1/mypet-android-native-app/blob/main/settings.gradle.kts"

    %% Styling
    classDef client fill:#ADD8E6,stroke:#000,stroke-width:2px;
    classDef backend fill:#90EE90,stroke:#000,stroke-width:2px;
    classDef build fill:#FFA500,stroke:#000,stroke-width:2px;
```
