# arjunbalaji123/zero-mesh architecture

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

- Interactive diagram: https://gitdiagram.com/arjunbalaji123/zero-mesh
- Repository: https://github.com/arjunbalaji123/zero-mesh

## Overview

ZeroMesh is a decentralized encrypted file-storage network. Users upload and retrieve files through the CLI or REST/web interface: the file manager chunks and encrypts data, stores local copies, replicates chunks to peers, and records manifests; downloads retrieve chunks, decrypt and verify them, then assemble the file. The node integrates storage with Kademlia discovery and TCP messaging. The README documents capabilities beyond the sampled excerpts; links based only on that documentation are cited to the README, and unsampled implementation details are not inferred.

Main entry points: [`zeromesh/node.py`](https://github.com/arjunbalaji123/zero-mesh/blob/main/zeromesh/node.py) (ZeroMesh node), [`zeromesh/storage/file_manager.py`](https://github.com/arjunbalaji123/zero-mesh/blob/main/zeromesh/storage/file_manager.py) (File manager), [`zeromesh/api/app.py`](https://github.com/arjunbalaji123/zero-mesh/blob/main/zeromesh/api/app.py) (REST API), [`zeromesh/dht/routing_table.py`](https://github.com/arjunbalaji123/zero-mesh/blob/main/zeromesh/dht/routing_table.py) (Routing table)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interfaces["User interfaces"]
  node_cli["CLI<br/>[cli.py]"]
  node_rest_api["REST API<br/>[app.py]"]
  node_web_dashboard["Web dashboard<br/>[app.js]"]
end

subgraph group_file_pipeline["File pipeline"]
  node_file_manager["File manager<br/>[file_manager.py]"]
  node_chunker["Chunker and assembler<br/>[chunker.py]"]
  node_crypto["Hash and encryption<br/>[engine.py]"]
  node_chunk_store[("Local chunk store<br/>[chunk_store.py]")]
  node_manifest_registry[("Manifest registry")]
end

subgraph group_peer_network["Peer network"]
  node_routing_table["Routing table<br/>[routing_table.py]"]
  node_kbucket["K-buckets<br/>[kbucket.py]"]
  node_node_id["Node identity<br/>[node_id.py]"]
  node_lookup["Kademlia lookup<br/>[lookup.py]"]
  node_network_server["TCP server<br/>[server.py]"]
  node_connection["Peer connection<br/>[connection.py]"]
  node_protocol["Wire protocol<br/>[protocol.py]"]
  node_peer_scorer["Peer scorer<br/>[peer_scorer.py]"]
end

subgraph group_node_state["Node state and telemetry"]
  node_node["ZeroMesh node<br/>[node.py]"]
  node_metrics["Prometheus metrics<br/>[metrics.py]"]
end

node_user(("User"))
node_other_peers(("Other peers"))

node_user -->|"runs commands"| node_cli
node_user -->|"uses endpoints"| node_rest_api
node_rest_api -->|"serves dashboard"| node_web_dashboard
node_cli -->|"operates node"| node_node
node_rest_api -->|"uses node"| node_node
node_rest_api -->|"uploads and downloads"| node_file_manager
node_rest_api -->|"reads and deletes"| node_manifest_registry
node_rest_api -->|"updates counters"| node_metrics
node_file_manager -->|"chunks and assembles"| node_chunker
node_file_manager -->|"encrypts and decrypts"| node_crypto
node_file_manager -->|"writes and reads chunks"| node_chunk_store
node_file_manager -->|"saves and loads manifests"| node_manifest_registry
node_file_manager -->|"selects peers"| node_routing_table
node_file_manager -->|"ranks peers"| node_peer_scorer
node_file_manager -->|"finds chunk peers"| node_lookup
node_node -->|"coordinates file operations"| node_file_manager
node_node -->|"starts peer service"| node_network_server
node_node -->|"maintains peer routes"| node_routing_table
node_node -->|"provides lookup RPC"| node_lookup
node_node -->|"coordinates storage"| node_chunk_store
node_node -->|"coordinates manifests"| node_manifest_registry
node_node -->|"records peer reliability"| node_peer_scorer
node_node -->|"records telemetry"| node_metrics
node_routing_table -->|"updates buckets"| node_kbucket
node_routing_table -->|"computes distance"| node_node_id
node_kbucket -->|"keys peers"| node_node_id
node_lookup -->|"orders candidates"| node_node_id
node_network_server -->|"accepts connections"| node_connection
node_connection -->|"encodes and decodes"| node_protocol
node_node -->|"exchanges RPCs"| node_other_peers
node_metrics -->|"exposes scrape endpoint"| node_user

click node_cli "https://github.com/arjunbalaji123/zero-mesh/blob/main/zeromesh/cli.py"
click node_rest_api "https://github.com/arjunbalaji123/zero-mesh/blob/main/zeromesh/api/app.py"
click node_web_dashboard "https://github.com/arjunbalaji123/zero-mesh/blob/main/zeromesh/api/static/app.js"
click node_file_manager "https://github.com/arjunbalaji123/zero-mesh/blob/main/zeromesh/storage/file_manager.py"
click node_chunker "https://github.com/arjunbalaji123/zero-mesh/blob/main/zeromesh/core/chunker.py"
click node_crypto "https://github.com/arjunbalaji123/zero-mesh/blob/main/zeromesh/crypto/engine.py"
click node_chunk_store "https://github.com/arjunbalaji123/zero-mesh/blob/main/zeromesh/storage/chunk_store.py"
click node_manifest_registry "https://github.com/arjunbalaji123/zero-mesh/blob/main/zeromesh/storage/manifest_registry.py"
click node_node "https://github.com/arjunbalaji123/zero-mesh/blob/main/zeromesh/node.py"
click node_routing_table "https://github.com/arjunbalaji123/zero-mesh/blob/main/zeromesh/dht/routing_table.py"
click node_kbucket "https://github.com/arjunbalaji123/zero-mesh/blob/main/zeromesh/dht/kbucket.py"
click node_node_id "https://github.com/arjunbalaji123/zero-mesh/blob/main/zeromesh/dht/node_id.py"
click node_lookup "https://github.com/arjunbalaji123/zero-mesh/blob/main/zeromesh/dht/lookup.py"
click node_network_server "https://github.com/arjunbalaji123/zero-mesh/blob/main/zeromesh/network/server.py"
click node_connection "https://github.com/arjunbalaji123/zero-mesh/blob/main/zeromesh/network/connection.py"
click node_protocol "https://github.com/arjunbalaji123/zero-mesh/blob/main/zeromesh/network/protocol.py"
click node_peer_scorer "https://github.com/arjunbalaji123/zero-mesh/blob/main/zeromesh/network/peer_scorer.py"
click node_metrics "https://github.com/arjunbalaji123/zero-mesh/blob/main/zeromesh/monitoring/metrics.py"

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_rest_api,node_web_dashboard,node_user toneBlue
class node_file_manager,node_chunker,node_crypto,node_chunk_store,node_manifest_registry toneAmber
class node_routing_table,node_kbucket,node_node_id,node_lookup,node_network_server,node_connection,node_protocol,node_peer_scorer toneMint
class node_node,node_metrics toneRose
class node_other_peers toneIndigo
```

## Components

### User interfaces

- [CLI](https://github.com/arjunbalaji123/zero-mesh/blob/main/zeromesh/cli.py): `zeromesh/cli.py`
- [REST API](https://github.com/arjunbalaji123/zero-mesh/blob/main/zeromesh/api/app.py): `zeromesh/api/app.py`
- [Web dashboard](https://github.com/arjunbalaji123/zero-mesh/blob/main/zeromesh/api/static/app.js): `zeromesh/api/static/app.js`

### File pipeline

- [File manager](https://github.com/arjunbalaji123/zero-mesh/blob/main/zeromesh/storage/file_manager.py): `zeromesh/storage/file_manager.py`
- [Chunker and assembler](https://github.com/arjunbalaji123/zero-mesh/blob/main/zeromesh/core/chunker.py): `zeromesh/core/chunker.py`
- [Hash and encryption](https://github.com/arjunbalaji123/zero-mesh/blob/main/zeromesh/crypto/engine.py): `zeromesh/crypto/engine.py`
- [Local chunk store](https://github.com/arjunbalaji123/zero-mesh/blob/main/zeromesh/storage/chunk_store.py): `zeromesh/storage/chunk_store.py`
- [Manifest registry](https://github.com/arjunbalaji123/zero-mesh/blob/main/zeromesh/storage/manifest_registry.py): `zeromesh/storage/manifest_registry.py`

### Peer network

- [Routing table](https://github.com/arjunbalaji123/zero-mesh/blob/main/zeromesh/dht/routing_table.py): `zeromesh/dht/routing_table.py`
- [K-buckets](https://github.com/arjunbalaji123/zero-mesh/blob/main/zeromesh/dht/kbucket.py): `zeromesh/dht/kbucket.py`
- [Node identity](https://github.com/arjunbalaji123/zero-mesh/blob/main/zeromesh/dht/node_id.py): `zeromesh/dht/node_id.py`
- [Kademlia lookup](https://github.com/arjunbalaji123/zero-mesh/blob/main/zeromesh/dht/lookup.py): `zeromesh/dht/lookup.py`
- [TCP server](https://github.com/arjunbalaji123/zero-mesh/blob/main/zeromesh/network/server.py): `zeromesh/network/server.py`
- [Peer connection](https://github.com/arjunbalaji123/zero-mesh/blob/main/zeromesh/network/connection.py): `zeromesh/network/connection.py`
- [Wire protocol](https://github.com/arjunbalaji123/zero-mesh/blob/main/zeromesh/network/protocol.py): `zeromesh/network/protocol.py`
- [Peer scorer](https://github.com/arjunbalaji123/zero-mesh/blob/main/zeromesh/network/peer_scorer.py): `zeromesh/network/peer_scorer.py`

### Node state and telemetry

- [ZeroMesh node](https://github.com/arjunbalaji123/zero-mesh/blob/main/zeromesh/node.py): `zeromesh/node.py`
- [Prometheus metrics](https://github.com/arjunbalaji123/zero-mesh/blob/main/zeromesh/monitoring/metrics.py): `zeromesh/monitoring/metrics.py`

### Other components

- **User**
- **Other peers**

## Connections

- User → CLI: runs commands (evidence: `README.md`)
- User → REST API: uses endpoints (evidence: `README.md`)
- REST API → Web dashboard: serves dashboard (evidence: `README.md`)
- CLI → ZeroMesh node: operates node (evidence: `README.md`)
- REST API → ZeroMesh node: uses node (evidence: `zeromesh/api/app.py`)
- REST API → File manager: uploads and downloads (evidence: `zeromesh/api/app.py`)
- REST API → Manifest registry: reads and deletes (evidence: `zeromesh/api/app.py`)
- REST API → Prometheus metrics: updates counters (evidence: `zeromesh/api/app.py`)
- File manager → Chunker and assembler: chunks and assembles (evidence: `README.md`)
- File manager → Hash and encryption: encrypts and decrypts (evidence: `zeromesh/storage/file_manager.py`)
- File manager → Local chunk store: writes and reads chunks (evidence: `zeromesh/storage/file_manager.py`)
- File manager → Manifest registry: saves and loads manifests (evidence: `zeromesh/storage/file_manager.py`)
- File manager → Routing table: selects peers (evidence: `zeromesh/storage/file_manager.py`)
- File manager → Peer scorer: ranks peers (evidence: `zeromesh/storage/file_manager.py`)
- File manager → Kademlia lookup: finds chunk peers (evidence: `zeromesh/storage/file_manager.py`)
- ZeroMesh node → File manager: coordinates file operations (evidence: `README.md`)
- ZeroMesh node → TCP server: starts peer service (evidence: `README.md`)
- ZeroMesh node → Routing table: maintains peer routes (evidence: `README.md`)
- ZeroMesh node → Kademlia lookup: provides lookup RPC (evidence: `zeromesh/node.py`)
- ZeroMesh node → Local chunk store: coordinates storage (evidence: `README.md`)
- ZeroMesh node → Manifest registry: coordinates manifests (evidence: `README.md`)
- ZeroMesh node → Peer scorer: records peer reliability (evidence: `zeromesh/node.py`)
- ZeroMesh node → Prometheus metrics: records telemetry (evidence: `zeromesh/node.py`)
- Routing table → K-buckets: updates buckets (evidence: `zeromesh/dht/routing_table.py`)
- Routing table → Node identity: computes distance (evidence: `zeromesh/dht/routing_table.py`)
- K-buckets → Node identity: keys peers (evidence: `zeromesh/dht/kbucket.py`)
- Kademlia lookup → Node identity: orders candidates (evidence: `zeromesh/dht/lookup.py`)
- TCP server → Peer connection: accepts connections (evidence: `zeromesh/network/server.py`)
- Peer connection → Wire protocol: encodes and decodes (evidence: `zeromesh/network/connection.py`)
- ZeroMesh node → Other peers: exchanges RPCs (evidence: `README.md`)
- Prometheus metrics → User: exposes scrape endpoint (evidence: `README.md`)
