# lynx-family/integrating-lynx-demo-projects architecture

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

- Interactive diagram: https://gitdiagram.com/lynx-family/integrating-lynx-demo-projects
- Repository: https://github.com/lynx-family/integrating-lynx-demo-projects

## Overview

##### Project type and purpose
- This is a mono-repo containing four “empty” or template mobile apps that demonstrate integrating the Lynx runtime into existing projects.
- It is not a multi-tier web application with a service or database layer; instead it’s four stand-alone native mobile demos (two Android, two iOS) that all share a common Lynx “bundle” asset.

##### File structure
- Top level:
- LICENSE, README.md
- android/
– JavaEmptyProject/ (Gradle-Groovy Android demo)
– KotlinEmptyProject/ (Gradle-Kotlin Android demo)
- ios/
– HelloLynxObjc/ (Objective-C iOS demo)
– HelloLynxSwift/ (Swift iOS demo)
- Each Android sub-project:
- app/src/main/assets/main.lynx.bundle (the compiled Lynx template)
- app/src/main/java/...DemoTemplateProvider.java|kt (loads the bundle)
- Multiple Activities (MainActivity, DebugActivity, SwitchActivity)
- UI/theme packages, resources under res/
- Gradle scripts (build.gradle(.kts), settings.gradle(.kts), wrapper)
- Each iOS sub-project:
- main.lynx.bundle at root
- DemoLynxProvider.(h|m|swift) (loads the bundle)
- AppDelegate, SceneDelegate, ViewController
- Xcode project files, asset catalogs, storyboards, Podfile

##### README for additional insights
- Confirms these are “demo projects for getting started with integrating Lynx to existing project.”
- No backend, database, or external web services—purely native clients loading a pre‐built bundle.

##### Main components
a. Repository (mono-repo)
b. Android
- JavaEmptyProject
– Build system (Gradle-Groovy)
– Assets folder (.lynx.bundle)
– DemoTemplateProvider (native wrapper around Lynx engine)
– Activities (UI hosts)
– UI-theme modules
- KotlinEmptyProject (same breakdown but Gradle-Kotlin DSL)
c. iOS
- HelloLynxObjc
– Xcode/Pods build system
– Asset (main.lynx.bundle)
– DemoLynxProvider (ObjC)
– AppDelegate, SceneDelegate, ViewController (UI hosts)
- HelloLynxSwift (same breakdown in Swift)
d. Lynx Engine (shared across all four demos; loads .bundle and renders UI)
e. Build Steps (external tools that compile native code & bundle Lynx templates)

##### Relationships & data flows
- Build process → produces main.lynx.bundle → placed in app assets
- At runtime, DemoTemplateProvider → loads .bundle → hands template to Lynx Engine → Engine renders UI inside native host (Activity or ViewController)
- Native UI hosts may call into Lynx for navigation or theming via the provider

##### Architectural patterns & design principles
- Separation of concerns:
- Build / bundling step is distinct from runtime
- Platform-specific host code (Activities/ViewControllers) is separated from cross-platform template logic (Lynx bundle)
- Template provider abstraction: hides the Lynx runtime details behind a small native interface
- Consistent directory layout across demos for easy comparison

