# stevdza-san/nutrisport architecture

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

- Interactive diagram: https://gitdiagram.com/stevdza-san/nutrisport
- Repository: https://github.com/stevdza-san/nutrisport

## Overview

##### Project Type and Purpose
- This is a Kotlin Multiplatform (KMP) mobile e-commerce application targeting both Android and iOS.
- It follows a multi-module, clean-architecture style: UI in feature modules, shared UI components, domain/data layers, navigation, DI, and backend Firebase functions.

##### File Structure
- Top-level modules:
- composeApp: the Android Compose Multiplatform host.
- iosApp: the native iOS SwiftUI/Swift host.
- data: common repository implementations and domain interfaces.
- di: Koin modules for dependency injection per platform and common.
- navigation: shared navigation graph.
- shared: common UI components, resources, domain models, and utilities.
- feature/*: one module per feature (auth, home, categories, cart, checkout, details, payment_completed, profile, admin_panel/manage_product).
- FIREBASE: cloud functions folder for server-side logic.
- Build scripts and configuration files: Gradle Kotlin DSL for module builds, google-services.json, Firebase config, Xcode projects, etc.

##### README
- Confirms the app is an online course example: a multi-modular e-commerce app built with KMP and Firebase.

##### Main Components to Model
a. Mobile Hosts
- Android Host (composeApp)
- iOS Host (iosApp)
b. Shared Layers
- UI Layer: feature modules + shared components
- Navigation Layer (navigation module)
- DI Layer (di module)
- Domain/Data Layer (data module + shared domain types)
c. External Services
- Firebase Cloud Functions (FIREBASE/functions)
- Firebase Auth & Firestore (configured via google-services.json)

##### Relationships and Interactions
- Hosts → inject DI modules (android or iOS) → expose ViewModels and Screens from feature modules.
- Feature Screens call ViewModels → injected domain interfaces (e.g., ProductRepository, OrderRepository).
- Repositories in data module call Firebase services or Cloud Functions.
- Navigation module provides NavGraph to wire feature screens.
- Shared module provides UI widgets, composable resources, and common domain models.

##### Architectural Patterns and Principles
- Clean architecture (separation into UI, domain, data).
- MVVM in each feature (Screen + ViewModel).
- Kotlin Multiplatform for code reuse across Android/iOS.
- DI via Koin modules (common + platform).
- Feature-based modularization for independent development and fast builds.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Mobile Hosts
    subgraph "Mobile Hosts"
        Android["Android Host"]:::host
        iOS["iOS Host"]:::host
    end

    Android -->|"Koin DI"| AndroidDI["KoinModule.android.kt"]:::shared
    iOS -->|"Koin DI"| iOSDI["KoinModule.ios.kt"]:::shared

    click Android "https://github.com/stevdza-san/nutrisport/tree/main/composeApp/"
    click iOS "https://github.com/stevdza-san/nutrisport/tree/main/iosApp/"
    click AndroidDI "https://github.com/stevdza-san/nutrisport/blob/main/di/src/androidMain/kotlin/com/nutrisport/di/KoinModule.android.kt"
    click iOSDI "https://github.com/stevdza-san/nutrisport/blob/main/di/src/iosMain/kotlin/com/nutrisport/di/KoinModule.ios.kt"

    %% Shared KMP Modules
    subgraph "Shared KMP Modules"
        Nav["Navigation Module"]:::shared
        CommonDI["KoinModule.kt"]:::shared

        subgraph "Shared UI & Models"
            UIComp["PrimaryButton.kt"]:::shared
            DomainModels["Product.kt"]:::shared
        end

        subgraph "Domain/Data Interfaces"
            ProdInt["ProductRepository"]:::shared
            OrdInt["OrderRepository"]:::shared
            CustInt["CustomerRepository"]:::shared
            AdminInt["AdminRepository"]:::shared
        end
    end

    click Nav "https://github.com/stevdza-san/nutrisport/blob/main/navigation/src/commonMain/kotlin/com/nutrisport/navigation/NavGraph.kt"
    click CommonDI "https://github.com/stevdza-san/nutrisport/blob/main/di/src/commonMain/kotlin/com/nutrisport/di/KoinModule.kt"
    click UIComp "https://github.com/stevdza-san/nutrisport/blob/main/shared/src/commonMain/kotlin/com/nutrisport/shared/component/PrimaryButton.kt"
    click DomainModels "https://github.com/stevdza-san/nutrisport/blob/main/shared/src/commonMain/kotlin/com/nutrisport/shared/domain/Product.kt"
    click ProdInt "https://github.com/stevdza-san/nutrisport/blob/main/data/src/commonMain/kotlin/com/nutrisport/data/domain/ProductRepository.kt"
    click OrdInt "https://github.com/stevdza-san/nutrisport/blob/main/data/src/commonMain/kotlin/com/nutrisport/data/domain/OrderRepository.kt"
    click CustInt "https://github.com/stevdza-san/nutrisport/blob/main/data/src/commonMain/kotlin/com/nutrisport/data/domain/CustomerRepository.kt"
    click AdminInt "https://github.com/stevdza-san/nutrisport/blob/main/data/src/commonMain/kotlin/com/nutrisport/data/domain/AdminRepository.kt"

    %% Feature Modules
    subgraph "Feature Modules"
        Auth["AuthScreen"]:::feature
        Home["HomeGraphScreen"]:::feature
        Categories["CategoriesScreen"]:::feature
        CatSearch["CategorySearchScreen"]:::feature
        Products["ProductsOverviewScreen"]:::feature
        Cart["CartScreen"]:::feature
        Checkout["CheckoutScreen"]:::feature
        Details["DetailsScreen"]:::feature
        PaymentDone["PaymentCompleted"]:::feature
        Profile["ProfileScreen"]:::feature
        AdminPanel["AdminPanelScreen"]:::feature
        ManageProd["ManageProductScreen"]:::feature
    end

    click Auth "https://github.com/stevdza-san/nutrisport/blob/main/feature/auth/src/commonMain/kotlin/com/nutrisport/auth/AuthScreen.kt"
    click Home "https://github.com/stevdza-san/nutrisport/blob/main/feature/home/src/commonMain/kotlin/com/nutrisport/home/HomeGraphScreen.kt"
    click Categories "https://github.com/stevdza-san/nutrisport/blob/main/feature/home/categories/src/commonMain/kotlin/com/nutrisport/categories/CategoriesScreen.kt"
    click CatSearch "https://github.com/stevdza-san/nutrisport/blob/main/feature/home/categories/category_search/src/commonMain/kotlin/com/nutrisport/category_search/CategorySearchScreen.kt"
    click Products "https://github.com/stevdza-san/nutrisport/blob/main/feature/home/products_overview/src/commonMain/kotlin/com/nutrisport/products_overview/ProductsOverviewScreen.kt"
    click Cart "https://github.com/stevdza-san/nutrisport/blob/main/feature/home/cart/src/commonMain/kotlin/com/nutrisport/cart/CartScreen.kt"
    click Checkout "https://github.com/stevdza-san/nutrisport/blob/main/feature/home/cart/checkout/src/commonMain/kotlin/com/nutrisport/checkout/CheckoutScreen.kt"
    click Details "https://github.com/stevdza-san/nutrisport/blob/main/feature/details/src/commonMain/kotlin/com/nutrisport/details/DetailsScreen.kt"
    click PaymentDone "https://github.com/stevdza-san/nutrisport/blob/main/feature/payment_completed/src/commonMain/kotlin/com/nutrisport/payment_completed/PaymentCompleted.kt"
    click Profile "https://github.com/stevdza-san/nutrisport/blob/main/feature/profile/src/commonMain/kotlin/com/nutrisport/profile/ProfileScreen.kt"
    click AdminPanel "https://github.com/stevdza-san/nutrisport/blob/main/feature/admin_panel/src/commonMain/kotlin/com/nutrisport/admin_panel/AdminPanelScreen.kt"
    click ManageProd "https://github.com/stevdza-san/nutrisport/blob/main/feature/admin_panel/manage_product/src/commonMain/kotlin/com/nutrisport/manage_product/ManageProductScreen.kt"

    %% Dependencies to Shared KMP
    CommonDI -->|provides DI| Auth
    CommonDI -->|provides DI| Home
    CommonDI -->|provides DI| Categories
    CommonDI -->|provides DI| CatSearch
    CommonDI -->|provides DI| Products
    CommonDI -->|provides DI| Cart
    CommonDI -->|provides DI| Checkout
    CommonDI -->|provides DI| Details
    CommonDI -->|provides DI| PaymentDone
    CommonDI -->|provides DI| Profile
    CommonDI -->|provides DI| AdminPanel
    CommonDI -->|provides DI| ManageProd

    Nav -->|navigation graph| Auth
    Nav -->|navigation graph| Home
    Nav -->|navigation graph| Categories
    Nav -->|navigation graph| Products
    Nav -->|navigation graph| Cart
    Nav -->|navigation graph| Checkout
    Nav -->|navigation graph| Details
    Nav -->|navigation graph| PaymentDone
    Nav -->|navigation graph| Profile
    Nav -->|navigation graph| AdminPanel
    Nav -->|navigation graph| ManageProd

    UIComp -->|shared UI| Auth
    UIComp -->|shared UI| Home
    UIComp -->|shared UI| Categories
    UIComp -->|shared UI| CatSearch
    UIComp -->|shared UI| Products
    UIComp -->|shared UI| Cart
    UIComp -->|shared UI| Checkout
    UIComp -->|shared UI| Details
    UIComp -->|shared UI| PaymentDone
    UIComp -->|shared UI| Profile
    UIComp -->|shared UI| AdminPanel
    UIComp -->|shared UI| ManageProd

    %% Features to Domain Interfaces
    Auth -->|uses| ProdInt
    Home -->|uses| ProdInt
    Categories -->|uses| ProdInt
    CatSearch -->|uses| ProdInt
    Products -->|uses| ProdInt
    Cart -->|uses| ProdInt
    Checkout -->|uses| OrdInt
    Details -->|uses| ProdInt
    PaymentDone -->|uses| OrdInt
    Profile -->|uses| CustInt
    AdminPanel -->|uses| AdminInt
    ManageProd -->|uses| AdminInt

    %% Repository Implementations
    subgraph "Repository Implementations"
        ProdImpl["ProductRepositoryImpl"]:::shared
        OrdImpl["OrderRepositoryImpl"]:::shared
        CustImpl["CustomerRepositoryImpl"]:::shared
        AdminImpl["AdminRepositoryImpl"]:::shared
    end

    click ProdImpl "https://github.com/stevdza-san/nutrisport/blob/main/data/src/commonMain/kotlin/com/nutrisport/data/ProductRepositoryImpl.kt"
    click OrdImpl "https://github.com/stevdza-san/nutrisport/blob/main/data/src/commonMain/kotlin/com/nutrisport/data/OrderRepositoryImpl.kt"
    click CustImpl "https://github.com/stevdza-san/nutrisport/blob/main/data/src/commonMain/kotlin/com/nutrisport/data/CustomerRepositoryImpl.kt"
    click AdminImpl "https://github.com/stevdza-san/nutrisport/blob/main/data/src/commonMain/kotlin/com/nutrisport/data/AdminRepositoryImpl.kt"

    ProdInt -->|implemented by| ProdImpl
    OrdInt -->|implemented by| OrdImpl
    CustInt -->|implemented by| CustImpl
    AdminInt -->|implemented by| AdminImpl

    %% External Services
    subgraph "Firebase Services"
        Functions["Cloud Functions"]:::external
        Firestore["Firestore"]:::external
        AuthService["Auth Service"]:::external
    end

    click Functions "https://github.com/stevdza-san/nutrisport/blob/main/FIREBASE/functions/index.js"

    ProdImpl -->|RPC calls| Functions
    OrdImpl -->|RPC calls| Functions
    CustImpl -->|RPC calls| Functions
    AdminImpl -->|RPC calls| Functions

    Functions -->|reads/writes| Firestore
    Functions -->|auth| AuthService

    %% Styles
    classDef host fill:#ADD8E6,stroke:#000,color:#000
    classDef shared fill:#90EE90,stroke:#000,color:#000
    classDef feature fill:#FFFFE0,stroke:#000,color:#000
    classDef external fill:#FFA500,stroke:#000,color:#000
```
