# dairondanilo/filamentdanilo architecture

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

- Interactive diagram: https://gitdiagram.com/dairondanilo/filamentdanilo
- Repository: https://github.com/dairondanilo/filamentdanilo

## Overview

##### Project's Main Components
- Android Application Shell – The “app” directory shows that this is a standard Android project with an AndroidManifest.xml. It includes components like the MainActivity.kt and FilamentApp.kt, which are likely responsible for bootstrapping the app.
- UI Layer – Built using Jetpack Compose. Look at the “presentation/screens” directory (e.g., HomeScreen.kt) and the custom view FilamentSurfaceComposeView.kt in “presentation/components”. This layer handles all the visual presentation and user interaction.
- Rendering Module – This encapsulates all interactions with the Filament 3D engine. Inside “presentation/rendering” you have classes like FrameCallback.kt, RenderingLifecycleObserver.kt, and modelRendering.kt. These are responsible for managing rendering loops, frame callbacks, and interfacing with Filament.
- Interaction Module – Under “presentation/interaction”, include gesture detectors such as SceneDoubleTapListener.kt and SceneSingleTapListener.kt to handle touch events that manipulate 3D models.
- Dependency Injection (DI) – The “di” directory (with AppModule.kt) is used to manage dependencies throughout the app.
- Assets & Environment Configuration – The “assets” directory holds environments and model data. For instance, “assets/envs/default_env” contains environment configuration scripts (e.g., default_env_ibl.ktx) for lighting/skybox, and “assets/models” includes 3D models.
- Testing – Presence of both “androidTest” and “test” directories shows unit and instrumentation testing (ExampleUnitTest.kt, ExampleInstrumentedTest.kt).

##### Relationships and Interactions
- The UI Layer (Compose screens and custom Filament view) sends user actions (taps, gestures) to the Interaction Module.
- The Interaction Module translates these inputs into commands affecting the 3D scene rendered by the Rendering Module.
- The Rendering Module uses Filament to process model rendering, coordinate frame callbacks, and manage the rendering lifecycle.
- Dependency Injection (DI) feeds required services and objects into UI and rendering components.
- Testing layers are separate and validate the interactions between these components.

##### Architectural Patterns and Design Principles
- MVVM: The existence of ViewModel classes (e.g., HomeViewModel.kt) and clearly separated presentation logic indicates an MVVM pattern.
- Separation of Concerns: The architecture separates UI, rendering, business logic, and asset management.
- Dependency Injection: Using DI (via AppModule) promotes loose coupling.
- Modularization: Different directories are used to organize functionalities like rendering, interaction, and UI components.

##### Key Technologies, Frameworks, and Libraries
- Android SDK and Kotlin as the primary platform and language.
- Jetpack Compose for UI development.
- Filament for 3D model loading and real-time rendering.
- Gradle (Kotlin DSL) for build configuration.
- (Likely) a DI framework (e.g., Dagger/Hilt or Koin) as indicated by the “di” directory.

