# Raft Deep Dive

A detailed look at the Raft consensus algorithm.

## How Raft Works

Raft uses a leader-follower model where one node is elected as the leader and all other nodes are followers.

## Key Components

1. Leader Election
2. Log Replication
3. Safety

## Election Process

When a follower doesn't hear from the leader for a timeout period, it increments its term and starts an election.

```mermaid
graph TD
    A[Follower] --timeout--> B[Candidate]
    B --votes received--> C[Leader]
    C --heartbeat--> A
```

## State Machine

The state machine applies committed log entries to produce the same output on all nodes.
