# leboncoin/spark-ios-component-text-input architecture

> Architecture diagram of the GitHub repository leboncoin/spark-ios-component-text-input, 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/leboncoin/spark-ios-component-text-input
- Repository: https://github.com/leboncoin/spark-ios-component-text-input

## Overview

##### Project Overview
- Project type: A design system component library for iOS, specifically offering customizable TextField (including variants with addons) and TextEditor components.

##### Main Architectural Components
- SparkTextInput Package – Central Swift package managed using Swift Package Manager.
- Core Modules:
a. Common Module:
- Contains shared constants, enumerations, models, use cases, and a view model for text input elements.
b. TextField Module:
- Split into subcomponents: the base TextField component and its Addons.
- Separate implementation folders for UIKit and SwiftUI views.
- Contains dedicated ViewModels and additional use cases.
c. TextEditor Module:
- Provides the TextEditor component’s implementations in both SwiftUI and UIKit.
- Contains its own use case (e.g., for vertical spacing) and ViewModel.

##### Relationships and Data Flow
- Each UI component (TextField and TextEditor) is implemented separately for UIKit and SwiftUI – this separation should be reflected by splitting the views into distinct branches.
- The Addons for TextField extend the base component functionality with additional supporting views, view models, and accessibility identifiers.
- Testing components are logically separate – unit tests verify use cases and view models, while snapshot tests validate UI rendering for both UIKit and SwiftUI implementations.

##### Important Architectural Patterns
- MVVM (Model-View-ViewModel): Both TextField and TextEditor use this pattern with clear separation between the view (SwiftUI or UIKit), the view model (which encapsulates the UI logic), and the model (provided by common configurations).
- Modularization: Projects are split into “Common”, “TextField” (and its addons), and “TextEditor” folders, clearly indicating separation of concerns.

##### Elements
- From that, create branches for:
- Common Module: inside it, list “Constants”, “Enums”, “Models”, “Use Cases”, and “ViewModel”.
- TextField Module: further branch into two:
- Base TextField
- TextField with Addons (include sub-branches for SwiftUI and UIKit implementations, along with their ViewModels).
- TextEditor Module: branch into SwiftUI and UIKit implementations, plus its own Use Case and ViewModel.
- A separate branch for CI/CD workflows (GitHub Actions defined in the .github directory) indicating tasks like building demo apps and deploying documentation.

## Diagram (Mermaid)