- Start at the highest level (Android OS, Application Entry Point) and drill down to individual modules (UI, Interaction, Rendering, etc.).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Global Entity
    OS["Android OS"]:::external

    %% Android Application Shell
    subgraph "Android Application Shell"
        A_Main["MainActivity.kt"]:::android
        A_Fil["FilamentApp.kt"]:::android
    end

    %% UI Layer – Jetpack Compose
    subgraph "UI Layer – Jetpack Compose"
        UI_HS["HomeScreen.kt"]:::UI
        UI_HV["HomeViewModel.kt"]:::UI
        UI_FCV["FilamentSurfaceComposeView.kt"]:::UI
    end

    %% Rendering Module – Filament Integration
    subgraph "Rendering Module – Filament Integration"
        R_FC["FrameCallback.kt"]:::Rendering
        R_RLO["RenderingLifecycleObserver.kt"]:::Rendering
        R_MR["modelRendering.kt"]:::Rendering
    end

    %% Interaction Module – Gesture Handlers
    subgraph "Interaction Module – Gesture Handlers"
        I_DT["SceneDoubleTapListener.kt"]:::Interaction
        I_ST["SceneSingleTapListener.kt"]:::Interaction
    end

    %% Dependency Injection (DI)
    D["AppModule.kt"]:::DI

    %% Assets & Environment Configuration
    Aset["Assets & Environment Configuration"]:::Assets

    %% Testing
    subgraph "Testing"
        T_Inst["ExampleInstrumentedTest.kt"]:::Testing
        T_Unit["ExampleUnitTest.kt"]:::Testing
    end

    %% Relationships
    OS --> A_Main
    OS --> A_Fil
    A_Main -->|"launches"| UI_HS
    A_Fil -->|"initializes"| UI_FCV
    UI_HS -->|"updates"| UI_HV
    UI_HS -->|"sends input"| I_DT
    UI_HS -->|"sends input"| I_ST
    I_DT -->|"triggers rendering"| R_FC
    I_ST -->|"triggers rendering"| R_RLO
    I_DT -->|"updates"| R_MR
    I_ST -->|"updates"| R_MR
    R_MR -->|"loads assets"| Aset

    %% Dependency Injection supplying components
    D --- A_Main
    D --- UI_HS
    D --- I_DT
    D --- R_FC

    %% Testing validations
    T_Inst --- A_Main
    T_Unit --- UI_HS
    T_Inst --- R_FC

    %% Click Events
    click A_Main "https://github.com/dairondanilo/filamentdanilo/blob/main/app/src/main/java/com/danilo/filamentdanilo/MainActivity.kt"
    click A_Fil "https://github.com/dairondanilo/filamentdanilo/blob/main/app/src/main/java/com/danilo/filamentdanilo/FilamentApp.kt"
    click UI_HS "https://github.com/dairondanilo/filamentdanilo/blob/main/app/src/main/java/com/danilo/filamentdanilo/presentation/screens/home/HomeScreen.kt"
    click UI_HV "https://github.com/dairondanilo/filamentdanilo/blob/main/app/src/main/java/com/danilo/filamentdanilo/presentation/screens/home/HomeViewModel.kt"
    click UI_FCV "https://github.com/dairondanilo/filamentdanilo/blob/main/app/src/main/java/com/danilo/filamentdanilo/presentation/screens/components/FilamentSurfaceComposeView.kt"
    click R_FC "https://github.com/dairondanilo/filamentdanilo/blob/main/app/src/main/java/com/danilo/filamentdanilo/presentation/rendering/FrameCallback.kt"
    click R_RLO "https://github.com/dairondanilo/filamentdanilo/blob/main/app/src/main/java/com/danilo/filamentdanilo/presentation/rendering/RenderingLifecycleObserver.kt"
    click R_MR "https://github.com/dairondanilo/filamentdanilo/blob/main/app/src/main/java/com/danilo/filamentdanilo/presentation/rendering/modelRendering.kt"
    click I_DT "https://github.com/dairondanilo/filamentdanilo/blob/main/app/src/main/java/com/danilo/filamentdanilo/presentation/interaction/SceneDoubleTapListener.kt"
    click I_ST "https://github.com/dairondanilo/filamentdanilo/blob/main/app/src/main/java/com/danilo/filamentdanilo/presentation/interaction/SceneSingleTapListener.kt"
    click D "https://github.com/dairondanilo/filamentdanilo/blob/main/app/src/main/java/com/danilo/filamentdanilo/di/AppModule.kt"
    click Aset "https://github.com/dairondanilo/filamentdanilo/tree/main/app/src/main/assets"
    click T_Inst "https://github.com/dairondanilo/filamentdanilo/blob/main/app/src/androidTest/java/com/danilo/filamentdanilo/ExampleInstrumentedTest.kt"
    click T_Unit "https://github.com/dairondanilo/filamentdanilo/blob/main/app/src/test/java/com/danilo/filamentdanilo/ExampleUnitTest.kt"

    %% Legend (as comments)
    %% Legend:
    %% • Red: Android Application Shell
    %% • Light Green: UI Layer – Jetpack Compose
    %% • Light Blue: Rendering Module – Filament Integration
    %% • Pink: Interaction Module – Gesture Handlers
    %% • Yellow: Dependency Injection (DI)
    %% • Grey: Assets & Environment Configuration
    %% • Light Grey: Testing
    %% • Light Grey: External/Android OS

    %% Styles
    classDef external fill:#e6e6e6,stroke:#333,stroke-width:2px,color:#000;
    classDef android fill:#ffcccc,stroke:#333,stroke-width:2px,color:#000;
    classDef UI fill:#ccffcc,stroke:#333,stroke-width:2px,color:#000;
    classDef Rendering fill:#ccccff,stroke:#333,stroke-width:2px,color:#000;
    classDef Interaction fill:#ffccff,stroke:#333,stroke-width:2px,color:#000;
    classDef DI fill:#ffffcc,stroke:#333,stroke-width:2px,color:#000;
    classDef Assets fill:#d9d9d9,stroke:#333,stroke-width:2px,color:#000;
    classDef Testing fill:#f2f2f2,stroke:#333,stroke-width:2px,color:#000;
```
