# plakarkorp/plakar architecture

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

- Interactive diagram: https://gitdiagram.com/plakarkorp/plakar
- Repository: https://github.com/plakarkorp/plakar

## Overview

##### Project type and purpose
- This is a Go-based, CLI-driven backup & restore solution (“plakar”) with a built-in HTTP server and web UI.
- It ships as a single binary exposing subcommands (backup, restore, sync, ui, agent, scheduler, etc.), a plugin/connector architecture for multiple storage backends, and embeds an immutable data store called Kloset.

##### File structure
- Top-level binaries & CLI:
- main.go + subcommands/… (each subcommand is its own package)
- agent/ (daemon to manage repository locks and remote access)
- scheduler/ (task scheduling client & config)
- server/httpd/ (REST API + static-file server for UI)
- ui/v2/frontend (static assets of the web UI)
- Core libraries & layers:
- api/ (defines REST endpoints and proxying)
- appcontext/ (context management across calls)
- connectors/ (plugin directory grouping fs, s3, ftp, grpc, sqlite, http, null, ptar, stdio, tar, etc.)
- plugins/ (higher-level integration hooks)
- plakarfs/ (FUSE filesystem implementation for instant mounts)
- reporting/ (metric/event reporting)
- utils/ (config, flags, time, browser integration)
- Configuration & build:
- Makefile, Go modules, GitHub Actions workflows, goreleaser, scheduler/config.yaml

