# flow-launcher/flow.launcher architecture

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

- Interactive diagram: https://gitdiagram.com/flow-launcher/flow.launcher
- Repository: https://github.com/flow-launcher/flow.launcher

## Overview

##### Main Components
- User Interface (Presentation Layer): Represented by the Flow.Launcher folder which contains the App.xaml, MainWindow.xaml, and various pages, dialogs, and controls. This layer is responsible for rendering the search window, hotkey handling, and overall user experience.
- Core Engine (Business/Domain Layer): Located in Flow.Launcher.Core. This layer includes configuration, core plugin management (loading, manifest parsing, error handling), and interoperability components for the plugins.
- Infrastructure/Utilities Layer: Found in Flow.Launcher.Infrastructure. It covers logging, file explorers, HTTP communication, hotkey management, and various helper classes. It provides common services and supports both the core functionalities and UI.
- Plugin Abstraction and Implementation:
- Flow.Launcher.Plugin directory: Contains abstract interfaces and base models that plugins must implement.
- The “Plugins” folder: Contains various plugin projects (e.g., Browser Bookmark, Calculator, Explorer, Shell, etc.). They plug into Flow Launcher via the interfaces defined in the core and plugin layers.
- Test and Build Components: The Flow.Launcher.Test directory and build configuration files (such as .sln, Directory.Build.props/targets, CI/CD pipelines in .github) indicate automated tests and continuous integration/deployment processes.
- External Assets and Styling: Including themes (Flow.Launcher/Themes) and localization resources (Flow.Launcher/Languages), which support the UI layer.

##### Relationships and Interactions
- The UI layer communicates directly with the Core Engine. It sends user search queries, hotkey events, and receives results.
- The Core Engine is in charge of loading and managing plugins. It scans the “Plugins” folder or loads plugins specified in Flow.Launcher.Core/ExternalPlugins; it then dispatches queries to these plugins (using interfaces defined in Flow.Launcher.Plugin).
- The Infrastructure/Utilities layer supplies cross-cutting services (logging, configuration, error handling) which are accessed by both the UI and Core.
- Plugins operate as loosely bound external components that follow a well-defined contract (e.g., PluginConfig, PluginManager, and various JSON-RPC interfaces) to return search results and handle commands.
- Testing components ensure that changes in the core or plugin code remain robust.

##### Architectural Patterns and Design Principles
- Plugin or Modular Architecture: Emphasize the dynamic loading of plugins via a plugin manager. Plugins can be developed in multiple languages (e.g., C#, Python, JavaScript via the provided environments) and are integrated at runtime.
- MVVM (Model-View-ViewModel) Pattern: The presence of ViewModel folders and XAML pages in the UI layer indicates the use of MVVM, which helps separate UI logic from business logic.
- Dependency Inversion: Core and infrastructure components are designed so that plugin implementations conform to defined interfaces.
- Configurability and Extensibility: Notice the presence of configuration files and user settings entities, along with language resources that support internationalization.

##### Technologies and Frameworks
- .NET 7 (target framework) and C# (primary language).
- WPF/XAML for the UI layer.
- Integration of CI/CD (GitHub Actions, Appveyor) and build scripts (msbuild via Directory.Build.props/targets).
- Multi-language plugin support (evident from dedicated environments such as Python, JavaScript, and TypeScript in the ExternalPlugins folder).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Layer
    subgraph "Presentation Layer"
        UI["User Interface (Flow.Launcher)"]
    end

    %% Core Engine (Business/Domain Layer)
    subgraph "Core Engine (Business/Domain Layer)"
        Core["Core Engine (Flow.Launcher.Core)"]
    end

    %% Infrastructure/Utilities Layer
    subgraph "Infrastructure/Utilities Layer"
        Infra["Infrastructure (Flow.Launcher.Infrastructure)"]
    end

    %% Plugin System
    subgraph "Plugin System"
        PluginInterface["Plugin Interfaces & Base Models (Flow.Launcher.Plugin)"]
        ExternalPlugins["External Plugins (Plugins)"]
    end

    %% Test & Build Components
    subgraph "Test & Build"
        Test["Tests & Build (Flow.Launcher.Test & Build Files)"]
    end

    %% External Assets and Styling
    subgraph "External Assets"
        Assets["Assets & Styling (Themes & Languages)"]
    end

    %% Connections
    UI -->|"sendsInputAndHotkeyEvents"| Core
    Core -->|"dispatchesQueriesTo"| ExternalPlugins
    ExternalPlugins -->|"returnsResultsTo"| Core
    Core -->|"utilizesInterfacesFrom"| PluginInterface
    Core -->|"callsServicesFrom"| Infra
    UI -->|"leveragesServicesFrom"| Infra
    UI -->|"appliesAssetsFrom"| Assets
    Test -.->|"validates"| UI
    Test -.->|"validates"| Core
    Test -.->|"validates"| ExternalPlugins

    %% Styles
    classDef ui fill:#ADD8E6,stroke:#000,stroke-width:2px;
    classDef core fill:#90EE90,stroke:#000,stroke-width:2px;
    classDef infra fill:#FFD700,stroke:#000,stroke-width:2px;
    classDef plugin fill:#FFA07A,stroke:#000,stroke-width:2px;
    classDef test fill:#D3D3D3,stroke:#000,stroke-width:2px;
    classDef assets fill:#DDA0DD,stroke:#000,stroke-width:2px;

    class UI ui;
    class Core core;
    class Infra infra;
    class PluginInterface,ExternalPlugins plugin;
    class Test test;
    class Assets assets;

    %% Click Events for Component Mapping
    click UI "https://github.com/flow-launcher/flow.launcher/blob/dev/Flow.Launcher/App.xaml"
    click UI "https://github.com/flow-launcher/flow.launcher/blob/dev/Flow.Launcher/MainWindow.xaml"
    click Core "https://github.com/flow-launcher/flow.launcher/blob/dev/Flow.Launcher.Core"
    click Infra "https://github.com/flow-launcher/flow.launcher/tree/dev/Flow.Launcher/Infrastructure"
    click PluginInterface "https://github.com/flow-launcher/flow.launcher/tree/dev/Flow.Launcher/Plugin"
    click ExternalPlugins "https://github.com/flow-launcher/flow.launcher/tree/dev/Plugins"
    click Test "https://github.com/flow-launcher/flow.launcher/tree/dev/Flow.Launcher/Test"
    click Test "https://github.com/flow-launcher/flow.launcher/blob/dev/Flow.Launcher.sln"
    click Test "https://github.com/flow-launcher/flow.launcher/blob/dev/Directory.Build.props"
    click Assets "https://github.com/flow-launcher/flow.launcher/tree/dev/Flow.Launcher/Themes"
    click Assets "https://github.com/flow-launcher/flow.launcher/tree/dev/Flow.Launcher/Languages"
```
