# sairajeshramaraju/distributed-file-grid architecture

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

- Interactive diagram: https://gitdiagram.com/sairajeshramaraju/distributed-file-grid
- Repository: https://github.com/sairajeshramaraju/distributed-file-grid

## Overview

Distributed File Grid is a replicated, chunk-based file-storage system. Applications use the client to upload, download, and list files through the Head Server, which coordinates metadata and storage-node transfers; downloads verify replica hashes and support consensus/read-repair. Separate services handle cluster membership, health telemetry, and ZooKeeper coordination. The graph also preserves the documented metrics and dashboard capabilities. Edges are limited to relationships stated in the README or visible in supplied excerpts; several implementation details were not sampled.

Main entry points: [`src/head_server/head_server.cpp`](https://github.com/sairajeshramaraju/distributed-file-grid/blob/main/src/head_server/head_server.cpp) (Head Server), [`src/cluster_server/cluster_server.cpp`](https://github.com/sairajeshramaraju/distributed-file-grid/blob/main/src/cluster_server/cluster_server.cpp) (Cluster Server), [`src/health_checker/health_checker.cpp`](https://github.com/sairajeshramaraju/distributed-file-grid/blob/main/src/health_checker/health_checker.cpp) (Health Checker), [`src/client/client.cpp`](https://github.com/sairajeshramaraju/distributed-file-grid/blob/main/src/client/client.cpp) (Client CLI)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_file_flow["File Operations"]
  node_client["Client CLI<br/>[client.cpp]"]
  node_head["Head Server<br/>[head_server.cpp]"]
  node_upload["Upload Handling<br/>[file_upload.cpp]"]
  node_metadata[("Metadata Store<br/>[redis_handler.hpp]")]
  node_redis[("Redis")]
  node_transfer_proto["Transfer Protocol"]
end

subgraph group_cluster["Cluster Services"]
  node_control["Control API<br/>[control_api.hpp]"]
  node_storage["Chunk Storage<br/>[chunk_service.cpp]"]
  node_cluster_daemon["Cluster Server<br/>[cluster_server.cpp]"]
  node_registry["Server Registry"]
  node_health_monitor["Health Monitor<br/>[health_monitor.hpp]"]
  node_health_checker["Health Checker<br/>[health_checker.cpp]"]
  node_heartbeat_proto["Heartbeat Protocol<br/>[heartbeat.proto]"]
end

subgraph group_coordination["Coordination"]
  node_zk_monitor["ZooKeeper Monitor<br/>[zk_monitor.cpp]"]
  node_zk_client["ZooKeeper Client"]
  node_zookeeper[("ZooKeeper Ensemble")]
end

subgraph group_observability["Observability"]
  node_head_metrics["Head Metrics<br/>[metrics.hpp]"]
  node_cluster_metrics["Cluster Metrics"]
  node_dashboards["Grafana Dashboards<br/>[dfg_overview.json]"]
  node_prometheus["Prometheus"]
end

subgraph group_shared["Shared Runtime"]
  node_sha["SHA-256<br/>[sha256.hpp]"]
  node_system_info["System Metrics<br/>[system_info.hpp]"]
  node_async_net["Async Networking<br/>[async_net.hpp]"]
end

node_applications(("User Applications"))

node_applications -->|"invokes"| node_client
node_client -->|"streams operations"| node_head
node_head -->|"handles uploads"| node_upload
node_upload -.->|"records placement"| node_metadata
node_head -.->|"reads metadata"| node_metadata
node_head -->|"transfers chunks"| node_cluster_daemon
node_cluster_daemon -->|"serves chunks"| node_storage
node_client -->|"verifies chunks"| node_sha
node_storage -->|"computes digests"| node_sha
node_head -->|"exposes management"| node_control
node_control -->|"registers servers"| node_registry
node_control -->|"registers health"| node_health_monitor
node_cluster_daemon -->|"sends heartbeats"| node_health_checker
node_health_checker -->|"checks membership"| node_zk_client
node_zk_monitor -.->|"coordinates election"| node_zk_client
node_zk_client -->|"coordinates"| node_zookeeper
node_cluster_daemon -->|"samples metrics"| node_system_info
node_health_checker -->|"reads metrics"| node_system_info
node_head -->|"exports metrics"| node_head_metrics
node_cluster_daemon -->|"exports metrics"| node_cluster_metrics
node_health_checker -->|"exports metrics"| node_prometheus
node_prometheus -->|"feeds dashboards"| node_dashboards
node_metadata -.->|"persists optionally"| node_redis
node_transfer_proto -.->|"defines transfers"| node_head
node_heartbeat_proto -.->|"defines telemetry"| node_health_checker
node_cluster_daemon -.->|"uses networking"| node_async_net

click node_client "https://github.com/sairajeshramaraju/distributed-file-grid/blob/main/src/client/client.cpp"
click node_head "https://github.com/sairajeshramaraju/distributed-file-grid/blob/main/src/head_server/head_server.cpp"
click node_upload "https://github.com/sairajeshramaraju/distributed-file-grid/blob/main/src/head_server/file_upload.cpp"
click node_metadata "https://github.com/sairajeshramaraju/distributed-file-grid/blob/main/src/head_server/redis_handler.hpp"
click node_control "https://github.com/sairajeshramaraju/distributed-file-grid/blob/main/src/head_server/control_api.hpp"
click node_storage "https://github.com/sairajeshramaraju/distributed-file-grid/blob/main/src/cluster_server/chunk_service.cpp"
click node_cluster_daemon "https://github.com/sairajeshramaraju/distributed-file-grid/blob/main/src/cluster_server/cluster_server.cpp"
click node_registry "https://github.com/sairajeshramaraju/distributed-file-grid/blob/main/src/common/include/dfg/server_registry.hpp"
click node_health_monitor "https://github.com/sairajeshramaraju/distributed-file-grid/blob/main/src/common/include/dfg/health_monitor.hpp"
click node_health_checker "https://github.com/sairajeshramaraju/distributed-file-grid/blob/main/src/health_checker/health_checker.cpp"
click node_zk_monitor "https://github.com/sairajeshramaraju/distributed-file-grid/blob/main/src/zk_monitor/zk_monitor.cpp"
click node_zk_client "https://github.com/sairajeshramaraju/distributed-file-grid/blob/main/src/common/src/zookeeper_client.cpp"
click node_sha "https://github.com/sairajeshramaraju/distributed-file-grid/blob/main/src/common/include/dfg/sha256.hpp"
click node_system_info "https://github.com/sairajeshramaraju/distributed-file-grid/blob/main/src/common/include/dfg/system_info.hpp"
click node_head_metrics "https://github.com/sairajeshramaraju/distributed-file-grid/blob/main/src/head_server/metrics.hpp"
click node_cluster_metrics "https://github.com/sairajeshramaraju/distributed-file-grid/blob/main/src/cluster_server/metrics_exporter.hpp"
click node_dashboards "https://github.com/sairajeshramaraju/distributed-file-grid/blob/main/deploy/docker/dashboards/dfg_overview.json"
click node_async_net "https://github.com/sairajeshramaraju/distributed-file-grid/blob/main/src/common/include/dfg/async_net.hpp"
click node_transfer_proto "https://github.com/sairajeshramaraju/distributed-file-grid/blob/main/src/proto/v1/file_transfer.proto"
click node_heartbeat_proto "https://github.com/sairajeshramaraju/distributed-file-grid/blob/main/src/proto/v1/heartbeat.proto"

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,node_head,node_upload,node_metadata,node_redis,node_transfer_proto,node_applications toneBlue
class node_control,node_storage,node_cluster_daemon,node_registry,node_health_monitor,node_health_checker,node_heartbeat_proto toneAmber
class node_zk_monitor,node_zk_client,node_zookeeper toneMint
class node_head_metrics,node_cluster_metrics,node_dashboards,node_prometheus toneRose
class node_sha,node_system_info,node_async_net toneIndigo
```

## Components

### File Operations

- [Client CLI](https://github.com/sairajeshramaraju/distributed-file-grid/blob/main/src/client/client.cpp): `src/client/client.cpp`
- [Head Server](https://github.com/sairajeshramaraju/distributed-file-grid/blob/main/src/head_server/head_server.cpp): `src/head_server/head_server.cpp`
- [Upload Handling](https://github.com/sairajeshramaraju/distributed-file-grid/blob/main/src/head_server/file_upload.cpp): `src/head_server/file_upload.cpp`
- [Metadata Store](https://github.com/sairajeshramaraju/distributed-file-grid/blob/main/src/head_server/redis_handler.hpp): `src/head_server/redis_handler.hpp`
- **Redis**
- [Transfer Protocol](https://github.com/sairajeshramaraju/distributed-file-grid/blob/main/src/proto/v1/file_transfer.proto): `src/proto/v1/file_transfer.proto`

### Cluster Services

- [Control API](https://github.com/sairajeshramaraju/distributed-file-grid/blob/main/src/head_server/control_api.hpp): `src/head_server/control_api.hpp`
- [Chunk Storage](https://github.com/sairajeshramaraju/distributed-file-grid/blob/main/src/cluster_server/chunk_service.cpp): `src/cluster_server/chunk_service.cpp`
- [Cluster Server](https://github.com/sairajeshramaraju/distributed-file-grid/blob/main/src/cluster_server/cluster_server.cpp): `src/cluster_server/cluster_server.cpp`
- [Server Registry](https://github.com/sairajeshramaraju/distributed-file-grid/blob/main/src/common/include/dfg/server_registry.hpp): `src/common/include/dfg/server_registry.hpp`
- [Health Monitor](https://github.com/sairajeshramaraju/distributed-file-grid/blob/main/src/common/include/dfg/health_monitor.hpp): `src/common/include/dfg/health_monitor.hpp`
- [Health Checker](https://github.com/sairajeshramaraju/distributed-file-grid/blob/main/src/health_checker/health_checker.cpp): `src/health_checker/health_checker.cpp`
- [Heartbeat Protocol](https://github.com/sairajeshramaraju/distributed-file-grid/blob/main/src/proto/v1/heartbeat.proto): `src/proto/v1/heartbeat.proto`

### Coordination

- [ZooKeeper Monitor](https://github.com/sairajeshramaraju/distributed-file-grid/blob/main/src/zk_monitor/zk_monitor.cpp): `src/zk_monitor/zk_monitor.cpp`
- [ZooKeeper Client](https://github.com/sairajeshramaraju/distributed-file-grid/blob/main/src/common/src/zookeeper_client.cpp): `src/common/src/zookeeper_client.cpp`
- **ZooKeeper Ensemble**

### Observability

- [Head Metrics](https://github.com/sairajeshramaraju/distributed-file-grid/blob/main/src/head_server/metrics.hpp): `src/head_server/metrics.hpp`
- [Cluster Metrics](https://github.com/sairajeshramaraju/distributed-file-grid/blob/main/src/cluster_server/metrics_exporter.hpp): `src/cluster_server/metrics_exporter.hpp`
- [Grafana Dashboards](https://github.com/sairajeshramaraju/distributed-file-grid/blob/main/deploy/docker/dashboards/dfg_overview.json): `deploy/docker/dashboards/dfg_overview.json`
- **Prometheus**

### Shared Runtime

- [SHA-256](https://github.com/sairajeshramaraju/distributed-file-grid/blob/main/src/common/include/dfg/sha256.hpp): `src/common/include/dfg/sha256.hpp`
- [System Metrics](https://github.com/sairajeshramaraju/distributed-file-grid/blob/main/src/common/include/dfg/system_info.hpp): `src/common/include/dfg/system_info.hpp`
- [Async Networking](https://github.com/sairajeshramaraju/distributed-file-grid/blob/main/src/common/include/dfg/async_net.hpp): `src/common/include/dfg/async_net.hpp`

### Other components

- **User Applications**

## Connections

- User Applications → Client CLI: invokes (evidence: `README.md`)
- Client CLI → Head Server: streams operations (evidence: `README.md`)
- Head Server → Upload Handling: handles uploads (evidence: `README.md`)
- Upload Handling → Metadata Store: records placement (evidence: `src/head_server/file_upload.cpp`)
- Head Server → Metadata Store: reads metadata (evidence: `src/head_server/head_server.cpp`)
- Head Server → Cluster Server: transfers chunks (evidence: `README.md`)
- Cluster Server → Chunk Storage: serves chunks (evidence: `README.md`)
- Client CLI → SHA-256: verifies chunks (evidence: `src/client/client.cpp`)
- Chunk Storage → SHA-256: computes digests (evidence: `src/cluster_server/chunk_service.cpp`)
- Head Server → Control API: exposes management (evidence: `README.md`)
- Control API → Server Registry: registers servers (evidence: `src/head_server/control_api.hpp`)
- Control API → Health Monitor: registers health (evidence: `src/head_server/control_api.hpp`)
- Cluster Server → Health Checker: sends heartbeats (evidence: `README.md`)
- Health Checker → ZooKeeper Client: checks membership (evidence: `src/health_checker/health_checker.cpp`)
- ZooKeeper Monitor → ZooKeeper Client: coordinates election
- ZooKeeper Client → ZooKeeper Ensemble: coordinates (evidence: `README.md`)
- Cluster Server → System Metrics: samples metrics
- Health Checker → System Metrics: reads metrics (evidence: `src/health_checker/health_checker.cpp`)
- Head Server → Head Metrics: exports metrics (evidence: `README.md`)
- Cluster Server → Cluster Metrics: exports metrics (evidence: `README.md`)
- Health Checker → Prometheus: exports metrics (evidence: `README.md`)
- Prometheus → Grafana Dashboards: feeds dashboards (evidence: `README.md`)
- Metadata Store → Redis: persists optionally (evidence: `README.md`)
- Transfer Protocol → Head Server: defines transfers
- Heartbeat Protocol → Health Checker: defines telemetry
- Cluster Server → Async Networking: uses networking
