# treeverse/lakefs architecture

> Architecture diagram of the GitHub repository treeverse/lakefs, 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/treeverse/lakefs
- Repository: https://github.com/treeverse/lakefs

## Overview

##### Main Components
- Data Versioning Engine (Core lakeFS Server): Represent the main lakeFS application that exposes the HTTP API. This includes:
– API layer (served by packages under “pkg/api”).
– Catalog and metadata handling (see “pkg/catalog”, “pkg/graveler” and “pkg/metastore”).
– Object storage interaction modules (under “pkg/block”, “pkg/kv” for adapter integrations with S3, Azure, GCP, etc.).
– Authentication/authorization services (modules in “pkg/auth”, “pkg/authentication”, “pkg/auth/oidc”, etc.)
- Underlying Storage Services: Indicate external object storage backends (S3-compatible, Azure, GCP) along with a metadata store. These are abstracted by lakeFS so that it can “version” data without needing to duplicate files.
- Clients & SDKs:
– Multiple client packages (Java, Python, Rust, Spark, etc., available under “clients” + their language-specific bindings) that interface with the lakeFS API.
– Command-line tools (lakectl and others under “cmd/”) that call the lakeFS API.
- Web UI: The “webui” directory holds the frontend resources that allow users to interact with lakeFS via a browser. This UI connects to the API layer.
- Hooks & Extensions: Customizable hooks implemented in Lua and other languages (see “pkg/actions”, “examples/hooks”) allow users to enforce data quality tests, governance, and Git-like workflows.
- Distributed & Operational Subsystems:
– Components for distributed coordination, retention, garbage collection (“pkg/distributed”, “pkg/graveler/retention”, “pkg/graveler/hooks_handler.go”) and integrations with ETL pipelines.

##### Relationships and Data Flows
– Incoming API and CLI calls from web UI, CLI tools, and SDK clients.
– Communication with back-end storage adapters which mediate operations on object stores.
– Internal coordination between the catalog/graveler components and the metadata store.
– Hook invocation: illustrate how pre- and post-commit hooks (configured via the lakeFS actions framework – e.g., Lua scripts under “pkg/actions/lua”, “examples/hooks”) are triggered on events.
- How the authentication service validates requests (e.g., through JWT, basic auth, or external OIDC providers) that are part of the API processing pipeline.
- Deployment boundaries to capture how the system can be deployed on-premises or in the cloud. Containers and orchestration details (Dockerfile, deployments directories) might be noted for operational context.

