# vishalk91-4/syncinator architecture

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

- Interactive diagram: https://gitdiagram.com/vishalk91-4/syncinator
- Repository: https://github.com/vishalk91-4/syncinator

## Overview

#### Purpose and entry points
Syncinator is a Go, gRPC-based distributed file synchronization system. Clients mirror a local base directory with remote metadata and content services. Executables are:
- Client sync process: `cmd/SyncinatorClientExec/main.go`
- Block data server: `cmd/SyncinatorServerExec/main.go`
- RAFT-backed metadata server: `cmd/SyncinatorRaftServerExec/main.go`
- Block-placement inspection utility: `cmd/SyncinatorPrintBlockMapping/main.go`

#### RPC contract and process boundary
The shared service contract is defined in `pkg/syncinator/Syncinator.proto`, with generated Go/gRPC bindings in `pkg/syncinator/Syncinator_grpc.pb.go`. Client and server processes communicate exclusively through gRPC; local filesystem state and remote service state are separate ownership domains.

#### Client synchronization engine
`pkg/syncinator/Syncinator.go` implements synchronization around local directory scanning, block hashing, `index.db`-backed state, remote metadata retrieval, and upload/download decisions. `pkg/syncinator/SyncinatorRPCClient.go` is the client-side RPC adapter, while `pkg/syncinator/SyncinatorInterfaces.go` defines the key abstractions. The core merge boundary is the three-view comparison of local disk/index state, previously synced state, and current remote metadata.

#### Content plane: BlockStore
`pkg/syncinator/BlockStore.go` owns content-addressed file blocks. Files are divided into fixed-size blocks and addressed by SHA-256 hashes; metadata refers to block hashes rather than embedding file data. This allows deduplication and separates large payload transfer from metadata consensus.

#### Metadata plane and block placement
`pkg/syncinator/MetaStore.go` maintains filename versions, file hash lists, and BlockStore membership/mappings. `pkg/syncinator/ConsistentHashRing.go` maps each block hash to a BlockStore endpoint using a SHA-256 consistent-hash ring. Metadata operations determine where clients upload or retrieve each block; BlockStores do not independently coordinate file versions.

#### Replicated metadata consensus
`pkg/syncinator/RaftSyncinatorServer.go` wraps metadata mutation in RAFT replication so MetaStore replicas converge and tolerate node failures. Consensus interfaces and protocol constants are concentrated in `pkg/syncinator/RaftInterfaces.go` and `pkg/syncinator/RaftConstants.go`. This is the authoritative write-control boundary: conflicting or stale metadata updates are resolved by the replicated service rather than clients.

#### Primary flow and infrastructure
A client scans its base directory, computes block hash lists, compares local/index state against remote metadata, then:
1. obtains current metadata and block placement from MetaStore;
2. uploads missing blocks to mapped BlockStores;
3. submits versioned metadata updates through the RAFT-backed MetaStore; or
4. downloads remotely newer blocks and reconstructs files locally.

Runtime topology is supplied by JSON endpoint configuration, principally `config.json`; shell launchers (`run_syncinator.sh`, `run_block_server.sh`, `run_meta_server.sh`) start the three process roles. Material dependencies are Go, gRPC/protobuf, SHA-256 hashing, local filesystem/index persistence, and a multi-node RAFT network.

Main entry points: [`pkg/syncinator/Syncinator.go`](https://github.com/vishalk91-4/syncinator/blob/main/pkg/syncinator/Syncinator.go) (Synchronization engine), [`pkg/syncinator/BlockStore.go`](https://github.com/vishalk91-4/syncinator/blob/main/pkg/syncinator/BlockStore.go) (BlockStore), [`config.json`](https://github.com/vishalk91-4/syncinator/blob/main/config.json) (Endpoint configuration), [`pkg/syncinator/Syncinator.proto`](https://github.com/vishalk91-4/syncinator/blob/main/pkg/syncinator/Syncinator.proto) (Syncinator gRPC contract)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Client sync runtime"]
  node_client_exec["Client executable<br/>Go process<br/>[main.go]"]
  node_sync_engine["Synchronization engine<br/>sync coordinator<br/>[Syncinator.go]"]
  node_local_disk[("Local base directory<br/>filesystem")]
  node_sync_index[("index.db state<br/>local index")]
  node_merge{{"Three-view merge<br/>comparison boundary<br/>[Syncinator.go]"}}
  node_rpc_client["RPC client adapter<br/>gRPC client"]
end

subgraph group_metadata["Metadata consensus plane"]
  node_raft_exec["RAFT metadata executable<br/>Go process<br/>[main.go]"]
  node_raft_server["RAFT metadata server<br/>replicated write control"]
  node_metastore[("MetaStore<br/>metadata authority<br/>[MetaStore.go]")]
  node_hash_ring{{"Consistent hash ring<br/>block placement"}}
end

subgraph group_content["Content plane"]
  node_block_exec["Block server executable<br/>Go process<br/>[main.go]"]
  node_blockstore[("BlockStore<br/>content-addressed storage<br/>[BlockStore.go]")]
end

node_rpc_contract["Syncinator gRPC contract<br/>protobuf API<br/>[Syncinator.proto]"]
node_placement_tool["Block mapping inspector<br/>Go utility<br/>[main.go]"]
node_runtime_config["Endpoint configuration<br/>JSON configuration<br/>[config.json]"]

node_client_exec -->|"runs"| node_sync_engine
node_sync_engine -->|"scans and reconstructs"| node_local_disk
node_sync_engine -->|"reads/writes sync state"| node_sync_index
node_sync_engine -->|"evaluates changes"| node_merge
node_merge -->|"requests metadata or transfer"| node_rpc_client
node_rpc_client -->|"uses"| node_rpc_contract
node_rpc_contract -->|"metadata RPCs"| node_raft_server
node_rpc_contract -->|"block RPCs"| node_blockstore
node_raft_exec -->|"runs"| node_raft_server
node_raft_server -->|"replicates mutations to"| node_metastore
node_metastore -->|"uses placement mapping"| node_hash_ring
node_hash_ring -->|"selects endpoint"| node_blockstore
node_block_exec -->|"runs"| node_blockstore
node_sync_engine -->|"uploads/downloads hashed blocks"| node_blockstore
node_placement_tool -->|"inspects mappings"| node_metastore
node_runtime_config -.->|"configures endpoints"| node_client_exec
node_runtime_config -.->|"configures topology"| node_raft_exec
node_runtime_config -.->|"configures endpoint"| node_block_exec

click node_client_exec "https://github.com/vishalk91-4/syncinator/blob/main/cmd/SyncinatorClientExec/main.go"
click node_sync_engine "https://github.com/vishalk91-4/syncinator/blob/main/pkg/syncinator/Syncinator.go"
click node_merge "https://github.com/vishalk91-4/syncinator/blob/main/pkg/syncinator/Syncinator.go"
click node_rpc_client "https://github.com/vishalk91-4/syncinator/blob/main/pkg/syncinator/SyncinatorRPCClient.go"
click node_rpc_contract "https://github.com/vishalk91-4/syncinator/blob/main/pkg/syncinator/Syncinator.proto"
click node_raft_exec "https://github.com/vishalk91-4/syncinator/blob/main/cmd/SyncinatorRaftServerExec/main.go"
click node_raft_server "https://github.com/vishalk91-4/syncinator/blob/main/pkg/syncinator/RaftSyncinatorServer.go"
click node_metastore "https://github.com/vishalk91-4/syncinator/blob/main/pkg/syncinator/MetaStore.go"
click node_hash_ring "https://github.com/vishalk91-4/syncinator/blob/main/pkg/syncinator/ConsistentHashRing.go"
click node_block_exec "https://github.com/vishalk91-4/syncinator/blob/main/cmd/SyncinatorServerExec/main.go"
click node_blockstore "https://github.com/vishalk91-4/syncinator/blob/main/pkg/syncinator/BlockStore.go"
click node_placement_tool "https://github.com/vishalk91-4/syncinator/blob/main/cmd/SyncinatorPrintBlockMapping/main.go"
click node_runtime_config "https://github.com/vishalk91-4/syncinator/blob/main/config.json"

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_client_exec,node_sync_engine,node_local_disk,node_sync_index,node_merge,node_rpc_client toneBlue
class node_raft_exec,node_raft_server,node_metastore,node_hash_ring toneAmber
class node_block_exec,node_blockstore toneMint
class node_rpc_contract,node_placement_tool,node_runtime_config toneNeutral
```

## Components

### Client sync runtime

- [Client executable](https://github.com/vishalk91-4/syncinator/blob/main/cmd/SyncinatorClientExec/main.go): Go process · `cmd/SyncinatorClientExec/main.go`
- [Synchronization engine](https://github.com/vishalk91-4/syncinator/blob/main/pkg/syncinator/Syncinator.go): sync coordinator · Performs scan, comparison, and transfer decisions. · `pkg/syncinator/Syncinator.go`
- **Local base directory**: filesystem
- **index.db state**: local index · Tracks prior synchronized state.
- [Three-view merge](https://github.com/vishalk91-4/syncinator/blob/main/pkg/syncinator/Syncinator.go): comparison boundary · Compares disk/index state, prior sync state, and remote metadata. · `pkg/syncinator/Syncinator.go`
- [RPC client adapter](https://github.com/vishalk91-4/syncinator/blob/main/pkg/syncinator/SyncinatorRPCClient.go): gRPC client · `pkg/syncinator/SyncinatorRPCClient.go`

### Metadata consensus plane

- [RAFT metadata executable](https://github.com/vishalk91-4/syncinator/blob/main/cmd/SyncinatorRaftServerExec/main.go): Go process · `cmd/SyncinatorRaftServerExec/main.go`
- [RAFT metadata server](https://github.com/vishalk91-4/syncinator/blob/main/pkg/syncinator/RaftSyncinatorServer.go): replicated write control · Replicates metadata mutations across a RAFT network. · `pkg/syncinator/RaftSyncinatorServer.go`
- [MetaStore](https://github.com/vishalk91-4/syncinator/blob/main/pkg/syncinator/MetaStore.go): metadata authority · Stores file versions, block hashes, and block mappings. · `pkg/syncinator/MetaStore.go`
- [Consistent hash ring](https://github.com/vishalk91-4/syncinator/blob/main/pkg/syncinator/ConsistentHashRing.go): block placement · Maps block hashes to BlockStore endpoints. · `pkg/syncinator/ConsistentHashRing.go`

### Content plane

- [Block server executable](https://github.com/vishalk91-4/syncinator/blob/main/cmd/SyncinatorServerExec/main.go): Go process · `cmd/SyncinatorServerExec/main.go`
- [BlockStore](https://github.com/vishalk91-4/syncinator/blob/main/pkg/syncinator/BlockStore.go): content-addressed storage · Stores fixed-size SHA-256-addressed file blocks. · `pkg/syncinator/BlockStore.go`

### Other components

- [Syncinator gRPC contract](https://github.com/vishalk91-4/syncinator/blob/main/pkg/syncinator/Syncinator.proto): protobuf API · `pkg/syncinator/Syncinator.proto`
- [Block mapping inspector](https://github.com/vishalk91-4/syncinator/blob/main/cmd/SyncinatorPrintBlockMapping/main.go): Go utility · `cmd/SyncinatorPrintBlockMapping/main.go`
- [Endpoint configuration](https://github.com/vishalk91-4/syncinator/blob/main/config.json): JSON configuration · Supplies runtime service topology. · `config.json`

## Connections

- Client executable → Synchronization engine: runs
- Synchronization engine → Local base directory: scans and reconstructs
- Synchronization engine → index.db state: reads/writes sync state
- Synchronization engine → Three-view merge: evaluates changes
- Three-view merge → RPC client adapter: requests metadata or transfer
- RPC client adapter → Syncinator gRPC contract: uses
- Syncinator gRPC contract → RAFT metadata server: metadata RPCs
- Syncinator gRPC contract → BlockStore: block RPCs
- RAFT metadata executable → RAFT metadata server: runs
- RAFT metadata server → MetaStore: replicates mutations to
- MetaStore → Consistent hash ring: uses placement mapping
- Consistent hash ring → BlockStore: selects endpoint
- Block server executable → BlockStore: runs
- Synchronization engine → BlockStore: uploads/downloads hashed blocks
- Block mapping inspector → MetaStore: inspects mappings
- Endpoint configuration → Client executable: configures endpoints
- Endpoint configuration → RAFT metadata executable: configures topology
- Endpoint configuration → Block server executable: configures endpoint
