# epicgames/lore architecture

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

- Interactive diagram: https://gitdiagram.com/epicgames/lore
- Repository: https://github.com/epicgames/lore

## Overview

#### Purpose and executables
Lore is a Rust, centralized version-control system for large binary and source assets. It models repository state as content-addressed Merkle trees plus an immutable revision chain, with lightweight mutable branch references.

Primary entry points:
- CLI executable: `lore-client/src/cli/main.rs`
- Long-running server executable: `lore-server/src/bin/loreserver/main.rs`
- Embeddable core/FFI library: `lore/src/lib.rs`, `lore-capi/lore.h`

#### Public API and client boundary
The `lore` crate is the high-level library surface used by native consumers and language bindings. It exposes repository, revision, branch, file, storage, lock, and service operations, delegating either to local revision logic or remote services.
- `lore/src/interface.rs`
- `lore/src/repository.rs`
- `lore/src/remote/connection.rs`

The CLI parses commands and configuration, invokes this library, and presents progress/logging; it is a client frontend rather than the revision engine.
- `lore-client/src/cli/commands.rs`
- `lore-client/src/cli/client_main.rs`

#### Revision-domain engine
`lore-revision` contains the domain model and orchestration for repositories, revisions, branches, staging, merges, dependencies, working filesystem realization, and synchronization. This is the key boundary between user-facing version-control operations and storage primitives.
- `lore-revision/src/lore.rs`
- `lore-revision/src/revision.rs`
- `lore-revision/src/repository.rs`

Typical write flow is workspace changes → stage/file state → revision state/Merkle objects → immutable content storage → mutable branch-head update. Read/checkout flows resolve branch/revision state, hydrate required content, then realize it in the filesystem.
- `lore-revision/src/stage.rs`
- `lore-revision/src/store/immutable.rs`
- `lore-revision/src/fs/realize.rs`

#### Content-addressed storage layer
`lore-storage` implements local immutable and mutable stores, chunking, compression, fragment handling, pack storage, and maintenance. Immutable objects support deduplication and integrity by hash; mutable data holds changeable references/metadata such as branch state.
- `lore-storage/src/fragment_engine.rs`
- `lore-storage/src/immutable_store.rs`
- `lore-storage/src/mutable_store.rs`

The revision engine composes local, remote, and replica-backed stores, separating repository semantics from durability and replication mechanisms.
- `lore-revision/src/store/composite.rs`
- `lore-revision/src/store/remote.rs`
- `lore-revision/src/store/packstore.rs`

#### Server protocols and request handling
Lore Server hosts multiple access paths: versioned gRPC APIs for repository/revision/storage operations, HTTP endpoints for health and presigned content access, and QUIC storage/replication services. Protobuf contracts are the compatibility boundary for gRPC clients and services.
- `lore-proto/proto/lore/revision/v1/revision.proto`
- `lore-server/src/grpc/server.rs`
- `lore-server/src/http/server.rs`

gRPC handlers authenticate/authorize requests, resolve repository and execution context, then invoke revision/store services. Forwarded-request modules support routing operations to other service instances.
- `lore-server/src/grpc/handlers/mod.rs`
- `lore-server/src/grpc/forwarded_requests.rs`
- `lore-server/src/execution_state.rs`

#### Security, clustering, and extensibility
JWT/JWK authentication and repository authorization sit at server ingress; credentials are also managed client-side. Locking, notifications, hooks, and plugin registries are server-side cross-cutting integrations.
- `lore-server/src/auth/jwt.rs`
- `lore-server/src/authnz/repository_authorizer.rs`
- `lore-credential/src/token_store.rs`

Server topology and replicated-store abstractions support multi-instance operation. AWS plugins provide S3-backed immutable storage and DynamoDB-backed mutable/lock storage; HashiCorp support provides Consul peer discovery and Nomad telemetry.
- `lore-server/src/store/replicated_store.rs`
- `lore-aws/src/store/immutable_store.rs`
- `lore-hashicorp/src/consul/service_peer_discovery.rs`

