# ricardogs1/mipymeanabel architecture

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

- Interactive diagram: https://gitdiagram.com/ricardogs1/mipymeanabel
- Repository: https://github.com/ricardogs1/mipymeanabel

## Overview

This project is a Kotlin Multiplatform application aimed at delivering a mobile solution for both Android and iOS. The shared code is maintained under the composeApp module (particularly within its commonMain folder), while platform-specific implementations are found under androidMain and iosMain. An additional iOS-specific entry point is present under the iosApp directory where SwiftUI and other iOS configurations live.

- Shared Module (composeApp/commonMain): Contains the business logic, domain models, use cases, data sources, repositories (for authentication, products, orders, etc.), and common UI elements which are platform-agnostic.
- iOS-Specific Module (composeApp/iosMain and iosApp): Contains iOS-specific code including the main view controller (MainViewController.kt), any iOS-specific data configuration, and then further integration of SwiftUI code in iosApp, which acts as the entry point for the iOS application.
- Build and Configuration: Gradle files (build.gradle.kts, gradlew, etc.) and project configuration files (e.g., google-services.json, Info.plist, Config.xcconfig) which set up the build pipelines and integration with external services like Firebase.

##### Data Flow and Interactions
- How interaction events from the UI pass into the ViewModels (e.g., HomeViewModel, CartViewModel) within the shared code.
- From the ViewModels, highlight the use of domain-level use cases (e.g., AddCartUseCase, AuthUseCase) that manage business logic and coordinate with the data layer.
- The data layer is segmented into local data sources (RoomDataSource for database interactions) and remote data sources (FirebaseAuthDataSource, FirebaseDataSource) where actual data fetching and persistence occur.
- Mapping components (Mappers) that convert between data transfer objects (DTOs) and domain models.
- Communication with external services such as Firebase for notifications (FirebaseMessagingService in androidMain and its commonMain counterpart).

##### Architectural Patterns and Design Principles
- Multiplatform Layering: Differentiate common/shared code from platform-specific implementations, emphasizing code reuse and shared business logic.
- MVC/MVVM Influences: While not strictly enforced by the structure, note that the use of ViewModels (and associated UI screens) implies an MVVM-like pattern.
- Dependency Injection Module: Although not explicitly outlined in the file tree, the presence of NativeModule, DataModules, and StartModule suggests a modular design possibly using dependency injection; show this as a supporting layer if known.

##### Technologies and Frameworks
- Kotlin Multiplatform and Compose Multiplatform for shared UI.
- Android components (Activities, AndroidManifest) and resource layouts for Android.
- SwiftUI integration in the iosApp for iOS-specific UI.
- Firebase services, as indicated by the Google services files and Firebase-specific classes.
- Room (or other local DB frameworks) as the local database solution.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Build and Configuration Subgraph
    subgraph "1. Build and Configuration"
        A1("Gradle Build File (build.gradle.kts)"):::config
        A2("ComposeApp Gradle (composeApp/build.gradle.kts)"):::config
        A3("Android Google Services (composeApp/google-services.json)"):::config
        I1("iOS Config (iosApp/Configuration/Config.xcconfig)"):::config
        I2("iOS Google Service (iosApp/iosApp/GoogleService-Info.plist)"):::config
        I3("iOS Info (iosApp/iosApp/Info.plist)"):::config
        A1 --> A2
        A2 --> A3
        A3 --> I1
        I1 --> I2
        I2 --> I3
    end

    %% Shared Module Subgraph
    subgraph "2. Shared Module (composeApp/commonMain)"
        B1("UI Layer (Compose UI)"):::shared
        B2("ViewModels"):::shared
        B3("Use Cases"):::shared
        B4("Repositories"):::shared
        B5("Data Sources (Room, Firebase)"):::shared
        B6("Mappers"):::shared
        B1 --> B2
        B2 --> B3
        B3 --> B4
        B4 --> B5
        B5 -->|"mapsTo"| B6
        B5 -->|"calls"| F["Firebase Services"]:::firebase
    end

    %% Android-Specific Module Subgraph
    subgraph "3. Android-Specific Module"
        C1("Android Activities & Fragments"):::android
        C2("MiPymeAnabelApp.kt"):::android
        C3("FirebaseMessagingService"):::android
        C1 --> C2
        C2 --> C3
    end

    %% iOS-Specific Module Subgraph
    subgraph "4. iOS-Specific Module"
        D1("MainViewController"):::ios
        D2("SwiftUI Entry (ContentView & iOSApp)"):::ios
        D1 --> D2
    end

    %% Interconnections between layers and modules
    %% Build & Config sets up Shared and Platform modules
    A3 ---|"configures"| B1
    A3 ---|"configures"| C1
    I1 ---|"configures"| D2

    %% Platform-specific modules integrate with Shared Module
    C1 ---|"usesSharedUI"| B1
    C2 ---|"bindsToVM"| B2
    C3 ---|"integratesWithData"| B5
    D2 ---|"usesSharedUI"| B1
    D1 ---|"bindsToVM"| B2

    %% Click Events for Build and Configuration nodes
    click A1 "https://github.com/ricardogs1/mipymeanabel/blob/main/build.gradle.kts"
    click A2 "https://github.com/ricardogs1/mipymeanabel/blob/main/composeApp/build.gradle.kts"
    click A3 "https://github.com/ricardogs1/mipymeanabel/blob/main/composeApp/google-services.json"
    click I1 "https://github.com/ricardogs1/mipymeanabel/blob/main/iosApp/Configuration/Config.xcconfig"
    click I2 "https://github.com/ricardogs1/mipymeanabel/blob/main/iosApp/iosApp/GoogleService-Info.plist"
    click I3 "https://github.com/ricardogs1/mipymeanabel/blob/main/iosApp/iosApp/Info.plist"

    %% Click Events for Shared Module
    click B1 "https://github.com/ricardogs1/mipymeanabel/tree/main/composeApp/src/commonMain"

    %% Click Events for Android-Specific Module
    click C1 "https://github.com/ricardogs1/mipymeanabel/tree/main/composeApp/src/androidMain"
    click C2 "https://github.com/ricardogs1/mipymeanabel/tree/main/composeApp/src/androidMain/kotlin/com/virtualworld/mipymeanabel"
    click C3 "https://github.com/ricardogs1/mipymeanabel/tree/main/composeApp/src/androidMain/kotlin/com/virtualworld/mipymeanabel"

    %% Click Events for iOS-Specific Module
    click D1 "https://github.com/ricardogs1/mipymeanabel/tree/main/composeApp/src/iosMain"
    click D2 "https://github.com/ricardogs1/mipymeanabel/tree/main/iosApp"

    %% Styles
    classDef config fill:#f9e79f,stroke:#7d6608,stroke-width:2px,color:#000;
    classDef shared fill:#aed6f1,stroke:#2471a3,stroke-width:2px,color:#000;
    classDef android fill:#a9dfbf,stroke:#239b56,stroke-width:2px,color:#000;
    classDef ios fill:#f9c5d1,stroke:#c0392b,stroke-width:2px,color:#000;
    classDef firebase fill:#f5b7b1,stroke:#922b21,stroke-width:2px,color:#000;
```
