# rounaktadvi/internet_connection_checker architecture

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

- Interactive diagram: https://gitdiagram.com/rounaktadvi/internet_connection_checker
- Repository: https://github.com/rounaktadvi/internet_connection_checker

## Overview

##### Main Components

a) Core Components:
- InternetConnectionChecker (Main Controller)
- Address Check System
- Connection Status Monitor
- Slow Connection Detector

b) Supporting Components:
- Configuration Management
- Platform-specific Implementations
- Event Stream System

**┌─ Application Layer ─────────────────────────────┐**

- ┌─ Client Applications ─┐                  │
- Flutter Apps       │                  │
- Example App        │                  │
- ┘                 │

- Public API Layer ──────────────────────────────┤

- ┌─ InternetConnectionChecker ──┐          │
- hasConnection             │          │
- onStatusChange            │          │
- checkInterval             │          │
- ┘         │

- Core Services Layer ────────────────────────────┤

- ┌─ Address ─┐    ┌─ Connection ┐    ┌─ Slow ─┐│
- Checker  │    │   Monitor   │    │Detector││
- ┘    └────────────┘    └────────┘│

- Configuration Layer ─────────────────────────────┤

- ┌─ Address ─┐    ┌─ Connection ┐    ┌─ Slow ─┐│
- Options  │    │   Config    │    │ Config ││
- ┘    └────────────┘    └────────┘│

- ┘

##### Key Elements to Highlight

- Blue: Core components
- Green: Configuration elements
- Orange: Platform-specific implementations
- Purple: Event streams and callbacks

b) Connection Types:

##### Flow Representation

Main data flows:
**Client → InternetConnectionChecker → Address Checker**
- ↓
- Status Monitor
- ↓
- Event Stream → Client

##### Implementation Details

- Singleton pattern implementation
- Stream-based status monitoring
- Custom configuration options
- Platform-specific implementations
- Disposal and cleanup mechanisms

##### Notes for Implementation

- Use standard UML notation where appropriate
- Version information and platform support
- Error handling and fallback mechanisms

Remember to include notes about the disposal pattern and memory management, as these are crucial aspects of the library's implementation.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Application
        Client["Client Applications"]
        ExampleApp["Example App"]:::example
        click ExampleApp "https://github.com/RounakTadvi/internet_connection_checker/tree/main/example/lib"
    end

    subgraph "Public API"
        ICC["InternetConnectionChecker"]:::main
        click ICC "https://github.com/RounakTadvi/internet_connection_checker/blob/main/lib/internet_connection_checker.dart"
    end

    subgraph "Core Services"
        AddressCheck["Address Check System"]:::core
        ConnectionMonitor["Connection Status Monitor"]:::core
        SlowDetector["Slow Connection Detector"]:::core
        CoreImpl["Core Connection Implementation"]:::core

        click AddressCheck "https://github.com/RounakTadvi/internet_connection_checker/blob/main/lib/address_check_option.dart"
        click ConnectionMonitor "https://github.com/RounakTadvi/internet_connection_checker/blob/main/lib/internet_connection_status.dart"
        click SlowDetector "https://github.com/RounakTadvi/internet_connection_checker/blob/main/lib/slow_connection_config.dart"
        click CoreImpl "https://github.com/RounakTadvi/internet_connection_checker/blob/main/lib/internet_connection.dart"
    end

    subgraph "Configuration"
        Constants["Constants & Configuration"]:::config
        AddressOpt["Address Options"]:::config
        ConnConfig["Connection Config"]:::config
        SlowConfig["Slow Connection Config"]:::config

        click Constants "https://github.com/RounakTadvi/internet_connection_checker/blob/main/lib/internet_connection_checker_constants.dart"
    end

    subgraph "Implementation Examples"
        InternetCubit["Internet Cubit"]:::example
        SlowInternetCubit["Slow Internet Cubit"]:::example
        
        click InternetCubit "https://github.com/RounakTadvi/internet_connection_checker/blob/main/example/lib/blocs/internet_cubit/internet_cubit.dart"
        click SlowInternetCubit "https://github.com/RounakTadvi/internet_connection_checker/blob/main/example/lib/blocs/slow_internet_cubit/slow_internet_cubit.dart"
    end

    subgraph "Usage Examples"
        ConnStreamPage["Connection Stream Listener"]:::example
        SlowConnPage["Slow Connection Stream Listener"]:::example

        click ConnStreamPage "https://github.com/RounakTadvi/internet_connection_checker/blob/main/example/lib/pages/connection_stream_listener_page.dart"
        click SlowConnPage "https://github.com/RounakTadvi/internet_connection_checker/blob/main/example/lib/pages/slow_internet_connection_stream_listener_page.dart"
    end

    subgraph "Tests"
        ConnTest["Connection Tests"]:::test
        SlowConnTest["Slow Connection Tests"]:::test
        AddressOptTest["Address Option Tests"]:::test
        AddressResTest["Address Result Tests"]:::test

        click ConnTest "https://github.com/RounakTadvi/internet_connection_checker/blob/main/test/internet_connection_test.dart"
        click SlowConnTest "https://github.com/RounakTadvi/internet_connection_checker/blob/main/test/slow_connection_config_test.dart"
        click AddressOptTest "https://github.com/RounakTadvi/internet_connection_checker/blob/main/test/address_check_option_test.dart"
        click AddressResTest "https://github.com/RounakTadvi/internet_connection_checker/blob/main/test/address_check_result_test.dart"
    end

    Client --> ICC
    ExampleApp --> ICC
    ICC --> AddressCheck
    ICC --> ConnectionMonitor
    ICC --> SlowDetector
    ICC --> CoreImpl

    AddressCheck --> Constants
    ConnectionMonitor --> Constants
    SlowDetector --> Constants

    AddressCheck --> AddressOpt
    ConnectionMonitor --> ConnConfig
    SlowDetector --> SlowConfig

    InternetCubit --> ICC
    SlowInternetCubit --> ICC
    ConnStreamPage --> InternetCubit
    SlowConnPage --> SlowInternetCubit

    classDef main fill:#3498db,stroke:#2980b9,color:white
    classDef core fill:#2ecc71,stroke:#27ae60,color:white
    classDef config fill:#e74c3c,stroke:#c0392b,color:white
    classDef example fill:#9b59b6,stroke:#8e44ad,color:white
    classDef test fill:#f1c40f,stroke:#f39c12,color:black
```