#### Runtime and infrastructure
The system is Rust-based with asynchronous networking/runtime support, custom I/O backends, TLS, tracing, metrics, and correlation propagation.
- `lore-base/src/runtime.rs`
- `lore-io/src/lib.rs`
- `lore-telemetry/src/metrics/mod.rs`

Deployment artifacts include a containerized server and an AWS Terraform example provisioning network, compute, IAM, storage, and TLS-related infrastructure.
- `lore-server/Dockerfile`
- `contrib/aws/main.tf`
- `contrib/aws/storage.tf`

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_clients["Client surfaces"]
  node_cli["Lore CLI<br/>Rust executable<br/>[main.rs]"]
  node_client_commands["Command frontend<br/>CLI commands<br/>[commands.rs]"]
  node_public_api["Lore library API<br/>Rust library<br/>[lib.rs]"]
  node_c_api["C FFI header<br/>FFI contract<br/>[lore.h]"]
  node_credentials["Credential store<br/>client auth<br/>[token_store.rs]"]
end

subgraph group_revision["Revision domain"]
  node_revision_engine["Revision engine<br/>domain orchestration<br/>[lore.rs]"]
  node_staging["Stage and file state<br/>workspace state<br/>[stage.rs]"]
  node_realization["Filesystem realization<br/>checkout layer<br/>[realize.rs]"]
  node_composite_store["Composite store<br/>store composition<br/>[composite.rs]"]
end

subgraph group_storage["Storage"]
  node_immutable_store[("Immutable object store<br/>content-addressed storage<br/>[immutable_store.rs]")]
  node_mutable_store[("Mutable reference store<br/>metadata storage<br/>[mutable_store.rs]")]
end

subgraph group_server["Server runtime"]
  node_server_main["Lore Server<br/>Rust executable<br/>[main.rs]"]
  node_grpc_contract["Revision gRPC contract<br/>protobuf API<br/>[revision.proto]"]
  node_grpc_ingress["gRPC handlers<br/>request ingress<br/>[mod.rs]"]
  node_http_ingress["HTTP server<br/>HTTP ingress<br/>[server.rs]"]
  node_authz["JWT repository auth<br/>authorization"]
  node_replicated_store["Replicated store<br/>cluster storage"]
end

subgraph group_extensions["Deployment &amp; extensions"]
  node_aws_storage["AWS storage plugin<br/>storage backend<br/>[immutable_store.rs]"]
  node_runtime["Async runtime<br/>runtime foundation<br/>[runtime.rs]"]
  node_aws_deployment["AWS Terraform deployment<br/>infrastructure<br/>[main.tf]"]
end

node_cli -->|"starts"| node_client_commands
node_client_commands -->|"invokes"| node_public_api
node_public_api -->|"uses credentials"| node_credentials
node_c_api -->|"binds"| node_public_api
node_public_api -->|"local operations"| node_revision_engine
node_public_api -.->|"remote API"| node_grpc_contract
node_revision_engine -->|"writes workspace state"| node_staging
node_revision_engine -->|"hydrates checkout"| node_realization
node_revision_engine -->|"persists revisions"| node_composite_store
node_staging -->|"content becomes objects"| node_immutable_store
node_composite_store -->|"immutable content"| node_immutable_store
node_composite_store -->|"branch heads"| node_mutable_store
node_server_main -->|"hosts"| node_grpc_ingress
node_server_main -->|"hosts"| node_http_ingress
node_grpc_contract -->|"defines API"| node_grpc_ingress
node_grpc_ingress -->|"authorizes"| node_authz
node_grpc_ingress -->|"dispatches operations"| node_revision_engine
node_grpc_ingress -->|"storage access"| node_replicated_store
node_replicated_store -.->|"backend option"| node_aws_storage
node_server_main -->|"runs on"| node_runtime
node_aws_deployment -.->|"deploys"| node_server_main

