# marc2332/freya architecture

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

- Interactive diagram: https://gitdiagram.com/marc2332/freya
- Repository: https://github.com/marc2332/freya

## Overview

##### Main Components Identification
The system should be divided into these major components:

a. Core Architecture:
- Native Core (crates/native-core): Handles the fundamental rendering system
- Core (crates/core): Manages DOM, events, and rendering pipeline
- Engine (crates/engine): Provides rendering backends (Skia)
- State (crates/state): Manages application state and styling
- Torin (crates/torin): Layout engine

b. User-Facing Layers:
- Components (crates/components): Pre-built UI components
- Elements (crates/elements): Basic building blocks
- Hooks (crates/hooks): Reusable logic components
- Freya (crates/freya): Main public API

c. Development Tools:
- DevTools (crates/devtools): Developer tooling
- Testing (crates/testing): Testing infrastructure

**[User Application Layer]**
- ↓
**[Freya Public API]**
- ↓
**┌─────────────────────────────────┐**
- Component Layer          │
- ┤
- Pre-built Components         │
- Custom Elements              │
- Hooks                        │
- ┘
- ↓
**┌─────────────────────────────────┐**
- Core Layer               │
- ┤
- DOM Management               │
- Event System                 │
- Rendering Pipeline           │
- State Management            │
- ┘
- ↓
**┌─────────────────────────────────┐**
- Platform Layer           │
- ┤
- Skia Rendering              │
- Native Windowing            │
- Platform Integration        │
- ┘

##### Key Relationships to Highlight

- Event propagation paths
- State management connections
- Integration points with Dioxus and Skia

##### Important Details

- Event system architecture
- Rendering pipeline flow
- State management system
- Component hierarchy
- Testing infrastructure
- DevTools integration

##### Architectural Patterns to Emphasize

- Component-based architecture
- Event-driven system
- Layered architecture
- Platform abstraction

##### Integration Points

- How Dioxus integration works
- Skia rendering pipeline
- Platform-specific adaptations
- Testing and DevTools hooks

Remember to highlight Freya's unique features:
- Native (non-web) implementation
- Cross-platform support
- Built-in component system
- Developer tools integration
- Testing infrastructure
- Theming support
- Accessibility features

This will help developers understand both the high-level architecture and the detailed implementation specifics of the Freya UI library.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph User["User Application"]
        App[User Application Code]
        style App rx:10,ry:10
    end

    subgraph API["Public API Layer"]
        Freya["Freya API"]:::api
        style Freya rx:10,ry:10
    end

    subgraph Components["Component Layer"]
        PrebuiltComponents["Pre-built Components"]:::component
        Elements["Basic Elements"]:::component
        Hooks["Hooks System"]:::component
        style PrebuiltComponents rx:10,ry:10
        style Elements rx:10,ry:10
        style Hooks rx:10,ry:10
    end

    subgraph Core["Core Layer"]
        DOM["DOM Management"]:::core
        Events["Event System"]:::core
        RenderPipeline["Rendering Pipeline"]:::core
        State["State Management"]:::core
        style DOM rx:10,ry:10
        style Events rx:10,ry:10
        style RenderPipeline rx:10,ry:10
        style State rx:10,ry:10
    end

    subgraph Platform["Platform Layer"]
        NativeCore["Native Core"]:::platform
        Engine["Rendering Engine"]:::platform
        Torin["Layout Engine"]:::platform
        Renderer["Renderer"]:::platform
        style NativeCore rx:10,ry:10
        style Engine rx:10,ry:10
        style Torin rx:10,ry:10
        style Renderer rx:10,ry:10
    end

    subgraph DevLayer["Development Layer"]
        DevTools["DevTools"]:::dev
        Testing["Testing Infrastructure"]:::dev
        style DevTools rx:10,ry:10
        style Testing rx:10,ry:10
    end

    Dioxus["Dioxus"]:::external
    Skia["Skia"]:::external
    style Dioxus rx:10,ry:10
    style Skia rx:10,ry:10

    App --> Freya
    Freya --> PrebuiltComponents
    Freya --> Elements
    Freya --> Hooks
    
    PrebuiltComponents --> DOM
    Elements --> DOM
    Hooks --> State
    
    DOM --> Events
    DOM --> RenderPipeline
    Events --> NativeCore
    RenderPipeline --> Engine
    State --> DOM
    
    Engine --> Skia
    NativeCore --> Dioxus
    Engine --> Renderer
    Torin --> Renderer
    
    DevTools --> DOM
    Testing --> PrebuiltComponents

    click NativeCore "https://github.com/marc2332/freya/tree/main/crates/native-core/"
    click DOM "https://github.com/marc2332/freya/tree/main/crates/core/src/dom/"
    click Events "https://github.com/marc2332/freya/tree/main/crates/core/src/events/"
    click RenderPipeline "https://github.com/marc2332/freya/tree/main/crates/core/src/render/"
    click Engine "https://github.com/marc2332/freya/tree/main/crates/engine/"
    click State "https://github.com/marc2332/freya/tree/main/crates/state/"
    click Torin "https://github.com/marc2332/freya/tree/main/crates/torin/"
    click PrebuiltComponents "https://github.com/marc2332/freya/tree/main/crates/components/src/"
    click Elements "https://github.com/marc2332/freya/tree/main/crates/elements/src/"
    click Hooks "https://github.com/marc2332/freya/tree/main/crates/hooks/src/"
    click Freya "https://github.com/marc2332/freya/tree/main/crates/freya/src/"
    click DevTools "https://github.com/marc2332/freya/tree/main/crates/devtools/"
    click Testing "https://github.com/marc2332/freya/tree/main/crates/testing/"
    click Renderer "https://github.com/marc2332/freya/tree/main/crates/renderer/src/"

    classDef api fill:#E6F3FF,stroke:#B8E6FF
    classDef component fill:#E6FFE6,stroke:#B8FFB8
    classDef core fill:#FFE6CC,stroke:#FFD1A3
    classDef platform fill:#F0E6FF,stroke:#D9B8FF
    classDef dev fill:#FFFDE6,stroke:#FFF9B8
    classDef external fill:#F5F5F5,stroke:#E0E0E0

    subgraph Legend
        API_L["API"]:::api
        Component_L["Component"]:::component
        Core_L["Core"]:::core
        Platform_L["Platform"]:::platform
        Dev_L["Development"]:::dev
        External_L["External"]:::external
        style API_L rx:10,ry:10
        style Component_L rx:10,ry:10
        style Core_L rx:10,ry:10
        style Platform_L rx:10,ry:10
        style Dev_L rx:10,ry:10
        style External_L rx:10,ry:10
    end
```
