How p-types/raft-consensus-distributed-systems-simulator works
This repository is a Raft consensus simulator that grows from an in-memory algorithm demonstration into a networked cluster with persistence, HTTP controls, and a live dashboard. Its main user workflow is to run nodes, submit commands to a leader, and observe replicated state; operators can also simulate partitions and heal links. The Python phases are separate educational simulations, while the Go phase provides the networked runtime. The dashboard and some documented capabilities are represented from README/tree evidence; unsampled wiring is not asserted.
Main entry points: main.go Node Process · node.go Raft Node State · command_endpoint.go Command Endpoints · replication.go Log Replication
Components 16
Python Simulations
- Core Node State
phase1_state/raft_node.py - Election Simulation
phase2_election/cluster.py - Election Node Logic
phase2_election/raft_node.py - Replication Simulation
phase3_replication/cluster.py - Replication Node Logic
phase3_replication/raft_node.py
Networked Raft
- Node Process
phase4_networking/cmd/node/main.go - Raft Node State
phase4_networking/raft/node.go - Network Elections
phase4_networking/raft/election.go - Log Replication
phase4_networking/raft/replication.go - Durable State
phase4_networking/raft/persist.go - Peer RPC
phase4_networking/raft/rpc.go
Cluster Controls
- Status Endpoint
phase4_networking/raft/status_endpoint.go - Command Endpoints
phase4_networking/raft/command_endpoint.go
Dashboard
- Live Dashboard
dashboard/index.html
Other components
- Client / Operator
- Raft Peers
Connections 16
- Election Simulation → Election Node Logic: uses node logic
phase2_election/cluster.py - Replication Simulation → Replication Node Logic: uses node logic
phase3_replication/cluster.py - Node Process → Raft Node State: starts server
phase4_networking/cmd/node/main.go - Node Process → Status Endpoint: registers endpoint
phase4_networking/cmd/node/main.go - Node Process → Command Endpoints: registers endpoints
phase4_networking/cmd/node/main.go - Node Process → Network Elections: runs election
phase4_networking/cmd/node/main.go - Node Process → Raft Node State: constructs node
phase4_networking/cmd/node/main.go - Raft Node State → Durable State: loads saved state
phase4_networking/raft/node.go - Command Endpoints → Raft Node State: proposes command
phase4_networking/raft/command_endpoint.go - Command Endpoints → Raft Node State: blocks or heals peer
phase4_networking/raft/command_endpoint.go - Log Replication → Peer RPC: sends AppendEntries
phase4_networking/raft/replication.go - Log Replication → Durable State: persists proposal
phase4_networking/raft/replication.go - Raft Peers → Peer RPC: exchange RPCs
- Client / Operator → Command Endpoints: submits commands
phase4_networking/raft/command_endpoint.go - Client / Operator → Live Dashboard: views cluster
README.md - Live Dashboard → Status Endpoint: polls status
README.md