Skip to content

SamridhiShreyaa/Mini-RAFT

Repository files navigation

Mini-RAFT Distributed Drawing Board

A powerful distributed systems project simulating cloud-native consensus models using a miniature version of the RAFT protocol. Multiple backend replicas maintain an identical event log of drawing strokes without relying on a central database, ensuring zero downtime even when containers crash.

RAFT Theory Overview

  • Leader Election: All nodes start as Followers. If they haven't heard from a Leader before a randomized timer expires, they become a Candidate and request votes. The first to achieve a majority becomes the Leader.
  • Log Replication: The Leader is the only node trusted to accept client data. It appends the data (drawing strokes) to an immutable log and blasts it to Followers. Once a majority acknowledge, the state is committed.
  • Fault Tolerance: If a node fails, it restarts and attempts to re-sync. If the Leader fails, followers notice the lack of heartbeats and securely elect a new one without disrupting data persistence.

Architecture Overview

graph TD
    UI[HTML Canvas UI] -->|WebSocket| G(Gateway Proxy)
    G -->|POST /submit-stroke| L[Leader Node: 3001]
    L -.->|RPC /append-entries| F1[Follower Node: 3002]
    L -.->|RPC /append-entries| F2[Follower Node: 3003]
    L -.->|RPC /append-entries| F3[Follower Node: 3004]
Loading

Setup & Instructions

Backend Start

  1. Ensure Docker Desktop is running.
  2. At the root of the project, run:
docker-compose up --build

This boots the Gateway (Port 3000) and your Replica Nodes (3001+).

Frontend Start

  1. In a separate terminal, navigate into the frontend folder:
cd frontend
npm install
npm run serve
  1. Open http://localhost:8080 in multiple browser tabs to simulate clients.

Assumptions & Constraints

  • All system instances run over http inside local Docker bridges. Network latencies are artificially mimicked.
  • Logs are held in memory on the replicas and are not persisted entirely to physical disk arrays between total cluster teardowns (docker-compose down).

MiniRAFT Project Checklist

  • Leader election
  • WebSocket Gateway
  • Basic log replication
  • Drawing canvas integration
  • Graceful reload
  • Blue-green replica replacement
  • Failover correctness
  • Multi-client real-time sync
  • Demo under chaotic conditions

Bonus Options:

  • Network partitions (simulate split brain)
  • Add 4th replica
  • Add vector-based undo/redo using log compensation
  • Implement a dashboard showing leader, term, log sizes
  • Deploy to a real cloud VM (e.g., Amazon Web Services (AWS) EC2 or Google Cloud)

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors