# akruphi/far2l architecture

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

- Interactive diagram: https://gitdiagram.com/akruphi/far2l
- Repository: https://github.com/akruphi/far2l

## Overview

##### Project type and purpose
- This is a monolithic, plugin-based native file manager (“far2l”), a Linux/macOS fork of Windows FAR Manager V2. It’s written in C/C++ with a modular plugin architecture and supports multiple UI backends (console and GUI).
- The README confirms it’s a terminal/desktop application with an extensible plugin system (NetRocks, colorer, multiarc, tmppanel, compare, filecase, inside, align, autowrap, drawline, editcase, editorcomp, incsrch, SimpleIndent, Calculator, Python scripting, etc.).

##### File-structure analysis
- Top‐level CMakeLists.txt orchestrates building core, library modules, plugins and utilities.
- Core engine lives under `far2l/src`, with subfolders for base, console, dialog, macro, panels, vt, plugin host and so on.
- UI backends:
- TTY / TTY|X / TTY|Xi code under `WinPort` and `far2l/src/console` plus X11 wrappers.
- GUI (wxWidgets) under `WinPort/src/Backend/WX`.
- Plugins are in parallel directories at root (`NetRocks`, `colorer`, `multiarc`, etc.), each with its own CMakeLists, source and config files.
- Shared libraries:
- `FARStdlib` – common FAR-style API.
- `utils` – OS-abstraction and helpers.
- `WinPort` – Windows-compat layer reused for TTY backends.
- External dependencies are declared in README (`libssh`, `libssl`, `libsmbclient`, `libnfs`, `libxml2`, `uchardet`, AWS SDK, ICU, Python3, libarchive, libunrar, etc.).

- Core Engine
– Command dispatcher, file panels, macro engine, plugin host, configuration subsystem.
- UI Backends
– TTY, TTY|X, TTY|Xi modules (console mode)
– GUI (wxWidgets)
- Plugin Manager
– Dynamically loads plugins via FAR2L plugin API.
- Plugins
– NetRocks (network protocols)
– Colorer (syntax highlighting)
– MultiArc (archive formats)
– TmpPanel, Compare, FileCase, Inside, Align, AutoWrap, DrawLine, EditCase, EditorComp, IncSrch, SimpleIndent, Calculator, Python plugin
- Shared Libraries
– FARStdlib, Utils, WinPort
- External Libraries & Services
– libssh/openssl (SFTP/FTPS), libsmbclient (SMB), libnfs, neon (WebDAV), AWS SDK (S3), libxml2, uchardet, ICU, Python3 Interpreter/CFFI, libarchive, libunrar, 7z
- Build System & Packaging
– CMake, CI workflows, packaging scripts.

b. Relationships and interactions
- User ↔ UI Backend: keyboard/mouse input; screen output.
- UI Backend → Core Engine: translate events → core APIs.
- Core Engine → Plugin Manager: load/initialize plugins; dispatch plugin callbacks.
- Plugin → Core Engine: query panels, perform operations (list files, transfer data).
- Plugins → External Libraries: use SSH/SSL, SMB, NFS, ICU, XML parsing, archive codecs, Python runtime.
- Core Engine → Shared Libraries: use Utils & FARStdlib for OS abstractions (threading, file I/O, IPC).
- Core Engine/Plugins → OS: filesystem, network, X11/Wayland.

c. Architectural patterns and design principles
- Plugin pattern: decoupled modules implementing a plugin API.
- Strategy pattern: pluggable UI backends selected at runtime.
- Facade/adaptor: Utils and WinPort abstract OS differences.
- Modular layering: core, UI, plugins, utilities, external dependencies.

d. Key technologies and frameworks
- CMake – build orchestration
- wxWidgets – GUI backend
- X11/XInput – extended TTY backends
- libssh, OpenSSL, libsmbclient, libnfs, neon – network plugins
- ICU, libuchardet – charset handling
- libxml2 – Colorer config parsing
- AWS C++ SDK – NetRocks AWS S3
- Python/CFFI – Python plugin
- libarchive, UnRAR, 7z ANSI-C – MultiArc plugin
- WINE sources – Windows API porting

## Diagram (Mermaid)