click node_cli "https://github.com/epicgames/lore/blob/main/lore-client/src/cli/main.rs"
click node_client_commands "https://github.com/epicgames/lore/blob/main/lore-client/src/cli/commands.rs"
click node_public_api "https://github.com/epicgames/lore/blob/main/lore/src/lib.rs"
click node_c_api "https://github.com/epicgames/lore/blob/main/lore-capi/lore.h"
click node_credentials "https://github.com/epicgames/lore/blob/main/lore-credential/src/token_store.rs"
click node_revision_engine "https://github.com/epicgames/lore/blob/main/lore-revision/src/lore.rs"
click node_staging "https://github.com/epicgames/lore/blob/main/lore-revision/src/stage.rs"
click node_realization "https://github.com/epicgames/lore/blob/main/lore-revision/src/fs/realize.rs"
click node_composite_store "https://github.com/epicgames/lore/blob/main/lore-revision/src/store/composite.rs"
click node_immutable_store "https://github.com/epicgames/lore/blob/main/lore-storage/src/immutable_store.rs"
click node_mutable_store "https://github.com/epicgames/lore/blob/main/lore-storage/src/mutable_store.rs"
click node_server_main "https://github.com/epicgames/lore/blob/main/lore-server/src/bin/loreserver/main.rs"
click node_grpc_contract "https://github.com/epicgames/lore/blob/main/lore-proto/proto/lore/revision/v1/revision.proto"
click node_grpc_ingress "https://github.com/epicgames/lore/blob/main/lore-server/src/grpc/handlers/mod.rs"
click node_http_ingress "https://github.com/epicgames/lore/blob/main/lore-server/src/http/server.rs"
click node_authz "https://github.com/epicgames/lore/blob/main/lore-server/src/authnz/repository_authorizer.rs"
click node_replicated_store "https://github.com/epicgames/lore/blob/main/lore-server/src/store/replicated_store.rs"
click node_aws_storage "https://github.com/epicgames/lore/blob/main/lore-aws/src/store/immutable_store.rs"
click node_runtime "https://github.com/epicgames/lore/blob/main/lore-base/src/runtime.rs"
click node_aws_deployment "https://github.com/epicgames/lore/blob/main/contrib/aws/main.tf"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_cli,node_client_commands,node_public_api,node_c_api,node_credentials toneBlue
class node_revision_engine,node_staging,node_realization,node_composite_store toneAmber
class node_immutable_store,node_mutable_store toneMint
class node_server_main,node_grpc_contract,node_grpc_ingress,node_http_ingress,node_authz,node_replicated_store toneRose
class node_aws_storage,node_runtime,node_aws_deployment toneIndigo
```

## Components

### Client surfaces

- [Lore CLI](https://github.com/epicgames/lore/blob/main/lore-client/src/cli/main.rs): Rust executable · `lore-client/src/cli/main.rs`
- [Command frontend](https://github.com/epicgames/lore/blob/main/lore-client/src/cli/commands.rs): CLI commands · `lore-client/src/cli/commands.rs`
- [Lore library API](https://github.com/epicgames/lore/blob/main/lore/src/lib.rs): Rust library · Native and FFI-facing repository operations. · `lore/src/lib.rs`
- [C FFI header](https://github.com/epicgames/lore/blob/main/lore-capi/lore.h): FFI contract · `lore-capi/lore.h`
- [Credential store](https://github.com/epicgames/lore/blob/main/lore-credential/src/token_store.rs): client auth · `lore-credential/src/token_store.rs`

### Revision domain

- [Revision engine](https://github.com/epicgames/lore/blob/main/lore-revision/src/lore.rs): domain orchestration · Repository, revision, branch, merge, sync, and workspace semantics. · `lore-revision/src/lore.rs`
- [Stage and file state](https://github.com/epicgames/lore/blob/main/lore-revision/src/stage.rs): workspace state · `lore-revision/src/stage.rs`
- [Filesystem realization](https://github.com/epicgames/lore/blob/main/lore-revision/src/fs/realize.rs): checkout layer · `lore-revision/src/fs/realize.rs`
- [Composite store](https://github.com/epicgames/lore/blob/main/lore-revision/src/store/composite.rs): store composition · Selects local, remote, and replica-backed storage. · `lore-revision/src/store/composite.rs`

### Storage

- [Immutable object store](https://github.com/epicgames/lore/blob/main/lore-storage/src/immutable_store.rs): content-addressed storage · Hashed, deduplicated content with chunking and pack support. · `lore-storage/src/immutable_store.rs`
- [Mutable reference store](https://github.com/epicgames/lore/blob/main/lore-storage/src/mutable_store.rs): metadata storage · Holds changeable branch heads and metadata. · `lore-storage/src/mutable_store.rs`

### Server runtime

- [Lore Server](https://github.com/epicgames/lore/blob/main/lore-server/src/bin/loreserver/main.rs): Rust executable · `lore-server/src/bin/loreserver/main.rs`
- [Revision gRPC contract](https://github.com/epicgames/lore/blob/main/lore-proto/proto/lore/revision/v1/revision.proto): protobuf API · `lore-proto/proto/lore/revision/v1/revision.proto`
- [gRPC handlers](https://github.com/epicgames/lore/blob/main/lore-server/src/grpc/handlers/mod.rs): request ingress · Authenticates, authorizes, and dispatches revision/store calls. · `lore-server/src/grpc/handlers/mod.rs`
- [HTTP server](https://github.com/epicgames/lore/blob/main/lore-server/src/http/server.rs): HTTP ingress · Health and presigned-content endpoints. · `lore-server/src/http/server.rs`
- [JWT repository auth](https://github.com/epicgames/lore/blob/main/lore-server/src/authnz/repository_authorizer.rs): authorization · `lore-server/src/authnz/repository_authorizer.rs`
- [Replicated store](https://github.com/epicgames/lore/blob/main/lore-server/src/store/replicated_store.rs): cluster storage · `lore-server/src/store/replicated_store.rs`

### Deployment & extensions

- [AWS storage plugin](https://github.com/epicgames/lore/blob/main/lore-aws/src/store/immutable_store.rs): storage backend · S3 immutable and DynamoDB mutable/lock backends. · `lore-aws/src/store/immutable_store.rs`
- [Async runtime](https://github.com/epicgames/lore/blob/main/lore-base/src/runtime.rs): runtime foundation · `lore-base/src/runtime.rs`
- [AWS Terraform deployment](https://github.com/epicgames/lore/blob/main/contrib/aws/main.tf): infrastructure · `contrib/aws/main.tf`

## Connections

- Lore CLI → Command frontend: starts
- Command frontend → Lore library API: invokes
- Lore library API → Credential store: uses credentials
- C FFI header → Lore library API: binds
- Lore library API → Revision engine: local operations
- Lore library API → Revision gRPC contract: remote API
- Revision engine → Stage and file state: writes workspace state
- Revision engine → Filesystem realization: hydrates checkout
- Revision engine → Composite store: persists revisions
- Stage and file state → Immutable object store: content becomes objects
- Composite store → Immutable object store: immutable content
- Composite store → Mutable reference store: branch heads
- Lore Server → gRPC handlers: hosts
- Lore Server → HTTP server: hosts
- Revision gRPC contract → gRPC handlers: defines API
- gRPC handlers → JWT repository auth: authorizes
- gRPC handlers → Revision engine: dispatches operations
- gRPC handlers → Replicated store: storage access
- Replicated store → AWS storage plugin: backend option
- Lore Server → Async runtime: runs on
- AWS Terraform deployment → Lore Server: deploys
