# anyproto/any architecture

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

- Interactive diagram: https://gitdiagram.com/anyproto/any
- Repository: https://github.com/anyproto/any

## Overview

Any is a local-first, end-to-end encrypted collaborative database exposed through a localhost HTTP API and CLI. The main workflow is: a user starts the server and initializes an account, an application creates or updates space data, and the server returns query results or streams live changes; connected devices synchronize encrypted changes over peer-to-peer links. The product also includes full-text, semantic, and hybrid search; collaborative editor and chat primitives; and push notifications. The README documents the workflow and capabilities; unsampled handler and sync internals are represented only where the tree or excerpts support them.

Main entry points: [`internal/server/routes.go`](https://github.com/anyproto/any/blob/main/internal/server/routes.go) (Local HTTP API), [`internal/server/engine.go`](https://github.com/anyproto/any/blob/main/internal/server/engine.go) (Server engine), [`internal/localstore/localstore.go`](https://github.com/anyproto/any/blob/main/internal/localstore/localstore.go) (Local data store), [`internal/indexer/worker.go`](https://github.com/anyproto/any/blob/main/internal/indexer/worker.go) (Search indexing)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["User access"]
  node_binary["Any binary<br/>[main.go]"]
  node_cli["CLI commands<br/>[root.go]"]
  node_httpclient["HTTP client<br/>[client.go]"]
end

subgraph group_runtime["Server and sync"]
  node_localapi["Local HTTP API<br/>[routes.go]"]
  node_engine["Server engine<br/>[engine.go]"]
  node_sync["Encrypted device sync<br/>[engine.go]"]
  node_account["Identity and account<br/>[identity.go]"]
end

subgraph group_data["Data and queries"]
  node_space["Spaces and objects"]
  node_mutations["Data mutations<br/>[handlers_modify.go]"]
  node_query["Object queries<br/>[handlers_query.go]"]
  node_dataset["Dataset queries"]
  node_live["Live query streams"]
  node_localstore[("Local data store<br/>[localstore.go]")]
end

subgraph group_search["Index and search"]
  node_indexer["Search indexing<br/>[worker.go]"]
  node_indexstore[("Search index store<br/>[store.go]")]
  node_embed["Embedding providers<br/>[embed_worker.go]"]
end

subgraph group_collab["Collaboration features"]
  node_editor["Collaborative editor<br/>[handler.go]"]
  node_chat["Encrypted chat<br/>[handler.go]"]
  node_push["Push notifications<br/>[push.go]"]
end

node_user(("User or app"))
node_syncnodes(("Sync nodes"))

node_user -->|"starts"| node_binary
node_binary -->|"executes"| node_cli
node_user -->|"requests data"| node_httpclient
node_httpclient -->|"sends HTTP"| node_localapi
node_cli -.->|"controls server"| node_localapi
node_localapi -.->|"serves requests"| node_engine
node_engine -.->|"opens account"| node_account
node_engine -->|"starts sync"| node_sync
node_sync -->|"relays encrypted changes"| node_syncnodes
node_localapi -.->|"routes data requests"| node_space
node_space -.->|"reads and writes"| node_localstore
node_localapi -.->|"routes mutations"| node_mutations
node_mutations -.->|"updates data"| node_localstore
node_localapi -.->|"routes queries"| node_query
node_query -.->|"queries data"| node_localstore
node_localapi -.->|"routes dataset queries"| node_dataset
node_dataset -.->|"queries datasets"| node_localstore
node_localapi -.->|"routes subscriptions"| node_live
node_live -->|"streams changes"| node_user
node_engine -->|"starts indexing"| node_indexer
node_indexer -.->|"updates index"| node_indexstore
node_indexer -.->|"requests vectors"| node_embed
node_engine -.->|"hosts editor"| node_editor
node_engine -.->|"hosts chat"| node_chat
node_engine -->|"starts notifications"| node_push

click node_binary "https://github.com/anyproto/any/blob/main/cmd/any/main.go"
click node_cli "https://github.com/anyproto/any/blob/main/internal/cli/root.go"
click node_httpclient "https://github.com/anyproto/any/blob/main/internal/client/client.go"
click node_localapi "https://github.com/anyproto/any/blob/main/internal/server/routes.go"
click node_engine "https://github.com/anyproto/any/blob/main/internal/server/engine.go"
click node_sync "https://github.com/anyproto/any/blob/main/internal/server/engine.go"
click node_account "https://github.com/anyproto/any/blob/main/internal/server/identity.go"
click node_space "https://github.com/anyproto/any/blob/main/internal/server/handlers_objects.go"
click node_mutations "https://github.com/anyproto/any/blob/main/internal/server/handlers_modify.go"
click node_query "https://github.com/anyproto/any/blob/main/internal/server/handlers_query.go"
click node_dataset "https://github.com/anyproto/any/blob/main/internal/server/handlers_dataset_query.go"
click node_live "https://github.com/anyproto/any/blob/main/internal/server/handlers_query_subscribe.go"
click node_localstore "https://github.com/anyproto/any/blob/main/internal/localstore/localstore.go"
click node_indexer "https://github.com/anyproto/any/blob/main/internal/indexer/worker.go"
click node_indexstore "https://github.com/anyproto/any/blob/main/internal/indexer/store.go"
click node_embed "https://github.com/anyproto/any/blob/main/internal/indexer/embed_worker.go"
click node_editor "https://github.com/anyproto/any/blob/main/internal/editor/handler.go"
click node_chat "https://github.com/anyproto/any/blob/main/internal/chat/handler.go"
click node_push "https://github.com/anyproto/any/blob/main/internal/push/push.go"

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_binary,node_cli,node_httpclient,node_user toneBlue
class node_localapi,node_engine,node_sync,node_account toneAmber
class node_space,node_mutations,node_query,node_dataset,node_live,node_localstore toneMint
class node_indexer,node_indexstore,node_embed toneRose
class node_editor,node_chat,node_push,node_syncnodes toneIndigo
```

## Components

### User access

- [Any binary](https://github.com/anyproto/any/blob/main/cmd/any/main.go): `cmd/any/main.go`
- [CLI commands](https://github.com/anyproto/any/blob/main/internal/cli/root.go): `internal/cli/root.go`
- [HTTP client](https://github.com/anyproto/any/blob/main/internal/client/client.go): `internal/client/client.go`

### Server and sync

- [Local HTTP API](https://github.com/anyproto/any/blob/main/internal/server/routes.go): `internal/server/routes.go`
- [Server engine](https://github.com/anyproto/any/blob/main/internal/server/engine.go): `internal/server/engine.go`
- [Encrypted device sync](https://github.com/anyproto/any/blob/main/internal/server/engine.go): `internal/server/engine.go`
- [Identity and account](https://github.com/anyproto/any/blob/main/internal/server/identity.go): `internal/server/identity.go`

### Data and queries

- [Spaces and objects](https://github.com/anyproto/any/blob/main/internal/server/handlers_objects.go): `internal/server/handlers_objects.go`
- [Data mutations](https://github.com/anyproto/any/blob/main/internal/server/handlers_modify.go): `internal/server/handlers_modify.go`
- [Object queries](https://github.com/anyproto/any/blob/main/internal/server/handlers_query.go): `internal/server/handlers_query.go`
- [Dataset queries](https://github.com/anyproto/any/blob/main/internal/server/handlers_dataset_query.go): `internal/server/handlers_dataset_query.go`
- [Live query streams](https://github.com/anyproto/any/blob/main/internal/server/handlers_query_subscribe.go): `internal/server/handlers_query_subscribe.go`
- [Local data store](https://github.com/anyproto/any/blob/main/internal/localstore/localstore.go): `internal/localstore/localstore.go`

### Index and search

- [Search indexing](https://github.com/anyproto/any/blob/main/internal/indexer/worker.go): `internal/indexer/worker.go`
- [Search index store](https://github.com/anyproto/any/blob/main/internal/indexer/store.go): `internal/indexer/store.go`
- [Embedding providers](https://github.com/anyproto/any/blob/main/internal/indexer/embed_worker.go): `internal/indexer/embed_worker.go`

### Collaboration features

- [Collaborative editor](https://github.com/anyproto/any/blob/main/internal/editor/handler.go): `internal/editor/handler.go`
- [Encrypted chat](https://github.com/anyproto/any/blob/main/internal/chat/handler.go): `internal/chat/handler.go`
- [Push notifications](https://github.com/anyproto/any/blob/main/internal/push/push.go): `internal/push/push.go`

### Other components

- **User or app**
- **Sync nodes**

## Connections

- User or app → Any binary: starts
- Any binary → CLI commands: executes (evidence: `cmd/any/main.go`)
- User or app → HTTP client: requests data
- HTTP client → Local HTTP API: sends HTTP
- CLI commands → Local HTTP API: controls server
- Local HTTP API → Server engine: serves requests
- Server engine → Identity and account: opens account
- Server engine → Encrypted device sync: starts sync (evidence: `internal/server/engine.go`)
- Encrypted device sync → Sync nodes: relays encrypted changes
- Local HTTP API → Spaces and objects: routes data requests
- Spaces and objects → Local data store: reads and writes
- Local HTTP API → Data mutations: routes mutations
- Data mutations → Local data store: updates data
- Local HTTP API → Object queries: routes queries
- Object queries → Local data store: queries data
- Local HTTP API → Dataset queries: routes dataset queries
- Dataset queries → Local data store: queries datasets
- Local HTTP API → Live query streams: routes subscriptions
- Live query streams → User or app: streams changes
- Server engine → Search indexing: starts indexing (evidence: `internal/server/engine.go`)
- Search indexing → Search index store: updates index
- Search indexing → Embedding providers: requests vectors
- Server engine → Collaborative editor: hosts editor
- Server engine → Encrypted chat: hosts chat
- Server engine → Push notifications: starts notifications (evidence: `internal/server/engine.go`)
