# ink-db/ink architecture

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

- Interactive diagram: https://gitdiagram.com/ink-db/ink
- Repository: https://github.com/ink-db/ink

## Overview

Ink is an append-only, tamper-evident database with a native browser and a TCP client/server interface. The main workflow is to submit IQL or append requests through a client or the browser, process them through the server/query and storage layers, and return records or integrity results. Storage, indexing, signatures, access control, and Merkle proofs are distinct domain capabilities. The browser also supports local browsing, query execution, verification, and proofs. Some server and UI implementations were not sampled, so uncertain internal links are omitted.

Main entry points: [`ink-browser/src/ui/app.rs`](https://github.com/ink-db/ink/blob/stable/ink-browser/src/ui/app.rs) (Desktop App), [`ink-core/src/store.rs`](https://github.com/ink-db/ink/blob/stable/ink-core/src/store.rs) (Database Store), [`ink-client/src/connection.rs`](https://github.com/ink-db/ink/blob/stable/ink-client/src/connection.rs) (Client Connection), [`ink-query/src/evaluator.rs`](https://github.com/ink-db/ink/blob/stable/ink-query/src/evaluator.rs) (IQL Evaluator)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_browser["Ink Browser"]
  node_browser_app["Desktop App<br/>[app.rs]"]
  node_browser_backend["Browser Backend<br/>[local.rs]"]
  node_settings["Browser Settings<br/>[settings.rs]"]
  node_browse["Record Browser<br/>[browse.rs]"]
  node_connection_view["Connection View<br/>[connection.rs]"]
  node_execute_view["Query View<br/>[execute_iql.rs]"]
  node_filter_builder["Filter Builder<br/>[filter_builder.rs]"]
  node_verify_view["Integrity View<br/>[verify.rs]"]
  node_proofs_view["Proofs View<br/>[proofs.rs]"]
  node_merkle_view["Merkle View<br/>[merkle.rs]"]
end

subgraph group_query["Query And Access"]
  node_lexer["IQL Lexer<br/>[lexer.rs]"]
  node_parser["IQL Parser<br/>[parser.rs]"]
  node_ast["IQL AST<br/>[ast.rs]"]
  node_evaluator["IQL Evaluator<br/>[evaluator.rs]"]
  node_authorization["Access Registry<br/>[auth.rs]"]
end

subgraph group_core["Storage And Integrity"]
  node_store[("Database Store<br/>[store.rs]")]
  node_segments["Append Segments<br/>[segment.rs]"]
  node_index["Rebuildable Index<br/>[index.rs]"]
  node_records["Signed Records<br/>[record.rs]"]
  node_crypto["Ed25519 Crypto<br/>[crypto.rs]"]
  node_merkle["Merkle Tree<br/>[merkle.rs]"]
end

subgraph group_protocol["Client And Protocol"]
  node_client_shell["Client Shell<br/>[shell.rs]"]
  node_client_connection["Client Connection<br/>[connection.rs]"]
  node_key["Client Keys<br/>[key.rs]"]
  node_frames["Wire Frames<br/>[frame.rs]"]
  node_messages["Wire Messages<br/>[messages.rs]"]
  node_codec["Frame Codec<br/>[codec.rs]"]
end

subgraph group_server["Server"]
  node_server_cli["Server CLI<br/>[cli.rs]"]
  node_server["TCP Daemon<br/>[server.rs]"]
end

node_user(("User"))
node_database_files[("Database Files")]

node_user -->|"uses"| node_browser_app
node_browser_app -->|"loads settings"| node_settings
node_browser_app -->|"shows"| node_browse
node_browser_app -->|"shows"| node_connection_view
node_browser_app -->|"shows"| node_execute_view
node_browser_app -->|"shows"| node_verify_view
node_browser_app -->|"shows"| node_proofs_view
node_browser_app -->|"shows"| node_merkle_view
node_browse -->|"loads pages"| node_browser_backend
node_browse -->|"uses filters"| node_filter_builder
node_execute_view -->|"executes through"| node_browser_backend
node_browser_backend -->|"opens local data"| node_database_files
node_user -->|"runs commands"| node_client_shell
node_client_shell -->|"uses"| node_client_connection
node_client_connection -->|"signs requests"| node_key
node_client_connection -->|"exchanges messages"| node_messages
node_client_connection -->|"frames traffic"| node_frames
node_messages -->|"serializes as"| node_frames
node_codec -->|"encodes frames"| node_frames
node_user -->|"administers"| node_server_cli
node_server_cli -.->|"configures daemon"| node_server
node_client_connection -.->|"connects over TCP"| node_server
node_server -.->|"handles protocol"| node_messages
node_server -.->|"dispatches queries"| node_evaluator
node_lexer -->|"tokenizes input"| node_parser
node_parser -->|"builds statements"| node_ast
node_evaluator -->|"parses input"| node_parser
node_evaluator -->|"evaluates statements"| node_ast
node_evaluator -.->|"executes against"| node_store
node_store -->|"reads and appends"| node_segments
node_store -->|"updates and queries"| node_index
node_store -->|"validates records"| node_records
node_store -->|"checks signatures"| node_crypto
node_store -->|"builds proofs"| node_merkle
node_store -->|"checks access"| node_authorization
node_segments -->|"persists log"| node_database_files
node_store -->|"opens database"| node_database_files

click node_browser_app "https://github.com/ink-db/ink/blob/stable/ink-browser/src/ui/app.rs"
click node_browser_backend "https://github.com/ink-db/ink/blob/stable/ink-browser/src/backend/local.rs"
click node_settings "https://github.com/ink-db/ink/blob/stable/ink-browser/src/settings.rs"
click node_browse "https://github.com/ink-db/ink/blob/stable/ink-browser/src/ui/browse.rs"
click node_connection_view "https://github.com/ink-db/ink/blob/stable/ink-browser/src/ui/connection.rs"
click node_execute_view "https://github.com/ink-db/ink/blob/stable/ink-browser/src/ui/execute_iql.rs"
click node_filter_builder "https://github.com/ink-db/ink/blob/stable/ink-browser/src/ui/filter_builder.rs"
click node_verify_view "https://github.com/ink-db/ink/blob/stable/ink-browser/src/ui/verify.rs"
click node_proofs_view "https://github.com/ink-db/ink/blob/stable/ink-browser/src/ui/proofs.rs"
click node_merkle_view "https://github.com/ink-db/ink/blob/stable/ink-browser/src/ui/merkle.rs"
click node_lexer "https://github.com/ink-db/ink/blob/stable/ink-query/src/lexer.rs"
click node_parser "https://github.com/ink-db/ink/blob/stable/ink-query/src/parser.rs"
click node_ast "https://github.com/ink-db/ink/blob/stable/ink-query/src/ast.rs"
click node_evaluator "https://github.com/ink-db/ink/blob/stable/ink-query/src/evaluator.rs"
click node_authorization "https://github.com/ink-db/ink/blob/stable/ink-core/src/auth.rs"
click node_store "https://github.com/ink-db/ink/blob/stable/ink-core/src/store.rs"
click node_segments "https://github.com/ink-db/ink/blob/stable/ink-core/src/segment.rs"
click node_index "https://github.com/ink-db/ink/blob/stable/ink-core/src/index.rs"
click node_records "https://github.com/ink-db/ink/blob/stable/ink-core/src/record.rs"
click node_crypto "https://github.com/ink-db/ink/blob/stable/ink-core/src/crypto.rs"
click node_merkle "https://github.com/ink-db/ink/blob/stable/ink-core/src/merkle.rs"
click node_client_shell "https://github.com/ink-db/ink/blob/stable/ink-client/src/shell.rs"
click node_client_connection "https://github.com/ink-db/ink/blob/stable/ink-client/src/connection.rs"
click node_key "https://github.com/ink-db/ink/blob/stable/ink-client/src/key.rs"
click node_frames "https://github.com/ink-db/ink/blob/stable/ink-proto/src/frame.rs"
click node_messages "https://github.com/ink-db/ink/blob/stable/ink-proto/src/messages.rs"
click node_codec "https://github.com/ink-db/ink/blob/stable/ink-proto/src/codec.rs"
click node_server_cli "https://github.com/ink-db/ink/blob/stable/ink-server/src/cli.rs"
click node_server "https://github.com/ink-db/ink/blob/stable/ink-server/src/server.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_browser_app,node_browser_backend,node_settings,node_browse,node_connection_view,node_execute_view,node_filter_builder,node_verify_view,node_proofs_view,node_merkle_view,node_user toneBlue
class node_lexer,node_parser,node_ast,node_evaluator,node_authorization,node_database_files toneAmber
class node_store,node_segments,node_index,node_records,node_crypto,node_merkle toneMint
class node_client_shell,node_client_connection,node_key,node_frames,node_messages,node_codec toneRose
class node_server_cli,node_server toneIndigo
```

## Components

### Ink Browser

- [Desktop App](https://github.com/ink-db/ink/blob/stable/ink-browser/src/ui/app.rs): `ink-browser/src/ui/app.rs`
- [Browser Backend](https://github.com/ink-db/ink/blob/stable/ink-browser/src/backend/local.rs): `ink-browser/src/backend/local.rs`
- [Browser Settings](https://github.com/ink-db/ink/blob/stable/ink-browser/src/settings.rs): `ink-browser/src/settings.rs`
- [Record Browser](https://github.com/ink-db/ink/blob/stable/ink-browser/src/ui/browse.rs): `ink-browser/src/ui/browse.rs`
- [Connection View](https://github.com/ink-db/ink/blob/stable/ink-browser/src/ui/connection.rs): `ink-browser/src/ui/connection.rs`
- [Query View](https://github.com/ink-db/ink/blob/stable/ink-browser/src/ui/execute_iql.rs): `ink-browser/src/ui/execute_iql.rs`
- [Filter Builder](https://github.com/ink-db/ink/blob/stable/ink-browser/src/ui/filter_builder.rs): `ink-browser/src/ui/filter_builder.rs`
- [Integrity View](https://github.com/ink-db/ink/blob/stable/ink-browser/src/ui/verify.rs): `ink-browser/src/ui/verify.rs`
- [Proofs View](https://github.com/ink-db/ink/blob/stable/ink-browser/src/ui/proofs.rs): `ink-browser/src/ui/proofs.rs`
- [Merkle View](https://github.com/ink-db/ink/blob/stable/ink-browser/src/ui/merkle.rs): `ink-browser/src/ui/merkle.rs`

### Query And Access

- [IQL Lexer](https://github.com/ink-db/ink/blob/stable/ink-query/src/lexer.rs): `ink-query/src/lexer.rs`
- [IQL Parser](https://github.com/ink-db/ink/blob/stable/ink-query/src/parser.rs): `ink-query/src/parser.rs`
- [IQL AST](https://github.com/ink-db/ink/blob/stable/ink-query/src/ast.rs): `ink-query/src/ast.rs`
- [IQL Evaluator](https://github.com/ink-db/ink/blob/stable/ink-query/src/evaluator.rs): `ink-query/src/evaluator.rs`
- [Access Registry](https://github.com/ink-db/ink/blob/stable/ink-core/src/auth.rs): `ink-core/src/auth.rs`

### Storage And Integrity

- [Database Store](https://github.com/ink-db/ink/blob/stable/ink-core/src/store.rs): `ink-core/src/store.rs`
- [Append Segments](https://github.com/ink-db/ink/blob/stable/ink-core/src/segment.rs): `ink-core/src/segment.rs`
- [Rebuildable Index](https://github.com/ink-db/ink/blob/stable/ink-core/src/index.rs): `ink-core/src/index.rs`
- [Signed Records](https://github.com/ink-db/ink/blob/stable/ink-core/src/record.rs): `ink-core/src/record.rs`
- [Ed25519 Crypto](https://github.com/ink-db/ink/blob/stable/ink-core/src/crypto.rs): `ink-core/src/crypto.rs`
- [Merkle Tree](https://github.com/ink-db/ink/blob/stable/ink-core/src/merkle.rs): `ink-core/src/merkle.rs`

### Client And Protocol

- [Client Shell](https://github.com/ink-db/ink/blob/stable/ink-client/src/shell.rs): `ink-client/src/shell.rs`
- [Client Connection](https://github.com/ink-db/ink/blob/stable/ink-client/src/connection.rs): `ink-client/src/connection.rs`
- [Client Keys](https://github.com/ink-db/ink/blob/stable/ink-client/src/key.rs): `ink-client/src/key.rs`
- [Wire Frames](https://github.com/ink-db/ink/blob/stable/ink-proto/src/frame.rs): `ink-proto/src/frame.rs`
- [Wire Messages](https://github.com/ink-db/ink/blob/stable/ink-proto/src/messages.rs): `ink-proto/src/messages.rs`
- [Frame Codec](https://github.com/ink-db/ink/blob/stable/ink-proto/src/codec.rs): `ink-proto/src/codec.rs`

### Server

- [Server CLI](https://github.com/ink-db/ink/blob/stable/ink-server/src/cli.rs): `ink-server/src/cli.rs`
- [TCP Daemon](https://github.com/ink-db/ink/blob/stable/ink-server/src/server.rs): `ink-server/src/server.rs`

### Other components

- **User**
- **Database Files**

## Connections

- User → Desktop App: uses
- Desktop App → Browser Settings: loads settings (evidence: `ink-browser/src/ui/app.rs`)
- Desktop App → Record Browser: shows (evidence: `ink-browser/src/ui/app.rs`)
- Desktop App → Connection View: shows (evidence: `ink-browser/src/ui/app.rs`)
- Desktop App → Query View: shows (evidence: `ink-browser/src/ui/app.rs`)
- Desktop App → Integrity View: shows (evidence: `ink-browser/src/ui/app.rs`)
- Desktop App → Proofs View: shows (evidence: `ink-browser/src/ui/app.rs`)
- Desktop App → Merkle View: shows (evidence: `ink-browser/src/ui/app.rs`)
- Record Browser → Browser Backend: loads pages (evidence: `ink-browser/src/ui/browse.rs`)
- Record Browser → Filter Builder: uses filters (evidence: `ink-browser/src/ui/browse.rs`)
- Query View → Browser Backend: executes through (evidence: `ink-browser/src/ui/execute_iql.rs`)
- Browser Backend → Database Files: opens local data
- User → Client Shell: runs commands
- Client Shell → Client Connection: uses (evidence: `ink-client/src/shell.rs`)
- Client Connection → Client Keys: signs requests (evidence: `ink-client/src/connection.rs`)
- Client Connection → Wire Messages: exchanges messages (evidence: `ink-client/src/connection.rs`)
- Client Connection → Wire Frames: frames traffic (evidence: `ink-client/src/connection.rs`)
- Wire Messages → Wire Frames: serializes as (evidence: `ink-proto/src/messages.rs`)
- Frame Codec → Wire Frames: encodes frames (evidence: `ink-proto/src/codec.rs`)
- User → Server CLI: administers
- Server CLI → TCP Daemon: configures daemon
- Client Connection → TCP Daemon: connects over TCP
- TCP Daemon → Wire Messages: handles protocol
- TCP Daemon → IQL Evaluator: dispatches queries
- IQL Lexer → IQL Parser: tokenizes input (evidence: `ink-query/src/parser.rs`)
- IQL Parser → IQL AST: builds statements (evidence: `ink-query/src/parser.rs`)
- IQL Evaluator → IQL Parser: parses input (evidence: `ink-query/src/evaluator.rs`)
- IQL Evaluator → IQL AST: evaluates statements (evidence: `ink-query/src/evaluator.rs`)
- IQL Evaluator → Database Store: executes against
- Database Store → Append Segments: reads and appends (evidence: `ink-core/src/store.rs`)
- Database Store → Rebuildable Index: updates and queries (evidence: `ink-core/src/store.rs`)
- Database Store → Signed Records: validates records (evidence: `ink-core/src/store.rs`)
- Database Store → Ed25519 Crypto: checks signatures (evidence: `ink-core/src/store.rs`)
- Database Store → Merkle Tree: builds proofs (evidence: `ink-core/src/store.rs`)
- Database Store → Access Registry: checks access (evidence: `ink-core/src/store.rs`)
- Append Segments → Database Files: persists log (evidence: `ink-core/src/segment.rs`)
- Database Store → Database Files: opens database
