# cartert27/scion architecture

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

- Interactive diagram: https://gitdiagram.com/cartert27/scion
- Repository: https://github.com/cartert27/scion

## Overview

Scion is a Rust source-control system for always-online clients, coding agents, and CI. A client uses the CLI or working-copy library to import or edit a repository, upload changes, query history, and materialize full or sparse checkouts; server-side history and expensive operations support that workflow. The server exposes gRPC services over persistent metadata and object storage, with optional daemon caching. The README documents these capabilities; sampled source confirms selected client, query, server, derived-data, and storage wiring, but not every subsystem connection.

Main entry points: [`crates/scion-server/src/app.rs`](https://github.com/cartert27/scion/blob/main/crates/scion-server/src/app.rs) (Server application), [`crates/scion-proto/src/client.rs`](https://github.com/cartert27/scion/blob/main/crates/scion-proto/src/client.rs) (gRPC client), [`crates/scion-server/src/handlers/query.rs`](https://github.com/cartert27/scion/blob/main/crates/scion-server/src/handlers/query.rs) (Query handlers), [`crates/scion-server/src/handlers/history_query.rs`](https://github.com/cartert27/scion/blob/main/crates/scion-server/src/handlers/history_query.rs) (History queries)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Client workflows"]
  node_cli["Scion CLI<br/>[args.rs]"]
  node_wc["Working copy<br/>[checkout.rs]"]
  node_importer["Git importer<br/>[git.rs]"]
  node_daemon["Local daemon<br/>[daemon.rs]"]
  node_proto["gRPC client<br/>[client.rs]"]
end

subgraph group_service["Server services"]
  node_server["Server application<br/>[app.rs]"]
  node_query["Query handlers<br/>[query.rs]"]
  node_history_query["History queries<br/>[history_query.rs]"]
  node_write["Write and ref handlers<br/>[write.rs]"]
end

subgraph group_domain["History and data"]
  node_history["History operations<br/>[create.rs]"]
  node_merge["Merge engine<br/>[merge3.rs]"]
  node_derived["Derived data<br/>[engine.rs]"]
  node_objects["Immutable objects<br/>[changeset.rs]"]
end

subgraph group_persistence["Persistence"]
  node_store_api["Storage interfaces<br/>[storage.rs]"]
  node_crdb[("CockroachDB metadata<br/>[store.rs]")]
  node_s3[("S3 object store<br/>[store.rs]")]
end

subgraph group_integrations["Identity and extensions"]
  node_auth["Auth and access<br/>[service.rs]"]
  node_policy["Authorization policy<br/>[policy.rs]"]
  node_redaction["Content redaction<br/>[redactor.rs]"]
end

node_user(("Developer or agent"))
node_github["GitHub OAuth"]

node_user -->|"runs commands"| node_cli
node_cli -->|"sends RPCs"| node_proto
node_wc -.->|"fetches and writes"| node_proto
node_importer -->|"publishes history"| node_proto
node_proto -->|"calls gRPC"| node_server
node_server -->|"routes requests"| node_query
node_server -->|"routes requests"| node_history_query
node_server -.->|"routes requests"| node_write
node_query -->|"checks access"| node_policy
node_history_query -->|"checks access"| node_policy
node_query -->|"computes hunks"| node_merge
node_history_query -->|"reads log"| node_history
node_history -.->|"persists history"| node_store_api
node_query -->|"reads objects"| node_objects
node_store_api -.->|"uses metadata backend"| node_crdb
node_store_api -.->|"uses blob backend"| node_s3
node_server -.->|"assembles derivation"| node_derived
node_server -.->|"configures authentication"| node_auth
node_server -.->|"applies redaction"| node_redaction
node_auth -.->|"authenticates with"| node_github
node_daemon -.->|"forwards requests"| node_proto
node_user -->|"checks out paths"| node_wc
node_user -->|"migrates Git history"| node_importer

click node_cli "https://github.com/cartert27/scion/blob/main/crates/scion-cli/src/cli/args.rs"
click node_wc "https://github.com/cartert27/scion/blob/main/crates/scion-wc/src/checkout.rs"
click node_importer "https://github.com/cartert27/scion/blob/main/crates/scion-import/src/import/git.rs"
click node_daemon "https://github.com/cartert27/scion/blob/main/crates/scion-daemon/src/daemon.rs"
click node_proto "https://github.com/cartert27/scion/blob/main/crates/scion-proto/src/client.rs"
click node_server "https://github.com/cartert27/scion/blob/main/crates/scion-server/src/app.rs"
click node_query "https://github.com/cartert27/scion/blob/main/crates/scion-server/src/handlers/query.rs"
click node_history_query "https://github.com/cartert27/scion/blob/main/crates/scion-server/src/handlers/history_query.rs"
click node_write "https://github.com/cartert27/scion/blob/main/crates/scion-server/src/handlers/write.rs"
click node_auth "https://github.com/cartert27/scion/blob/main/crates/scion-auth/src/service.rs"
click node_policy "https://github.com/cartert27/scion/blob/main/crates/scion-policy/src/policy.rs"
click node_redaction "https://github.com/cartert27/scion/blob/main/crates/scion-redaction/src/redactor.rs"
click node_history "https://github.com/cartert27/scion/blob/main/crates/scion-history/src/create.rs"
click node_merge "https://github.com/cartert27/scion/blob/main/crates/scion-merge/src/merge3.rs"
click node_derived "https://github.com/cartert27/scion/blob/main/crates/scion-derived/src/engine.rs"
click node_objects "https://github.com/cartert27/scion/blob/main/crates/scion-object/src/changeset.rs"
click node_store_api "https://github.com/cartert27/scion/blob/main/crates/scion-store/src/storage.rs"
click node_crdb "https://github.com/cartert27/scion/blob/main/crates/scion-store-crdb/src/store.rs"
click node_s3 "https://github.com/cartert27/scion/blob/main/crates/scion-store-s3/src/store.rs"

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_wc,node_importer,node_daemon,node_proto toneBlue
class node_server,node_query,node_history_query,node_write toneAmber
class node_history,node_merge,node_derived,node_objects toneMint
class node_store_api,node_crdb,node_s3 toneRose
class node_auth,node_policy,node_redaction,node_user,node_github toneIndigo
```

## Components

### Client workflows

- [Scion CLI](https://github.com/cartert27/scion/blob/main/crates/scion-cli/src/cli/args.rs): `crates/scion-cli/src/cli/args.rs`
- [Working copy](https://github.com/cartert27/scion/blob/main/crates/scion-wc/src/checkout.rs): `crates/scion-wc/src/checkout.rs`
- [Git importer](https://github.com/cartert27/scion/blob/main/crates/scion-import/src/import/git.rs): `crates/scion-import/src/import/git.rs`
- [Local daemon](https://github.com/cartert27/scion/blob/main/crates/scion-daemon/src/daemon.rs): `crates/scion-daemon/src/daemon.rs`
- [gRPC client](https://github.com/cartert27/scion/blob/main/crates/scion-proto/src/client.rs): `crates/scion-proto/src/client.rs`

### Server services

- [Server application](https://github.com/cartert27/scion/blob/main/crates/scion-server/src/app.rs): `crates/scion-server/src/app.rs`
- [Query handlers](https://github.com/cartert27/scion/blob/main/crates/scion-server/src/handlers/query.rs): `crates/scion-server/src/handlers/query.rs`
- [History queries](https://github.com/cartert27/scion/blob/main/crates/scion-server/src/handlers/history_query.rs): `crates/scion-server/src/handlers/history_query.rs`
- [Write and ref handlers](https://github.com/cartert27/scion/blob/main/crates/scion-server/src/handlers/write.rs): `crates/scion-server/src/handlers/write.rs`

### History and data

- [History operations](https://github.com/cartert27/scion/blob/main/crates/scion-history/src/create.rs): `crates/scion-history/src/create.rs`
- [Merge engine](https://github.com/cartert27/scion/blob/main/crates/scion-merge/src/merge3.rs): `crates/scion-merge/src/merge3.rs`
- [Derived data](https://github.com/cartert27/scion/blob/main/crates/scion-derived/src/engine.rs): `crates/scion-derived/src/engine.rs`
- [Immutable objects](https://github.com/cartert27/scion/blob/main/crates/scion-object/src/changeset.rs): `crates/scion-object/src/changeset.rs`

### Persistence

- [Storage interfaces](https://github.com/cartert27/scion/blob/main/crates/scion-store/src/storage.rs): `crates/scion-store/src/storage.rs`
- [CockroachDB metadata](https://github.com/cartert27/scion/blob/main/crates/scion-store-crdb/src/store.rs): `crates/scion-store-crdb/src/store.rs`
- [S3 object store](https://github.com/cartert27/scion/blob/main/crates/scion-store-s3/src/store.rs): `crates/scion-store-s3/src/store.rs`

### Identity and extensions

- [Auth and access](https://github.com/cartert27/scion/blob/main/crates/scion-auth/src/service.rs): `crates/scion-auth/src/service.rs`
- [Authorization policy](https://github.com/cartert27/scion/blob/main/crates/scion-policy/src/policy.rs): `crates/scion-policy/src/policy.rs`
- [Content redaction](https://github.com/cartert27/scion/blob/main/crates/scion-redaction/src/redactor.rs): `crates/scion-redaction/src/redactor.rs`

### Other components

- **Developer or agent**
- **GitHub OAuth**

## Connections

- Developer or agent → Scion CLI: runs commands
- Scion CLI → gRPC client: sends RPCs
- Working copy → gRPC client: fetches and writes
- Git importer → gRPC client: publishes history
- gRPC client → Server application: calls gRPC (evidence: `crates/scion-proto/src/client.rs`)
- Server application → Query handlers: routes requests (evidence: `crates/scion-server/src/app.rs`)
- Server application → History queries: routes requests (evidence: `crates/scion-server/src/app.rs`)
- Server application → Write and ref handlers: routes requests
- Query handlers → Authorization policy: checks access (evidence: `crates/scion-server/src/handlers/query.rs`)
- History queries → Authorization policy: checks access (evidence: `crates/scion-server/src/handlers/history_query.rs`)
- Query handlers → Merge engine: computes hunks (evidence: `crates/scion-server/src/handlers/query.rs`)
- History queries → History operations: reads log (evidence: `crates/scion-server/src/handlers/history_query.rs`)
- History operations → Storage interfaces: persists history
- Query handlers → Immutable objects: reads objects (evidence: `crates/scion-server/src/handlers/query.rs`)
- Storage interfaces → CockroachDB metadata: uses metadata backend
- Storage interfaces → S3 object store: uses blob backend
- Server application → Derived data: assembles derivation
- Server application → Auth and access: configures authentication
- Server application → Content redaction: applies redaction
- Auth and access → GitHub OAuth: authenticates with
- Local daemon → gRPC client: forwards requests
- Developer or agent → Working copy: checks out paths
- Developer or agent → Git importer: migrates Git history
