# kit-g/heart-of-yours architecture

> Architecture diagram of the GitHub repository kit-g/heart-of-yours, 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/kit-g/heart-of-yours
- Repository: https://github.com/kit-g/heart-of-yours

## Overview

##### Main Components
▪ Frontend/Mobile UI: Represented by the Flutter “lib” folder, particularly the presentation layer (inside lib/presentation) and its associated widgets. Indicate that this layer handles the user interface and interacts with state and business logic via Provider.
▪ Core App Logic & State Management: The “heart_state” package (within shared/heart_state) contains all business logic and state management, exposing the Provider package to the app. This is your MVVM “view-model”.
▪ Data Layer: This is further separated into several modules:
– heart_models: Contains the data models and domain objects.
– heart_db: Abstracts the local database operations.
– heart_language: Provides localization and language support.
▪ Platform-Specific Code: Android (android directory) and iOS (ios directory) code are tailored for the respective platforms.
▪ External Dependencies: Firebase is used as the backend (although its API is hidden inside heart_state) and Sentry for error logging; as mentioned, the app never directly accesses Firebase so this promotes separation of concerns.

##### Relationships and Interactions
▪ The UI layer (Flutter screens and widgets) communicates with the ViewModel layer (heart_state) via Provider for state management.
▪ The data layer (heart_models, heart_db, and heart_language) resides in shared packages and is consumed by heart_state to get, process, and persist data.
▪ Firebase, as the backend, is integrated inside heart_state and handles asynchronous database operations; this dependency is kept internal and is not exposed to the UI layer.

##### Architectural Patterns and Design Principles
▪ Separation of Concerns: The “data layer” has been completely factored into separate packages which interact only through the heart_state package.
▪ Dependency Injection / Provider: Use a Provider-based approach to connect UI with business logic.
▪ Environment Configuration and Flavors: The inclusion of different flavors (dev, prod, etc.) with separate configurations (env/dev.json) should be shown as part of the deployment/configuration process.

##### Relevant Technologies, Frameworks, and Libraries
▪ Flutter & Dart for cross-platform (Android/iOS) mobile development.
▪ Provider for state management.
▪ Firebase as the backend service (accessed indirectly through heart_state).
▪ Sentry for error logging.
▪ The shared packages (heart_models, heart_db, heart_language, heart_state) provide modularity and potential reuse across different parts of the app.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Mobile App"
        ENV["Env & Config"]:::config
        UI["UI (Flutter Presentation)"]:::frontend
        STATE["State Management (heart_state)"]:::vm

        subgraph "Data Layer"
            MODELS["Data Models (heart_models)"]:::data
            DB["Database Abstraction (heart_db)"]:::data
            LANG["Localization (heart_language)"]:::data
        end

        FB["Firebase Backend"]:::external
        SENTRY["Sentry (Error Logging)"]:::external

        subgraph "Platform Specific"
            ANDROID["Android Code"]:::platform
            IOS["iOS Code"]:::platform
        end
    end

    ENV -->|"configures"| UI
    ENV -->|"configures"| STATE
    ENV -->|"configures"| ANDROID
    ENV -->|"configures"| IOS

    UI -->|"provider_update"| STATE

    STATE -->|"uses"| MODELS
    STATE -->|"persists"| DB
    STATE -->|"localizes"| LANG
    STATE -->|"integrates_with"| FB
    STATE -->|"logs_errors"| SENTRY

    UI -->|"deployed_on"| ANDROID
    UI -->|"deployed_on"| IOS

    click UI "https://github.com/kit-g/heart-of-yours/tree/main/lib/presentation"
    click STATE "https://github.com/kit-g/heart-of-yours/tree/main/shared/heart_state"
    click MODELS "https://github.com/kit-g/heart-of-yours/tree/main/shared/heart_models"
    click DB "https://github.com/kit-g/heart-of-yours/tree/main/shared/heart_db"
    click LANG "https://github.com/kit-g/heart-of-yours/tree/main/shared/heart_language"
    click ANDROID "https://github.com/kit-g/heart-of-yours/tree/main/android"
    click IOS "https://github.com/kit-g/heart-of-yours/tree/main/ios"
    click ENV "https://github.com/kit-g/heart-of-yours/tree/main/lib/core/env"

    classDef frontend fill:#AED6F1,stroke:#000,stroke-width:1px;
    classDef vm fill:#F9E79F,stroke:#000,stroke-width:1px;
    classDef data fill:#D5F5E3,stroke:#000,stroke-width:1px;
    classDef platform fill:#FAD7A0,stroke:#000,stroke-width:1px;
    classDef external fill:#76D7C4,stroke:#000,stroke-width:1px;
    classDef config fill:#F5B7B1,stroke:#000,stroke-width:1px;
```