```mermaid
flowchart TD
    package["SparkTextInput Package"]:::package

    subgraph "Common Module"
        commonConstants["TextInputConstants"]:::common
        commonEnumBS["TextInputBorderStyle"]:::common
        commonEnumIntent["TextInputIntent"]:::common
        commonModelBL["TextInputBorderLayout"]:::common
        commonModelColors["TextInputColors"]:::common
        commonModelSp["TextInputSpacings"]:::common
        commonUC_BL["TextInputGetBorderLayoutUseCase"]:::common
        commonUC_Color["TextInputGetColorsUseCase"]:::common
        commonUC_Spacing["TextInputGetSpacingsUseCase"]:::common
        commonVM["TextInputViewModel"]:::common
    end

    subgraph "TextField Module"
        subgraph "Base TextField Component"
            tfUIKit["TextFieldUIView (UIKit)"]:::textfield
            tfSwiftUI["TextFieldView (SwiftUI)"]:::textfield
            tfAcc["TextFieldAccessibilityIdentifier"]:::textfield
        end
        subgraph "TextField Addons"
            tfAddonUIKit["TextFieldAddonsUIView (UIKit)"]:::textfield
            tfAddonSwiftUI["TextFieldAddon (SwiftUI)"]:::textfield
            tfAddonsVM["TextFieldAddonsViewModel"]:::textfield
            tfViewModelForAddons["TextFieldViewModelForAddons"]:::textfield
            tfAddonAcc["TextFieldAddonsAccessibilityIdentifier"]:::textfield
        end
        tfEnum["TextFieldIntent Enum"]:::textfield
    end

    subgraph "TextEditor Module"
        teUIKit["TextEditorUIView (UIKit)"]:::texteditor
        teSwiftUI["TextEditorView (SwiftUI)"]:::texteditor
        teAcc["TextEditorAccessibiltyIdentifier"]:::texteditor
        teEnum["TextEditorIntent Enum"]:::texteditor
        teUC["TextEditorGetVerticalSpacingUseCase"]:::texteditor
        teVM["TextEditorViewModel"]:::texteditor
    end

    subgraph "Testing Components"
        testCommon["Common Unit Tests"]:::testing
        testTE["TextEditor Unit Tests"]:::testing
        testTFAddons["TextField Addons Unit Tests"]:::testing
        snapshotTests["Snapshot Tests"]:::testing
    end

    subgraph "CI/CD Workflows"
        ciActions["GitHubActions Workflow"]:::cicd
        ciBuild["BuildDemoApp Workflow"]:::cicd
        ciDeploy["DeployDocCPage Workflow"]:::cicd
    end

    %% Package to Modules Connections
    package --> commonConstants
    package --> tfUIKit
    package --> teUIKit
    package --> testCommon
    package --> ciActions

    %% Internal Common Module Relationships
    commonConstants --> commonUC_BL
    commonEnumBS --> commonUC_Color
    commonEnumIntent --> commonUC_Spacing
    commonModelBL --> commonUC_BL
    commonModelColors --> commonUC_Color
    commonModelSp --> commonUC_Spacing
    commonUC_BL --> commonVM
    commonUC_Color --> commonVM
    commonUC_Spacing --> commonVM

    %% Common to TextField and TextEditor Dependencies
    commonVM --> tfUIKit
    commonVM --> tfSwiftUI
    commonVM --> tfAddonUIKit
    commonVM --> tfAddonSwiftUI
    commonVM --> teUIKit
    commonVM --> teSwiftUI

    %% TextField Module Relationships
    tfUIKit --> tfAcc
    tfSwiftUI --> tfAcc
    tfAddonsVM --> tfAddonUIKit
    tfAddonsVM --> tfAddonSwiftUI
    tfViewModelForAddons --> tfAddonUIKit
    tfViewModelForAddons --> tfAddonSwiftUI

    %% TextEditor Module Relationships
    teUC --> teVM
    teVM --> teUIKit
    teVM --> teSwiftUI

    %% Testing Relationships
    testCommon --> commonVM
    testTE --> teVM
    testTFAddons --> tfAddonsVM
    snapshotTests --> tfUIKit
    snapshotTests --> teUIKit

    %% Click Events
    click package "https://github.com/leboncoin/spark-ios-component-text-input/blob/main/Package.swift"
    click commonConstants "https://github.com/leboncoin/spark-ios-component-text-input/blob/main/Sources/Core/Common/Constants/TextInputConstants.swift"
    click commonEnumBS "https://github.com/leboncoin/spark-ios-component-text-input/blob/main/Sources/Core/Common/Enum/TextInputBorderStyle.swift"
    click commonEnumIntent "https://github.com/leboncoin/spark-ios-component-text-input/blob/main/Sources/Core/Common/Enum/TextInputIntent.swift"
    click commonModelBL "https://github.com/leboncoin/spark-ios-component-text-input/blob/main/Sources/Core/Common/Model/TextInputBorderLayout.swift"
    click commonModelColors "https://github.com/leboncoin/spark-ios-component-text-input/blob/main/Sources/Core/Common/Model/TextInputColors.swift"
    click commonModelSp "https://github.com/leboncoin/spark-ios-component-text-input/blob/main/Sources/Core/Common/Model/TextInputSpacings.swift"
    click commonUC_BL "https://github.com/leboncoin/spark-ios-component-text-input/blob/main/Sources/Core/Common/UseCase/TextInputGetBorderLayoutUseCase.swift"
    click commonUC_Color "https://github.com/leboncoin/spark-ios-component-text-input/blob/main/Sources/Core/Common/UseCase/TextInputGetColorsUseCase.swift"
    click commonUC_Spacing "https://github.com/leboncoin/spark-ios-component-text-input/blob/main/Sources/Core/Common/UseCase/TextInputGetSpacingsUseCase.swift"
    click commonVM "https://github.com/leboncoin/spark-ios-component-text-input/blob/main/Sources/Core/Common/ViewModel/TextInputViewModel.swift"

    click tfUIKit "https://github.com/leboncoin/spark-ios-component-text-input/blob/main/Sources/Core/TextField/View/UIKit/TextFieldUIView.swift"
    click tfSwiftUI "https://github.com/leboncoin/spark-ios-component-text-input/blob/main/Sources/Core/TextField/View/SwiftUI/TextFieldView.swift"
    click tfAcc "https://github.com/leboncoin/spark-ios-component-text-input/blob/main/Sources/Core/TextField/View/AccessibilityIdentifiier/TextFieldAccessibilityIdentifier.swift"
    click tfAddonUIKit "https://github.com/leboncoin/spark-ios-component-text-input/blob/main/Sources/Core/TextField/Addons/View/UIKit/TextFieldAddonsUIView.swift"
    click tfAddonSwiftUI "https://github.com/leboncoin/spark-ios-component-text-input/blob/main/Sources/Core/TextField/Addons/View/SwiftUI/TextFieldAddon.swift"
    click tfAddonsVM "https://github.com/leboncoin/spark-ios-component-text-input/blob/main/Sources/Core/TextField/Addons/ViewModel/TextFieldAddonsViewModel.swift"
    click tfViewModelForAddons "https://github.com/leboncoin/spark-ios-component-text-input/blob/main/Sources/Core/TextField/Addons/ViewModel/TextFieldViewModelForAddons.swift"
    click tfAddonAcc "https://github.com/leboncoin/spark-ios-component-text-input/blob/main/Sources/Core/TextField/Addons/View/AccessibilityIdentifiier/TextFieldAddonsAccessibilityIdentifier.swift"
    click tfEnum "https://github.com/leboncoin/spark-ios-component-text-input/blob/main/Sources/Core/TextField/Enum/TextFieldIntent.swift"

    click teUIKit "https://github.com/leboncoin/spark-ios-component-text-input/blob/main/Sources/Core/TextEditor/View/UIKit/TextEditorUIView.swift"
    click teSwiftUI "https://github.com/leboncoin/spark-ios-component-text-input/blob/main/Sources/Core/TextEditor/View/SwiftUI/TextEditorView.swift"
    click teAcc "https://github.com/leboncoin/spark-ios-component-text-input/blob/main/Sources/Core/TextEditor/AccessibilityIdentifier/TextEditorAccessibiltyIdentifier.swift"
    click teEnum "https://github.com/leboncoin/spark-ios-component-text-input/blob/main/Sources/Core/TextEditor/Enum/TextEditorIntent.swift"
    click teUC "https://github.com/leboncoin/spark-ios-component-text-input/blob/main/Sources/Core/TextEditor/UseCase/TextEditorGetVerticalSpacingUseCase.swift"
    click teVM "https://github.com/leboncoin/spark-ios-component-text-input/blob/main/Sources/Core/TextEditor/ViewModel/TextEditorViewModel.swift"

    click testCommon "https://github.com/leboncoin/spark-ios-component-text-input/blob/main/Tests/UnitTests/Common/UseCase/TextInputGetBorderLayoutUseCaseTests.swift"
    click testTE "https://github.com/leboncoin/spark-ios-component-text-input/blob/main/Tests/UnitTests/TextEditor/UseCase/TextEditorGetVerticalSpacingUseCaseTests.swift"
    click testTFAddons "https://github.com/leboncoin/spark-ios-component-text-input/blob/main/Tests/UnitTests/TextField/Addons/ViewModel/TextFieldAddonsViewModelTests.swift"
    click snapshotTests "https://github.com/leboncoin/spark-ios-component-text-input/tree/main/Tests/SnapshotTests/"
    click ciActions "https://github.com/leboncoin/spark-ios-component-text-input/blob/main/.github/workflows/actions.yml"
    click ciBuild "https://github.com/leboncoin/spark-ios-component-text-input/blob/main/.github/workflows/buildDemoApp.yml"
    click ciDeploy "https://github.com/leboncoin/spark-ios-component-text-input/blob/main/.github/workflows/deployDocCPage.yml"

    %% Styling classes
    class package package
    class common common
    class textfield textfield
    class texteditor texteditor
    class testing testing
    class cicd cicd

classDef package fill:#D5F5E3,stroke:#196F3D,stroke-width:2px;
classDef common fill:#AED6F1,stroke:#2980B9,stroke-width:2px;
classDef textfield fill:#A9DFBF,stroke:#27AE60,stroke-width:2px;
classDef texteditor fill:#F9E79F,stroke:#D4AC0D,stroke-width:2px;
classDef testing fill:#E8DAEF,stroke:#8E44AD,stroke-width:2px;
classDef cicd fill:#FAD7A0,stroke:#D35400,stroke-width:2px;
```
