# huri000/swiftentrykit architecture

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

- Interactive diagram: https://gitdiagram.com/huri000/swiftentrykit
- Repository: https://github.com/huri000/swiftentrykit

## Overview

##### Project Type and Purpose
- SwiftEntryKit is an iOS UI library used to present customizable notification entries. It is designed to offer a wide array of display options (positioning, styling, animations, haptics, lifecycle events, etc.) by creating separate windows that display entries without interfering with the main app’s navigation.

##### Analyzing the File Structure
- There is a clear separation between the example project (in the “Example” directory), the source code (in the “Source” directory), and tests (in the “Tests” directory).
- Within “Source” you see further subdivisions:
- Extensions: Contains helper utilities and UI layout extensions.
- Infra: Contains classes related to window and view management (e.g., EKWindow, EKRootViewController, and various content view wrappers) that create and manage the separate UIWindow instances.
- MessageViews: Contains pre-built UI components like banners, alerts, pop-ups, and different message views (with subdirectories for notes, alerts, etc.).
- Model: Defines data models such as EKAlertMessage, EKNotificationMessage, and the EKAttributes structure that drives the configuration for all entries.
- Utils: Contains utility components (e.g., gradient views, haptic feedback generators, responder extensions) that support the presentation logic.
- Other files like the podspec and Package.swift indicate how the library is packaged and distributed.

a. Main Components:
- SwiftEntryKit API Layer – the public API (i.e. SwiftEntryKit.display, dismiss, and related functions).
- Entry Attributes & Configuration – the EKAttributes struct (found in the Model folder) that contains all configurable parameters: display duration, animations, user interactions, background style, and more.
- UI Presentation Layer – the various MessageViews (like EKNotificationMessageView and others) that define the view appearance.
- Window Management – components in the Infra folder (EKWindow, EKWindowProvider, EKRootViewController, etc.) that manage the creation and life cycle of the UIWindow used for entry presentation.
- Utility & Extensions – modules from the Extensions and Utils folder that help support layout, custom animations, haptic feedback, and overall UI adjustments.
- Example/Demo – the example project providing practical usage, demonstrating how an application integrates and uses SwiftEntryKit.

b. Relationships and Interactions:
- The public API (SwiftEntryKit) accepts a custom view or view controller along with an EKAttributes configuration.
- The attributes (model/data) inform the UI Presentation Layer on how to animate, display, and interact with the entry.
- The UI Presentation Layer constructs and organizes the content view (using components from MessageViews) based on these attributes.
- The Infra layer then creates a dedicated UIWindow that hosts the entry view. This window is managed (shown/dismissed) with lifecycle events and animations per configuration.
- The dependency direction flows from the API invocation down to the infra (window creation), with back-and-forth interactions such as user-interaction events (e.g., swipe to dismiss) invoking callbacks.

c. Important Architectural Patterns and Design Principles:
- Modular Design: Separation into discrete modules such as Model, Infra, MessageViews, and Utils.
- Configuration-Driven Behavior: The EKAttributes configuration object enables a high degree of customization by decoupling the presentation behavior from the underlying view logic.
- Lifecycle Management: Use of event callbacks (willAppear, didAppear, etc.) to keep the UI responsive.
- Reusability and Extensibility: The extensive use of extensions, presets, and customization hooks signifies a design built for reuse across different UI patterns (toasts, alerts, pop-ups).
- Dependency Inversion: The library offers a clear public API (via SwiftEntryKit.display and related methods) decoupled from the internal components.

d. Relevant Technologies, Frameworks, or Libraries:
- iOS/Swift: Mention that the library heavily leverages UIKit components and iOS-specific UI window management.
- CocoaPods/Carthage/Accio: These build and dependency managers are used to integrate SwiftEntryKit in user projects.
- Animation, Haptic, and Layout Utilities: Internal use of custom animations, haptic feedback generators, and Auto Layout helpers.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Layers
    subgraph "API Layer"
        SAPI["SwiftEntryKit Public API"]:::api
    end

    subgraph "Configuration/Model Layer"
        EAC["Entry Attributes & Configuration"]:::config
    end

    subgraph "UI Presentation Layer"
        MPV["UI Presentation Layer (MessageViews)"]:::presentation
    end

    subgraph "Infrastructure Layer"
        WIN["Window Management"]:::infra
    end

    subgraph "Utility & Extensions"
        EXT["Extensions"]:::utility
        UTILS["Utils"]:::utility
    end

    subgraph "Example/Demo"
        DEMO["Example/Demo"]:::example
    end

    %% Relationships
    SAPI -->|"configures"| EAC
    EAC -->|"drives"| MPV
    MPV -->|"presented on"| WIN
    WIN -->|"lifecycle-callbacks"| SAPI
    SAPI -->|"demonstrated_in"| DEMO

    EXT -->|"aidsLayout"| MPV
    UTILS -->|"providesHaptic"| WIN

    %% Click Events
    click SAPI "https://github.com/huri000/swiftentrykit/blob/master/Source/SwiftEntryKit.swift"
    click EAC "https://github.com/huri000/swiftentrykit/blob/master/Source/Model/EntryAttributes/EKAttributes.swift"
    click MPV "https://github.com/huri000/swiftentrykit/tree/master/Source/MessageViews/"
    click WIN "https://github.com/huri000/swiftentrykit/tree/master/Source/Infra/"
    click EXT "https://github.com/huri000/swiftentrykit/tree/master/Source/Extensions/"
    click UTILS "https://github.com/huri000/swiftentrykit/tree/master/Source/Utils/"
    click DEMO "https://github.com/huri000/swiftentrykit/tree/master/Example/"

    %% Styles
    classDef api fill:#FFCC00,stroke:#333,stroke-width:2px;
    classDef config fill:#66FF66,stroke:#333,stroke-width:2px;
    classDef presentation fill:#66CCFF,stroke:#333,stroke-width:2px;
    classDef infra fill:#FF9966,stroke:#333,stroke-width:2px;
    classDef utility fill:#CC99FF,stroke:#333,stroke-width:2px;
    classDef example fill:#99FFCC,stroke:#333,stroke-width:2px;
```
