# amanyara88/fityatraapp architecture

> Architecture diagram of the GitHub repository amanyara88/fityatraapp, 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/amanyara88/fityatraapp
- Repository: https://github.com/amanyara88/fityatraapp

## Overview

##### Main Components
- Mobile Application (Android):
- UI Layer: Represented by a rich set of activities (e.g., MainActivity, various activity screens for calorie statistics, meal tracking, exercise, etc.), fragments (e.g., HomeFragment, DashboardFragment, ExerciseFragment) and ViewModels (e.g., HomeViewModel, DashboardViewModel) that follow an MVVM pattern.
- Service Layer: This includes the StepTrackingService and other services that manage sensor data, Firebase ML Kit integrations (for posture detection, exercise rep counting) and background tasks.
- Data Layer: Look for local database interactions (such as SQLiteUtils) and data models (e.g., User, Exercise, DietPlan). Also include utilities for API connections in the utils folder (ApiClient, ApiServices), and any adapters that manage list displays.
- Assets & Resources: These include XML layouts, drawable resources, layouts, and configuration files (AndroidManifest, google-services.json) which provide the visual and configuration backbone of the app.

- Backend Service (Python Flask):
- Although not present in the file tree, the README indicates that a Flask backend exists. Include a component for the backend server to handle REST API calls, process personalized diet plans, and support any additional business logic or data persistence.

- External Integrations:
- Firebase ML Kit: For posture detection and counting exercise repetitions.
- Health Connect API: For integrating health data from various sources.
- Google Mobile Services (as evidenced by google-services.json).
- Chatbot Service (likely powered by Gemini or an alternative ML service) to manage health-related queries.

##### Relationships and Interactions
- The Mobile Application’s UI layer interacts with the Service layer (via activities, fragments, and ViewModels) to process user inputs and sensor data.
- The Service layer collects data from mobile sensors and interfaces with external services (Firebase ML Kit, Health Connect API) to perform processing tasks.
- The data layer interacts with the local SQLite database for persistent data storage, while also making network calls (using ApiClient/ApiServices) to communicate with the Python Flask backend.
- The backend processes requests related to personalized diet plans, updates, or other health-related configurations and then communicates back to the mobile client as needed.
- The chatbot component in the UI initiates queries that are routed either to a backend service or an external AI service.

##### Architectural Patterns and Design Principles
- Use the MVVM architecture for the Android app. Emphasize how Activities, Fragments, and ViewModels interact.
- Clearly how services act as a bridge between sensor data (mobile), local storage (SQLite), and external API integrations.
- That network clients in the utils module provide abstraction over API communications.
- Modularity and separation of concerns (UI, business logic, data, external integrations).

## Diagram (Mermaid)

```mermaid
graph TD
    %% Mobile Application UI Layer
    subgraph "Mobile Application UI Layer"
        A1("Activities"):::ui
        A2("Fragments & ViewModels"):::ui
    end

    %% Mobile Application Service Layer
    subgraph "Mobile Application Service Layer"
        S1("StepTrackingService"):::service
        S2("FirebaseUtils"):::service
        S3("HealthConnectManager"):::service
    end

    %% Mobile Application Data Layer
    subgraph "Mobile Application Data Layer"
        D1("Data Models"):::data
        D2("API Utilities"):::data
        D3("SQLiteUtils"):::data
    end

    %% Mobile Application Assets & Resources
    subgraph "Mobile Application Assets & Resources"
        R1("Assets"):::assets
        R2("Configuration & Manifest"):::assets
        R3("Layouts & Drawables"):::assets
    end

    %% Backend Service
    subgraph "Backend Service"
        B1("Python Flask Backend"):::backend
    end

    %% External Integrations
    subgraph "External Integrations"
        E1("Firebase ML Kit"):::integration
        E2("Health Connect API"):::integration
        E3("Chatbot Service"):::integration
    end

    %% Connections between UI Layer and Service Layer
    A1 -->|"triggers"| S1
    A1 -->|"launches"| E3
    A2 -->|"binds_to"| D1

    %% Connections between Service Layer and Data Layer
    S1 -->|"calls"| D2
    S1 -->|"stores"| D3
    S2 -->|"integrates"| E1
    S3 -->|"integrates"| E2

    %% Data Layer to Backend Service
    D2 -->|"fetches"| B1

    %% Assets & Resources influences UI Layer
    R1 -->|"supplies"| A1
    R2 -->|"configures"| A1
    R2 -->|"configures"| A2
    R3 -->|"renders"| A1

    %% Click Events
    click A1 "https://github.com/amanyara88/fityatraapp/tree/master/app/src/main/java/com/aman/fityatraapp/activities"
    click A2 "https://github.com/amanyara88/fityatraapp/tree/master/app/src/main/java/com/aman/fityatraapp/ui"
    click S1 "https://github.com/amanyara88/fityatraapp/tree/master/app/src/main/java/com/aman/fityatraapp/services"
    click S2 "https://github.com/amanyara88/fityatraapp/blob/master/app/src/main/java/com/aman/fityatraapp/utils/FirebaseUtils.kt"
    click S3 "https://github.com/amanyara88/fityatraapp/blob/master/app/src/main/java/com/aman/fityatraapp/utils/HealthConnectManager.kt"
    click D1 "https://github.com/amanyara88/fityatraapp/tree/master/app/src/main/java/com/aman/fityatraapp/models"
    click D2 "https://github.com/amanyara88/fityatraapp/blob/master/app/src/main/java/com/aman/fityatraapp/utils/ApiClient.kt"
    click D3 "https://github.com/amanyara88/fityatraapp/blob/master/app/src/main/java/com/aman/fityatraapp/utils/SQLiteUtils.kt"
    click R1 "https://github.com/amanyara88/fityatraapp/tree/master/app/src/main/assets"
    click R2 "https://github.com/amanyara88/fityatraapp/blob/master/app/src/main/AndroidManifest.xml"
    click R3 "https://github.com/amanyara88/fityatraapp/tree/master/app/src/main/res"
    click E1 "https://github.com/amanyara88/fityatraapp/blob/master/app/google-services.json"
    click E3 "https://github.com/amanyara88/fityatraapp/blob/master/app/src/main/java/com/aman/fityatraapp/activities/ChatBotActivity.kt"

    %% Styles
    classDef ui fill:#AED6F1,stroke:#1B4F72,stroke-width:2px;
    classDef service fill:#ABEBC6,stroke:#145A32,stroke-width:2px;
    classDef data fill:#F9E79F,stroke:#7D6608,stroke-width:2px;
    classDef assets fill:#FAD7A0,stroke:#9C640C,stroke-width:2px;
    classDef backend fill:#D2B4DE,stroke:#6C3483,stroke-width:2px;
    classDef integration fill:#F5B7B1,stroke:#943126,stroke-width:2px;
```