##### Architectural Patterns and Technologies
- Microservices/Modularity: lakeFS uses a modular design through separate packages for API, authentication, catalog, storage abstraction, and client SDKs.
- Abstraction & Adapter Pattern: Show how lakeFS abstracts the underlying object storage using various “adapters” (located in pkg/block/* and pkg/kv/*) so that the same operations can apply to S3, Azure, GCP, or local file systems.
- Git-like Versioning: Emphasize the branching, commit, rollback, and merge functionalities similar to Git, which are core to its design.
- API-Driven Architecture: The clear separation of front-end (web UI/CLI/SDK) and back-end (lakeFS API server) components supports RESTful, client–server interactions.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Core lakeFS Server Subgraph
    subgraph "Core lakeFS Server"
        API["API Layer"]:::server
        CatalogManager["Catalog & Metadata Manager"]:::server
        StorageAdapter["Storage Adapter"]:::server
        Authentication["Authentication Service"]:::server
        HooksExtensions["Hooks & Extensions"]:::server
        DistributedSubsystem["Distributed Subsystem"]:::server
    end

    %% Clients & SDKs Subgraph
    subgraph "Clients & SDKs"
        CLITools["CLI Tools"]:::client
        ClientLibraries["Client Libraries"]:::client
        WebUI["Web UI"]:::client
    end

    %% External Services Subgraph
    subgraph "External Services"
        ObjectStorage["Object Storage Backends"]:::external
        MetadataStore["Metadata Store"]:::external
    end

    %% Auxiliary Services Subgraph
    subgraph "Auxiliary Services"
        Auxiliary["Deployment, Testing & Documentation"]:::util
    end

    %% Clients to API connections
    CLITools -->|"REST_API"| API
    ClientLibraries -->|"REST_API"| API
    WebUI -->|"REST_API"| API

    %% Internal API calls to core modules
    API -->|"calls"| Authentication
    API -->|"calls"| CatalogManager
    API -->|"calls"| StorageAdapter
    API -->|"triggers"| HooksExtensions
    API -->|"coordinates"| DistributedSubsystem

    %% Core modules to external services
    CatalogManager -->|"metadata_ops"| MetadataStore
    StorageAdapter -->|"storage_ops"| ObjectStorage

    %% Distributed subsystem reporting to auxiliary services
    DistributedSubsystem -->|"reports"| Auxiliary

    %% Class Definitions for coloring
    classDef server fill:#AED6F1,stroke:#333,stroke-width:2px;
    classDef client fill:#ABEBC6,stroke:#333,stroke-width:2px;
    classDef external fill:#FAD7A0,stroke:#333,stroke-width:2px;
    classDef util fill:#F9E79F,stroke:#333,stroke-width:2px;

    %% Click Events for Core lakeFS Server
    click API "https://github.com/treeverse/lakefs/tree/master/pkg/api"
    click CatalogManager "https://github.com/treeverse/lakefs/tree/master/pkg/catalog"
    click CatalogManager "https://github.com/treeverse/lakefs/tree/master/pkg/graveler"
    click CatalogManager "https://github.com/treeverse/lakefs/tree/master/pkg/metastore"
    click StorageAdapter "https://github.com/treeverse/lakefs/tree/master/pkg/block"
    click StorageAdapter "https://github.com/treeverse/lakefs/tree/master/pkg/kv"
    click Authentication "https://github.com/treeverse/lakefs/tree/master/pkg/auth"
    click Authentication "https://github.com/treeverse/lakefs/tree/master/pkg/authentication"
    click Authentication "https://github.com/treeverse/lakefs/tree/master/pkg/auth/oidc"
    
    %% Click Events for Clients & SDKs
    click CLITools "https://github.com/treeverse/lakefs/tree/master/cmd/lakectl"
    click CLITools "https://github.com/treeverse/lakefs/tree/master/cmd/lakefs"
    click ClientLibraries "https://github.com/treeverse/lakefs/tree/master/clients/java"
    click ClientLibraries "https://github.com/treeverse/lakefs/tree/master/clients/python"
    click ClientLibraries "https://github.com/treeverse/lakefs/tree/master/clients/python-wrapper"
    click ClientLibraries "https://github.com/treeverse/lakefs/tree/master/clients/rust"
    click ClientLibraries "https://github.com/treeverse/lakefs/tree/master/clients/spark"
    click WebUI "https://github.com/treeverse/lakefs/tree/master/webui"

    %% Click Events for Hooks & Extensions
    click HooksExtensions "https://github.com/treeverse/lakefs/tree/master/pkg/actions"
    click HooksExtensions "https://github.com/treeverse/lakefs/tree/master/examples/hooks"

    %% Click Events for Distributed & Operational Subsystems
    click DistributedSubsystem "https://github.com/treeverse/lakefs/tree/master/pkg/distributed"
    click DistributedSubsystem "https://github.com/treeverse/lakefs/tree/master/pkg/graveler/retention"
    click DistributedSubsystem "https://github.com/treeverse/lakefs/blob/master/pkg/graveler/hooks_handler.go"

    %% Click Events for Auxiliary Services & Tools
    click Auxiliary "https://github.com/treeverse/lakefs/tree/master/deployments"
    click Auxiliary "https://github.com/treeverse/lakefs/tree/master/docs"
    click Auxiliary "https://github.com/treeverse/lakefs/tree/master/tools"
    click Auxiliary "https://github.com/treeverse/lakefs/tree/master/esti"
```
