# f3d-app/f3d architecture

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

- Interactive diagram: https://gitdiagram.com/f3d-app/f3d
- Repository: https://github.com/f3d-app/f3d

## Overview

- Core Library (libf3d): Indicate the core rendering functionality that handles mesh rendering, scene management, and configuration (located in the library folder, with public and private APIs). This is the heart of the system.
- Bindings: Show optional language bindings such as Python (in the python folder), Java (in the java folder), and even WebAssembly (webassembly folder). These allow the core library to be used from different environments.
- Testing & Documentation: It can be helpful to denote separate testing and documentation components (e.g., tests in library/testing, application/testing, and various doc folders) although these might be depicted as ancillary or supportive to the core system.

##### Out relationships and data flows
- Integration flows for language bindings – for example, showing that when a Python application calls into F3D’s Python bindings, those in turn wrap the Core Library functionalities.
- Data/instruction flows such as user interactions that trigger input event handlers in the application, which then call into the library for rendering updates.

##### Architectural patterns and design principles
- Modular design: Clearly show a separation between the viewer application, the core library, and plugins. This modularity allows for easy extension and integration of additional file formats or rendering techniques.
- Multi-language support: Use a separate branch or grouping that shows bindings (Python, Java, JavaScript/WebAssembly) as wrappers or adapters to the core functionalities.
- Clear API boundaries: Mark boundaries between public interfaces (in library/public) and internal implementations (in library/private).

##### Relevant technologies
- Usage of C++17 (as indicated in the README) as the main language.
- Mention build/configuration tools (CMake, as seen in multiple CMakeLists.txt files) to highlight that components are independently built and then integrated.
- Point out key third-party libraries (VTK, OCCT, Assimp, Alembic, Draco, etc.), especially for the specific plugins that wrap these technologies.
- For the web version, include Emscripten (webassembly folder) to indicate that some parts are compiled to WebAssembly and integrated with HTML/JS.

- Labels for each key component: "F3D Application (CLI/Viewer)", "libf3d Core Library", "3D File Format Plugins" (with sub-labels like Alembic, Assimp, Draco, etc.), "Language Bindings" (Python, Java, WebAssembly), and "External Dependencies (VTK, OCCT, etc.)".
- From user/file input → Application Layer → Core Library → Plugins.
- From configuration files → both Application and libf3d config utilities.
- Bindings feeding into libf3d.
- Annotations for build and test infrastructure (indicate the presence of CMake, GitHub workflows, and tests from the testing directories) to capture the complete ecosystem.
- If space allows, include a small inset or note for how the application can operate non-interactively (command-line usage and rendering to image files) versus interactive session (drag-and-drop, realtime viewer).

## Diagram (Mermaid)

```mermaid
graph TD
    UI["User Input/Configuration"]:::external
    App["F3D Application (CLI/Viewer)"]:::app
    Lib["libf3d Core Library"]:::core
    PluginsEco["Plugin Ecosystem"]:::plugin
    BindingsContainer["Language Bindings"]:::bindings
    ExtDep["External Dependencies"]:::external
    TestDoc["Testing & Documentation"]:::support

    UI -->|"sends commands/config"| App
    App -->|"invokes rendering"| Lib
    Lib -->|"loads plugins"| PluginsEco
    ExtDep -->|"provides functionality"| Lib
    ExtDep -->|"used by"| PluginsEco
    BindingsContainer -->|"wraps core"| Lib

    %% Subgraph for individual plugins
    subgraph "Available Plugins"
      direction TB
      Alembic["Alembic"]:::plugin_inner
      Assimp["Assimp"]:::plugin_inner
      Draco["Draco"]:::plugin_inner
      OCCT["OCCT"]:::plugin_inner
      USD["USD"]:::plugin_inner
      VDB["VDB"]:::plugin_inner
    end

    PluginsEco -->|"manages"| Alembic
    PluginsEco -->|"manages"| Assimp
    PluginsEco -->|"manages"| Draco
    PluginsEco -->|"manages"| OCCT
    PluginsEco -->|"manages"| USD
    PluginsEco -->|"manages"| VDB

    %% Subgraph for language bindings
    subgraph "Bindings"
      direction TB
      Py["Python Bindings"]:::bindings_inner
      Java["Java Bindings"]:::bindings_inner
      WASM["WebAssembly Bindings"]:::bindings_inner
    end

    BindingsContainer -->|"composes"| Py
    BindingsContainer -->|"composes"| Java
    BindingsContainer -->|"composes"| WASM

    %% Click events for mapped components
    click App "https://github.com/f3d-app/f3d/blob/master/application/main.cxx"
    click Lib "https://github.com/f3d-app/f3d/tree/master/library/"
    click PluginsEco "https://github.com/f3d-app/f3d/tree/master/plugins/"
    click Py "https://github.com/f3d-app/f3d/blob/master/python/F3DPythonBindings.cxx"
    click Java "https://github.com/f3d-app/f3d/blob/master/java/F3DJavaBindings.cxx"
    click WASM "https://github.com/f3d-app/f3d/blob/master/webassembly/F3DEmscriptenBindings.cxx"
    click ExtDep "https://github.com/f3d-app/f3d/tree/master/external/"
    click TestDoc "https://github.com/f3d-app/f3d/tree/master/doc/"

    %% Styles
    classDef app fill:#f9e79f,stroke:#d35400,stroke-width:2px;
    classDef core fill:#aed6f1,stroke:#2874a6,stroke-width:2px;
    classDef plugin fill:#d5f5e3,stroke:#27ae60,stroke-width:2px;
    classDef bindings fill:#f5b7b1,stroke:#c0392b,stroke-width:2px;
    classDef external fill:#d6eaf8,stroke:#2471a3,stroke-width:2px;
    classDef support fill:#fbfcfc,stroke:#7f8c8d,stroke-width:2px;
    classDef plugin_inner fill:#abebc6,stroke:#1e8449,stroke-width:1px;
    classDef bindings_inner fill:#f9e79f,stroke:#c0392b,stroke-width:1px;
```
