# changyy/chromecast_dlna_finder_dart architecture

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

- Interactive diagram: https://gitdiagram.com/changyy/chromecast_dlna_finder_dart
- Repository: https://github.com/changyy/chromecast_dlna_finder_dart

## Overview

##### Project type and purpose
- This is a Dart/Flutter library package (“chromecast_dlna_finder”) that also provides a CLI tool and example Flutter/Dart apps.
- Purpose: discover and categorize Chromecast and DLNA (and AirPlay) devices on the local network via mDNS and SSDP, expose results via JSON or Dart objects, and provide logging and i18n.

##### File structure
- Top‐level bins & examples:
- bin/ — CLI entry point (`chromecast_dlna_finder.dart`)
- example/ — sample Dart & Flutter applications
- Core code in lib/:
- lib/chromecast_dlna_finder.dart — public API
- lib/src/
– discovery/ — device model, discovery service, mDNS & SSDP scanner, caching
– locales/ — JSON files for i18n
– util/ — DLNA helpers, SOAP utilities, logging, platform detection, localization manager
- Docs & CI:
- doc/api/ — generated API docs
- .github/workflows — build & test pipelines
- test/ — unit & integration tests

##### README for additional insights
- It describes a modular architecture with clear separation:
- Main entry point (`ChromecastDlnaFinder`)
- Discovery Service that delegates to scanner modules
- Scanner modules for each protocol
- Caching & event streams for discovered devices
- Logger and Localization subsystems
- Lists supported platforms (mobile, desktop, web stub) and network requirements (ports 5353 for mDNS, 1900 for SSDP).

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Client Layer"
        CLI["CLI Application"]:::client
        ExampleApps["Flutter/Dart Examples"]:::client
    end

    subgraph "API Façade"
        Facade["ChromecastDlnaFinder"]:::facade
        BaseImpl["chromecast_dlna_finder_base"]:::facade
    end

    subgraph "Core Services"
        Discovery["DiscoveryService"]:::service
    end

    subgraph "Protocol Scanners"
        Mdns["MdnsScanner\n(port 5353)"]:::protocol
        Ssdp["SsdpScanner\n(port 1900)"]:::protocol
    end

    subgraph "Discovery Models"
        Device["DiscoveredDevice"]:::model
        Events["DiscoveryEvents"]:::model
        Cache["CachedDevice"]:::model
    end

    subgraph "Utilities"
        Logger["AppLogger"]:::util
        LocMgr["LocalizationManager"]:::util
        LocHelper["Localization Helper"]:::util
        PlatformInfo["PlatformInfo"]:::util
        PlatformStub["PlatformInfo_Stub"]:::util
        PlatformWeb["PlatformInfo_Web"]:::util
        Soap["DlnaSoapUtil"]:::util
        DlnaUtils["DlnaDeviceUtils"]:::util
    end

    subgraph "Locales"
        LocaleFiles["*.json"]:::locale
    end

    CLI -->|uses| Facade
    ExampleApps -->|uses| Facade

    Facade -->|calls| BaseImpl
    Facade -->|initializes| Logger
    Facade -->|initializes| LocMgr
    Facade -->|delegates| Discovery

    Discovery -->|starts| Mdns
    Discovery -->|starts| Ssdp

    Mdns -->|DeviceFoundEvent| Discovery
    Ssdp -->|DeviceFoundEvent| Discovery

    Discovery -->|caches| Cache
    Discovery -->|emits SearchCompleteEvent| Facade

    Discovery -->|uses| Device
    Discovery -->|uses| Events

    BaseImpl -->|uses| PlatformInfo
    BaseImpl -->|uses| LocMgr

    Mdns -->|uses| PlatformInfo
    Ssdp -->|uses| PlatformInfo

    Mdns -->|uses| Soap
    Ssdp -->|uses| Soap

    Facade -->|returns results| CLI
    Facade -->|returns results| ExampleApps

    classDef client fill:#ffeb99,stroke:#333,stroke-width:1px
    classDef facade fill:#bfffcf,stroke:#333,stroke-width:1px
    classDef service fill:#99ccff,stroke:#333,stroke-width:1px
    classDef protocol fill:#ffcc99,stroke:#333,stroke-width:1px
    classDef model fill:#dfefff,stroke:#333,stroke-width:1px
    classDef util fill:#dddddd,stroke:#333,stroke-width:1px
    classDef locale fill:#fff2cc,stroke:#333,stroke-width:1px

    click CLI "https://github.com/changyy/chromecast_dlna_finder_dart/blob/main/bin/chromecast_dlna_finder.dart"
    click ExampleApps "https://github.com/changyy/chromecast_dlna_finder_dart/tree/main/example/"
    click Facade "https://github.com/changyy/chromecast_dlna_finder_dart/blob/main/lib/chromecast_dlna_finder.dart"
    click BaseImpl "https://github.com/changyy/chromecast_dlna_finder_dart/blob/main/lib/src/chromecast_dlna_finder_base.dart"
    click Discovery "https://github.com/changyy/chromecast_dlna_finder_dart/blob/main/lib/src/discovery/discovery_service.dart"
    click Mdns "https://github.com/changyy/chromecast_dlna_finder_dart/blob/main/lib/src/discovery/mdns_scanner.dart"
    click Ssdp "https://github.com/changyy/chromecast_dlna_finder_dart/blob/main/lib/src/discovery/ssdp_scanner.dart"
    click Cache "https://github.com/changyy/chromecast_dlna_finder_dart/blob/main/lib/src/discovery/cached_device.dart"
    click Device "https://github.com/changyy/chromecast_dlna_finder_dart/blob/main/lib/src/discovery/device.dart"
    click Events "https://github.com/changyy/chromecast_dlna_finder_dart/blob/main/lib/src/discovery/discovery_events.dart"
    click LocaleFiles "https://github.com/changyy/chromecast_dlna_finder_dart/tree/main/lib/src/locales/"
    click LocMgr "https://github.com/changyy/chromecast_dlna_finder_dart/blob/main/lib/src/util/localization_manager.dart"
    click LocHelper "https://github.com/changyy/chromecast_dlna_finder_dart/blob/main/lib/src/util/localization.dart"
    click Logger "https://github.com/changyy/chromecast_dlna_finder_dart/blob/main/lib/src/util/logger.dart"
    click PlatformInfo "https://github.com/changyy/chromecast_dlna_finder_dart/blob/main/lib/src/util/platform_info.dart"
    click PlatformStub "https://github.com/changyy/chromecast_dlna_finder_dart/blob/main/lib/src/util/platform_info_stub.dart"
    click PlatformWeb "https://github.com/changyy/chromecast_dlna_finder_dart/blob/main/lib/src/util/platform_info_web.dart"
    click Soap "https://github.com/changyy/chromecast_dlna_finder_dart/blob/main/lib/src/util/dlna_soap_util.dart"
    click DlnaUtils "https://github.com/changyy/chromecast_dlna_finder_dart/blob/main/lib/src/util/dlna_device_utils.dart"
```