##### README for additional insights
- plakar offers CLI subcommands, built-in web UI (served by HTTP server), a plugin-style connector architecture, encryption, deduplication, and multiple “storage backends” (local FS, S3, FTP, etc.).
- Quickstart shows that plakar ties together repository creation, backup, restore, sync, and UI launch under one binary.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User Interfaces
    subgraph "User Interfaces"
        CLI["plakar CLI"]:::ui
        WebUI["Web UI (Browser)"]:::ui
    end

    %% Control Plane
    subgraph "Control Plane"
        HTTP["HTTP Server\n(server/httpd)"]:::core
        Agent["Agent Daemon"]:::core
        Scheduler["Scheduler"]:::core
    end

    %% Core Services
    subgraph "Core Services"
        API["API Layer"]:::core
        Services["Service Layer"]:::core
        Plugins["Plugin Manager"]:::core
        AppCtx["App Context & Config"]:::core
    end

    %% Data Plane
    subgraph "Data Plane"
        Connectors["Connectors\n(fs, s3, ftp, sftp, grpc, http, stdio, tar, ptar, sqlite, null)"]:::data
        FUSE["plakarfs (FUSE)"]:::data
        Kloset["Kloset Store"]:::data
    end

    %% Reporting & Utilities
    subgraph "Reporting & Utilities"
        Reporting["Reporting & Metrics"]:::core
        Utils2["Utilities & Helpers"]:::core
        Build["Build & CI"]:::core
    end

    %% External Systems
    subgraph "External Systems"
        S3["S3/Object Store"]:::external
        FSLocal["Local File System"]:::external
        FTP["FTP/SFTP Server"]:::external
        GRPC["gRPC Service"]:::external
    end

    %% Connections
    CLI -->|invokes| Services
    CLI -->|lock RPC| Agent
    WebUI -->|served by| HTTP
    WebUI -->|REST API calls| API
    HTTP -->|exposes endpoints| API
    HTTP -->|lock RPC| Agent
    Scheduler -->|invokes CLI| CLI
    Scheduler -->|posts to REST API| HTTP
    API -->|calls| Services
    Services -->|uses| Plugins
    Plugins -->|loads| Connectors
    Services -->|reports to| Reporting
    Services -->|depends on| AppCtx
    Connectors -->|data flow| Kloset
    Services -->|reads/writes| Kloset
    Connectors -->|stores to| S3
    Connectors -->|stores to| FSLocal
    Connectors -->|stores to| FTP
    Connectors -->|stores to| GRPC
    Services -->|uses| Utils2

    %% Click Events
    click CLI "https://github.com/plakarkorp/plakar/blob/main/main.go"
    click CLI "https://github.com/plakarkorp/plakar/tree/main/subcommands/"
    click Agent "https://github.com/plakarkorp/plakar/blob/main/agent/agent.go"
    click Agent "https://github.com/plakarkorp/plakar/blob/main/agent/flock_unix.go"
    click Agent "https://github.com/plakarkorp/plakar/blob/main/agent/flock_windows.go"
    click Scheduler "https://github.com/plakarkorp/plakar/blob/main/scheduler/scheduler.go"
    click Scheduler "https://github.com/plakarkorp/plakar/blob/main/scheduler/client.go"
    click Scheduler "https://github.com/plakarkorp/plakar/blob/main/scheduler/config.go"
    click Scheduler "https://github.com/plakarkorp/plakar/blob/main/scheduler/config.yaml"
    click Scheduler "https://github.com/plakarkorp/plakar/blob/main/scheduler/tasks.go"
    click HTTP "https://github.com/plakarkorp/plakar/blob/main/server/httpd/httpd.go"
    click WebUI "https://github.com/plakarkorp/plakar/blob/main/ui/v2/ui.go"
    click WebUI "https://github.com/plakarkorp/plakar/blob/main/ui/v2/frontend/index.html"
    click WebUI "https://github.com/plakarkorp/plakar/blob/main/ui/v2/frontend/assets/index-CUYVuAtq.js"
    click WebUI "https://github.com/plakarkorp/plakar/blob/main/ui/v2/frontend/assets/index-hWznsRWO.css"
    click API "https://github.com/plakarkorp/plakar/blob/main/api/api.go"
    click API "https://github.com/plakarkorp/plakar/blob/main/api/api_authentication.go"
    click API "https://github.com/plakarkorp/plakar/blob/main/api/api_errors.go"
    click API "https://github.com/plakarkorp/plakar/blob/main/api/api_integrations.go"
    click API "https://github.com/plakarkorp/plakar/blob/main/api/api_params.go"
    click API "https://github.com/plakarkorp/plakar/blob/main/api/api_proxy.go"
    click API "https://github.com/plakarkorp/plakar/blob/main/api/api_repository.go"
    click API "https://github.com/plakarkorp/plakar/blob/main/api/api_snapshot.go"
    click Services "https://github.com/plakarkorp/plakar/blob/main/services/services.go"
    click AppCtx "https://github.com/plakarkorp/plakar/blob/main/appcontext/appcontext.go"
    click AppCtx "https://github.com/plakarkorp/plakar/blob/main/utils/config.go"
    click AppCtx "https://github.com/plakarkorp/plakar/blob/main/utils/oldconfig.go"
    click AppCtx "https://github.com/plakarkorp/plakar/blob/main/utils/opts.go"
    click Plugins "https://github.com/plakarkorp/plakar/blob/main/plugins/manager.go"
    click Plugins "https://github.com/plakarkorp/plakar/blob/main/plugins/plugin.go"
    click Plugins "https://github.com/plakarkorp/plakar/blob/main/plugins/connect.go"
    click Plugins "https://github.com/plakarkorp/plakar/blob/main/plugins/connect_windows.go"
    click Plugins "https://github.com/plakarkorp/plakar/blob/main/plugins/integration.go"
    click Plugins "https://github.com/plakarkorp/plakar/blob/main/plugins/manifest.go"
    click Plugins "https://github.com/plakarkorp/plakar/blob/main/plugins/package.go"
    click Plugins "https://github.com/plakarkorp/plakar/blob/main/plugins/recipe.go"
    click Connectors "https://github.com/plakarkorp/plakar/tree/main/connectors/fs/"
    click Connectors "https://github.com/plakarkorp/plakar/tree/main/connectors/s3/"
    click Connectors "https://github.com/plakarkorp/plakar/tree/main/connectors/ftp/"
    click Connectors "https://github.com/plakarkorp/plakar/tree/main/connectors/sftp/"
    click Connectors "https://github.com/plakarkorp/plakar/tree/main/connectors/grpc/"
    click Connectors "https://github.com/plakarkorp/plakar/tree/main/connectors/http/"
    click Connectors "https://github.com/plakarkorp/plakar/tree/main/connectors/stdio/"
    click Connectors "https://github.com/plakarkorp/plakar/tree/main/connectors/tar/"
    click Connectors "https://github.com/plakarkorp/plakar/tree/main/connectors/ptar/"
    click Connectors "https://github.com/plakarkorp/plakar/tree/main/connectors/sqlite/"
    click Connectors "https://github.com/plakarkorp/plakar/tree/main/connectors/null/"
    click FUSE "https://github.com/plakarkorp/plakar/blob/main/plakarfs/fs.go"
    click FUSE "https://github.com/plakarkorp/plakar/blob/main/plakarfs/dir.go"
    click FUSE "https://github.com/plakarkorp/plakar/blob/main/plakarfs/file.go"
    click Reporting "https://github.com/plakarkorp/plakar/blob/main/reporting/reporting.go"
    click Reporting "https://github.com/plakarkorp/plakar/blob/main/reporting/report.go"
    click Reporting "https://github.com/plakarkorp/plakar/blob/main/reporting/http.go"
    click Reporting "https://github.com/plakarkorp/plakar/blob/main/reporting/null.go"
    click Utils2 "https://github.com/plakarkorp/plakar/blob/main/utils/browser.go"
    click Utils2 "https://github.com/plakarkorp/plakar/blob/main/utils/time.go"
    click Utils2 "https://github.com/plakarkorp/plakar/blob/main/utils/utils.go"
    click Build "https://github.com/plakarkorp/plakar/tree/main/Makefile"
    click Build "https://github.com/plakarkorp/plakar/blob/main/.goreleaser.yml"
    click Build "https://github.com/plakarkorp/plakar/blob/main/.github/workflows/ci.yml"

    %% Styles
    classDef ui fill:#e0ffc1,stroke:#333,stroke-width:1px
    classDef core fill:#cfe2ff,stroke:#333,stroke-width:1px
    classDef data fill:#ffe5b4,stroke:#333,stroke-width:1px
    classDef external fill:#d3d3d3,stroke:#333,stroke-width:1px
```
