# jordond/connectivity architecture

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

- Interactive diagram: https://gitdiagram.com/jordond/connectivity
- Repository: https://github.com/jordond/connectivity

## Overview

- connectivity-core – the base/common library with shared logic and APIs;
- platform-specific modules such as connectivity-android, connectivity-apple, and connectivity-device that use native APIs;
- connectivity-http – an implementation that uses HTTP polling to determine connectivity status;
- connectivity-compose and its variants – composable integrations for Compose Multiplatform; and
- a demo application that shows how to use the library across multiple platforms.

The overall design shows a clear separation between the common core logic and platform-specific implementations (device vs. HTTP). There is also a well-organized build system (utilizing Gradle Kotlin DSL scripts, convention plugins, and a buildLogic folder for build configurations) along with CI/CD configuration inside the .github directory.

##### Main Components
- Connectivity Core: The central module that holds the shared connectivity logic and API definitions.
- Platform-Specific Modules: These include:
- connectivity-android
- connectivity-apple
- connectivity-device
- connectivity-http
- Compose Integrations: Composing connectivity state for UI with modules such as connectivity-compose, connectivity-compose-device, and connectivity-compose-http.
- Build & CI/CD Infrastructure: Represent the Gradle scripts, buildLogic conventions (to centralize configuration), and GitHub workflows that automate testing and publishing.
- Demo Applications: Demo/composeApp and demo/iosApp folders which show real usage and integration.

##### Relationships and Interactions
- How the compose modules extend the functionality of the basic connectivity modules to provide UI composable integrations.
- How the demo apps depend on one or more connectivity modules (for instance, the demo app on composeApp referencing both Android and common multiplatform connectivity modules).

##### Architectural Patterns and Design Principles
- Separation of Concerns: The design clearly separates core logic (connectivity-core) from specific implementations.
- Multiplatform Paradigm: Indicate how the commonMain source set is shared and how platform-specific source sets (such as androidMain, appleMain, etc.) extend the shared logic.
- Modularity: Each platform-specific implementation and the corresponding compose wrapper is modular, ensuring easy updates/isolation.
- Dependency Injection / Factory Pattern: The factory function Connectivity() that creates instances based on platform can be highlighted.

##### Technologies, Frameworks, and Tools
- Kotlin Multiplatform: The project relies on Kotlin’s multiplatform capabilities.
- Gradle Kotlin DSL: Used for builds (refer to build.gradle.kts in many modules) and centralized build logic in buildLogic.
- Compose Multiplatform: For UI integration in the compose modules.
- Testing Frameworks: The file structure includes androidUnitTest and commonTest directories.
- GitHub Actions: The .github/workflows indicates CI/CD usage for continuous integration and publishing.

## Diagram (Mermaid)

```mermaid
graph TD
    subgraph "Core Modules"
        Core["Connectivity Core"]:::core
    end

    subgraph "Platform-Specific Modules"
        Android["Android Connectivity: Uses Android native APIs"]:::platform
        Apple["Apple Connectivity: Uses iOS native APIs"]:::platform
        Device["Device Connectivity: Uses device-level APIs"]:::platform
        HTTP["HTTP Connectivity: Uses HTTP polling"]:::platform
    end

    subgraph "Compose Integrations"
        ComposeGen["Compose Integration"]:::compose
        ComposeDevice["Compose Integration for Device"]:::compose
        ComposeHTTP["Compose Integration for HTTP"]:::compose
    end

    subgraph "Build & CI/CD"
        BuildLogic["Gradle BuildLogic"]:::build
        GitHub["GitHub Actions (.github)"]:::build
    end

    subgraph "Demo Applications"
        DemoCompose["Demo Compose App"]:::demo
        DemoiOS["Demo iOS App"]:::demo
    end

    %% Core dependencies to Platform-Specific Modules
    Core -->|"depends"| Android
    Core -->|"depends"| Apple
    Core -->|"depends"| Device
    Core -->|"depends"| HTTP

    %% Core integrations with Compose Modules
    Core -->|"integrated"| ComposeGen
    Core -->|"integrated"| ComposeDevice
    Core -->|"integrated"| ComposeHTTP

    %% Compose Modules wrapping underlying implementations
    ComposeDevice -->|"wraps"| Device
    ComposeHTTP -->|"wraps"| HTTP

    %% Demo Applications using modules
    DemoCompose -->|"uses"| ComposeGen
    DemoCompose -->|"uses"| Android
    DemoiOS -->|"uses"| Apple

    %% Build system supports all modules (dotted arrows)
    BuildLogic -.->|"builds"| Core
    BuildLogic -.->|"builds"| Android
    BuildLogic -.->|"builds"| Apple
    BuildLogic -.->|"builds"| Device
    BuildLogic -.->|"builds"| HTTP
    BuildLogic -.->|"builds"| ComposeGen
    BuildLogic -.->|"builds"| ComposeDevice
    BuildLogic -.->|"builds"| ComposeHTTP
    BuildLogic -.->|"builds"| DemoCompose
    BuildLogic -.->|"builds"| DemoiOS

    GitHub -.->|"CI/CD"| Core
    GitHub -.->|"CI/CD"| Android
    GitHub -.->|"CI/CD"| Apple
    GitHub -.->|"CI/CD"| Device
    GitHub -.->|"CI/CD"| HTTP
    GitHub -.->|"CI/CD"| ComposeGen
    GitHub -.->|"CI/CD"| ComposeDevice
    GitHub -.->|"CI/CD"| ComposeHTTP
    GitHub -.->|"CI/CD"| DemoCompose
    GitHub -.->|"CI/CD"| DemoiOS

    %% Click Events
    click Core "https://github.com/jordond/connectivity/tree/main/connectivity-core"
    click Android "https://github.com/jordond/connectivity/tree/main/connectivity-android"
    click Apple "https://github.com/jordond/connectivity/tree/main/connectivity-apple"
    click Device "https://github.com/jordond/connectivity/tree/main/connectivity-device"
    click HTTP "https://github.com/jordond/connectivity/tree/main/connectivity-http"
    click ComposeGen "https://github.com/jordond/connectivity/tree/main/connectivity-compose"
    click ComposeDevice "https://github.com/jordond/connectivity/tree/main/connectivity-compose-device"
    click ComposeHTTP "https://github.com/jordond/connectivity/tree/main/connectivity-compose-http"
    click BuildLogic "https://github.com/jordond/connectivity/tree/main/buildLogic"
    click GitHub "https://github.com/jordond/connectivity/blob/main/.github"
    click DemoCompose "https://github.com/jordond/connectivity/tree/main/demo/composeApp"
    click DemoiOS "https://github.com/jordond/connectivity/tree/main/demo/iosApp"

    %% Styles
    classDef core fill:#a2d8f0,stroke:#333,stroke-width:2px;
    classDef platform fill:#f7d794,stroke:#333,stroke-width:2px;
    classDef compose fill:#c1fba4,stroke:#333,stroke-width:2px;
    classDef build fill:#fab1a0,stroke:#333,stroke-width:2px;
    classDef demo fill:#ffcc5c,stroke:#333,stroke-width:2px;
```