##### Detail
- Likewise for iOS
- This level of granularity helps spotlight exactly how and where Lynx integrates into each platform demo.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Android"
        subgraph "JavaEmptyProject"
            JavaBuild["Gradle Build System"]:::android
            JavaBundle["main.lynx.bundle"]:::asset
            JavaProvider["DemoTemplateProvider.java"]:::provider
            JavaTheme["UI Theme Modules"]:::android
            JavaUI["Activities (UI Hosts)"]:::ui
        end
        subgraph "KotlinEmptyProject"
            KotlinBuild["Gradle-Kotlin Build System"]:::android
            KotlinBundle["main.lynx.bundle"]:::asset
            KotlinProvider["DemoTemplateProvider.kt"]:::provider
            KotlinTheme["UI Theme Modules"]:::android
            KotlinUI["Activities (UI Hosts)"]:::ui
        end
    end

    subgraph "iOS"
        subgraph "HelloLynxObjc"
            ObjcBuild["Xcode/Pods Build System"]:::ios
            ObjcBundle["main.lynx.bundle"]:::asset
            ObjcProvider["DemoLynxProvider (ObjC)"]:::provider
            ObjcUI["AppDelegate/SceneDelegate/ViewController"]:::ui
        end
        subgraph "HelloLynxSwift"
            SwiftBuild["Xcode/Pods Build System"]:::ios
            SwiftBundle["main.lynx.bundle"]:::asset
            SwiftProvider["DemoLynxProvider (Swift)"]:::provider
            SwiftUI["AppDelegate/SceneDelegate/ViewController"]:::ui
        end
    end

    subgraph "Shared"
        LynxEngine["Lynx Engine"]:::engine
    end

    JavaBuild --> JavaBundle --> JavaProvider --> JavaTheme --> JavaUI --> LynxEngine
    KotlinBuild --> KotlinBundle --> KotlinProvider --> KotlinTheme --> KotlinUI --> LynxEngine
    ObjcBuild --> ObjcBundle --> ObjcProvider --> ObjcUI --> LynxEngine
    SwiftBuild --> SwiftBundle --> SwiftProvider --> SwiftUI --> LynxEngine

    click JavaBuild "https://github.com/lynx-family/integrating-lynx-demo-projects/tree/release/3.1/android/JavaEmptyProject/"
    click JavaBundle "https://github.com/lynx-family/integrating-lynx-demo-projects/blob/release/3.1/android/JavaEmptyProject/app/src/main/assets/main.lynx.bundle"
    click JavaProvider "https://github.com/lynx-family/integrating-lynx-demo-projects/blob/release/3.1/android/JavaEmptyProject/app/src/main/java/com/lynx/javaemptyproject/DemoTemplateProvider.java"
    click JavaTheme "https://github.com/lynx-family/integrating-lynx-demo-projects/tree/release/3.1/android/JavaEmptyProject/app/src/main/java/com/lynx/javaemptyproject/ui/theme/"
    click JavaUI "https://github.com/lynx-family/integrating-lynx-demo-projects/tree/release/3.1/android/JavaEmptyProject/app/src/main/java/com/lynx/javaemptyproject/"

    click KotlinBuild "https://github.com/lynx-family/integrating-lynx-demo-projects/tree/release/3.1/android/KotlinEmptyProject/"
    click KotlinBundle "https://github.com/lynx-family/integrating-lynx-demo-projects/blob/release/3.1/android/KotlinEmptyProject/app/src/main/assets/main.lynx.bundle"
    click KotlinProvider "https://github.com/lynx-family/integrating-lynx-demo-projects/blob/release/3.1/android/KotlinEmptyProject/app/src/main/java/com/lynx/kotlinemptyproject/DemoTemplateProvider.kt"
    click KotlinTheme "https://github.com/lynx-family/integrating-lynx-demo-projects/tree/release/3.1/android/KotlinEmptyProject/app/src/main/java/com/lynx/kotlinemptyproject/ui/theme/"
    click KotlinUI "https://github.com/lynx-family/integrating-lynx-demo-projects/tree/release/3.1/android/KotlinEmptyProject/app/src/main/java/com/lynx/kotlinemptyproject/"

    click ObjcBuild "https://github.com/lynx-family/integrating-lynx-demo-projects/tree/release/3.1/ios/HelloLynxObjc/"
    click ObjcBundle "https://github.com/lynx-family/integrating-lynx-demo-projects/blob/release/3.1/ios/HelloLynxObjc/main.lynx.bundle"
    click ObjcProvider "https://github.com/lynx-family/integrating-lynx-demo-projects/blob/release/3.1/ios/HelloLynxObjc/Hello-Lynx-OC/DemoLynxProvider.h"
    click ObjcUI "https://github.com/lynx-family/integrating-lynx-demo-projects/tree/release/3.1/ios/HelloLynxObjc/Hello-Lynx-OC/"

    click SwiftBuild "https://github.com/lynx-family/integrating-lynx-demo-projects/tree/release/3.1/ios/HelloLynxSwift/"
    click SwiftBundle "https://github.com/lynx-family/integrating-lynx-demo-projects/blob/release/3.1/ios/HelloLynxSwift/main.lynx.bundle"
    click SwiftProvider "https://github.com/lynx-family/integrating-lynx-demo-projects/blob/release/3.1/ios/HelloLynxSwift/Hello-Lynx/DemoLynxProvider.swift"
    click SwiftUI "https://github.com/lynx-family/integrating-lynx-demo-projects/tree/release/3.1/ios/HelloLynxSwift/Hello-Lynx/"

    classDef android fill:#cfe2f3,stroke:#6d9eeb,color:#000
    classDef ios fill:#d9ead3,stroke:#93c47d,color:#000
    classDef asset fill:#f2f2f2,stroke:#999,color:#000
    classDef engine fill:#d9d2e9,stroke:#8e7cc3,color:#000
    classDef provider fill:#fff2cc,stroke:#d9b200,color:#000
    classDef ui fill:#fce5cd,stroke:#e69138,color:#000
```