```mermaid
graph TD
    subgraph "UI Backends"
        GUI["GUI (wxWidgets)"]:::ui
        TTY["TTY Backend"]:::ui
    end

    Core["Core Engine"]:::core
    PluginManager["Plugin Manager"]:::core

    subgraph "Shared Libraries"
        FARStdlib["FARStdlib"]:::shared
        Utils["Utils"]:::shared
        WinPortLib["WinPort"]:::shared
    end

    subgraph "Plugins"
        NetRocks["NetRocks"]:::plugin
        Colorer["Colorer"]:::plugin
        MultiArc["MultiArc"]:::plugin
        TmpPanel["TmpPanel"]:::plugin
        Compare["Compare"]:::plugin
        FileCase["FileCase"]:::plugin
        Inside["Inside"]:::plugin
        Align["Align"]:::plugin
        AutoWrap["AutoWrap"]:::plugin
        DrawLine["DrawLine"]:::plugin
        EditCase["EditCase"]:::plugin
        EditorComp["EditorComp"]:::plugin
        IncSrch["IncSrch"]:::plugin
        SimpleIndent["SimpleIndent"]:::plugin
        Calculator["Calculator"]:::plugin
        PythonScript["Python Scripting"]:::plugin
    end

    External["External Libraries & Services"]:::external

    subgraph "Build & CI"
        CMake["CMake Build"]:::build
        CI["CI & Packaging"]:::build
    end

    %% Connections
    GUI -->|"input/output"| Core
    TTY -->|"input/output"| Core
    Core -->|"initializes"| PluginManager
    PluginManager -->|"loads"| NetRocks
    PluginManager -->|"loads"| Colorer
    PluginManager -->|"loads"| MultiArc
    PluginManager -->|"loads"| TmpPanel
    PluginManager -->|"loads"| Compare
    PluginManager -->|"loads"| FileCase
    PluginManager -->|"loads"| Inside
    PluginManager -->|"loads"| Align
    PluginManager -->|"loads"| AutoWrap
    PluginManager -->|"loads"| DrawLine
    PluginManager -->|"loads"| EditCase
    PluginManager -->|"loads"| EditorComp
    PluginManager -->|"loads"| IncSrch
    PluginManager -->|"loads"| SimpleIndent
    PluginManager -->|"loads"| Calculator
    PluginManager -->|"loads"| PythonScript

    Core -->|"uses"| FARStdlib
    Core -->|"uses"| Utils
    Core -->|"uses"| WinPortLib

    Plugins -->|"depend on"| External

    CMake -->|"orchestrates build of"| Core
    CMake -->|"orchestrates build of"| PluginManager
    CMake -->|"orchestrates build of"| Plugins
    CMake -->|"orchestrates build of"| FARStdlib
    CMake -->|"orchestrates build of"| Utils
    CMake -->|"orchestrates build of"| WinPortLib
    CI -->|"runs workflows"| CMake

    %% Click Events
    click Core "https://github.com/akruphi/far2l/tree/master/far2l/src"
    click TTY "https://github.com/akruphi/far2l/tree/master/WinPort/src/Backend/TTY"
    click GUI "https://github.com/akruphi/far2l/tree/master/WinPort/src/Backend/WX"
    click PluginManager "https://github.com/akruphi/far2l/tree/master/far2l/src/plug"
    click NetRocks "https://github.com/akruphi/far2l/tree/master/NetRocks"
    click Colorer "https://github.com/akruphi/far2l/tree/master/colorer"
    click MultiArc "https://github.com/akruphi/far2l/tree/master/multiarc"
    click TmpPanel "https://github.com/akruphi/far2l/tree/master/tmppanel"
    click Compare "https://github.com/akruphi/far2l/tree/master/compare"
    click FileCase "https://github.com/akruphi/far2l/tree/master/filecase"
    click Inside "https://github.com/akruphi/far2l/tree/master/inside"
    click Align "https://github.com/akruphi/far2l/tree/master/align"
    click AutoWrap "https://github.com/akruphi/far2l/tree/master/autowrap"
    click DrawLine "https://github.com/akruphi/far2l/tree/master/drawline"
    click EditCase "https://github.com/akruphi/far2l/tree/master/editcase"
    click EditorComp "https://github.com/akruphi/far2l/tree/master/editorcomp"
    click IncSrch "https://github.com/akruphi/far2l/tree/master/incsrch"
    click SimpleIndent "https://github.com/akruphi/far2l/tree/master/SimpleIndent"
    click Calculator "https://github.com/akruphi/far2l/tree/master/calc"
    click PythonScript "https://github.com/akruphi/far2l/tree/master/python"
    click FARStdlib "https://github.com/akruphi/far2l/tree/master/FARStdlib"
    click Utils "https://github.com/akruphi/far2l/tree/master/utils"
    click WinPortLib "https://github.com/akruphi/far2l/tree/master/WinPort"
    click CMake "https://github.com/akruphi/far2l/blob/master/CMakeLists.txt"
    click CI "https://github.com/akruphi/far2l/tree/master/packaging and .github/workflows"

    %% Styles
    classDef ui fill:#90EE90,stroke:#333,stroke-width:1px
    classDef core fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef shared fill:#FFFF99,stroke:#333,stroke-width:1px
    classDef plugin fill:#FFA500,stroke:#333,stroke-width:1px
    classDef external fill:#D3D3D3,stroke:#333,stroke-width:1px
    classDef build fill:#FFE4E1,stroke:#333,stroke-width:1px
```
