Interactive 3D Blockchain Consensus Mechanism Visualizer
Live Demo · Report Bug · Request Feature
Learn how Bitcoin, Ethereum, and enterprise blockchains achieve consensus through beautiful real-time 3D simulations
- About
- Demo
- Features
- Architecture
- Tech Stack
- Getting Started
- Project Structure
- Consensus Mechanisms
- Performance
- Roadmap
- Contributing
- License
- Contact
Consensus Lab is an educational visualization tool that brings blockchain consensus mechanisms to life through interactive 3D simulations. Instead of reading abstract descriptions, users can watch and understand how different networks achieve agreement in real-time.
- 📖 Educational Gap: Most blockchain education relies on text and static diagrams
- 🎮 Interactive Learning: See consensus happen in real-time with visual feedback
- 🔬 Technical Accuracy: Based on actual protocol specifications (Bitcoin Whitepaper, Ethereum Yellow Paper, RAFT Paper)
- 🌐 Accessible: Works on any modern browser with WebGL support
| Proof of Work (Bitcoin) | Proof of Stake (Ethereum) |
|---|---|
![]() |
![]() |
| Mining race across regions, fork resolution, orphan blocks | Validator selection, attestations, finality |
| RAFT (Hyperledger Fabric) | IBFT 2.0 (Hyperledger Besu) |
|---|---|
![]() |
![]() |
| Leader election, log replication, instant commit | 3-phase BFT consensus, Byzantine tolerance |
| Mechanism | Network | Fault Tolerance | Finality |
|---|---|---|---|
| Proof of Work | Bitcoin | 51% attack resistant | ~60 min (6 blocks) |
| Proof of Stake | Ethereum | 34% stake attack | ~13 min (2 epochs) |
| RAFT | Hyperledger Fabric | CFT (N-1)/2 crashes | Instant |
| IBFT 2.0 | Hyperledger Besu | BFT 33% Byzantine | Instant |
- 3D WebGL Graphics - Immersive visualization with Three.js
- Real-time Simulation - Watch consensus unfold step-by-step
- Audio Feedback - Sound effects for mining, voting, finalization
- Bilingual Support - English and Korean (한국어)
- Responsive Design - Desktop and mobile compatible
- Block propagation and fork resolution
- Validator/miner stake and rewards
- Network statistics (TPS, finality time, costs)
- Economic incentives and slashing conditions
┌─────────────────────────────────────────────────────────────┐
│ Next.js App │
├─────────────────────────────────────────────────────────────┤
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────────────┐ │
│ │ UI Layer │ │ 3D Canvas │ │ State Management │ │
│ │ (React + │ │ (R3F + │ │ (useReducer + │ │
│ │ Framer) │ │ Three.js) │ │ Custom Hooks) │ │
│ └─────────────┘ └─────────────┘ └─────────────────────┘ │
├─────────────────────────────────────────────────────────────┤
│ ┌─────────────────────────────────────────────────────┐ │
│ │ Simulation Hooks Layer │ │
│ │ ┌──────────┐ ┌──────────┐ ┌────────┐ ┌──────────┐ │ │
│ │ │usePoW │ │usePoS │ │useRaft │ │useQbft │ │ │
│ │ │Simulation│ │Simulation│ │Sim │ │Simulation│ │ │
│ │ └──────────┘ └──────────┘ └────────┘ └──────────┘ │ │
│ └─────────────────────────────────────────────────────┘ │
├─────────────────────────────────────────────────────────────┤
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────────────┐ │
│ │ Types │ │ Constants │ │ i18n (en/ko) │ │
│ │ (TS) │ │ (Config) │ │ (Translations) │ │
│ └─────────────┘ └─────────────┘ └─────────────────────┘ │
└─────────────────────────────────────────────────────────────┘
| Decision | Rationale |
|---|---|
| useReducer over Redux | Simpler state management for component-scoped simulation state |
| Custom Hooks per Consensus | Encapsulated simulation logic, easy to test and extend |
| React.memo + useMemo | Prevent unnecessary re-renders in 60fps 3D environment |
| Dynamic Imports | Code-split 3D components to reduce initial bundle |
| Strict Mode Disabled | Prevent WebGL context issues from double mounting |
| Technology | Purpose | Version |
|---|---|---|
| Next.js | React Framework | 16.1.0 |
| React | UI Library | 19.2.3 |
| TypeScript | Type Safety | 5.x |
| Tailwind CSS | Styling | 4.x |
| Technology | Purpose | Version |
|---|---|---|
| Three.js | 3D Engine | 0.182.0 |
| React Three Fiber | React Renderer | 9.4.2 |
| @react-three/drei | Helpers | 10.3.1 |
| @react-three/postprocessing | Effects | 3.1.1 |
| Technology | Purpose |
|---|---|
| Framer Motion | UI Animations |
| Web Audio API | Sound Effects |
- Node.js 18.x or higher
- npm, yarn, or pnpm
# Clone the repository
git clone https://github.com/nara020/consensus-lab.git
cd consensus-lab
# Install dependencies
npm install
# Start development server
npm run devOpen http://localhost:3000 in your browser.
# Create optimized build
npm run build
# Start production server
npm startNo environment variables required for basic usage.
consensus-lab/
├── src/
│ ├── app/ # Next.js App Router
│ │ ├── layout.tsx # Root layout with providers
│ │ ├── page.tsx # Main entry point
│ │ └── globals.css # Global styles
│ │
│ ├── components/
│ │ ├── ConsensusVisualization.tsx # Main orchestrator
│ │ ├── ui/ # UI components
│ │ │ ├── ModeSelector.tsx
│ │ │ ├── InfoPanel.tsx
│ │ │ ├── StartButton.tsx
│ │ │ ├── ReplayButton.tsx
│ │ │ ├── StepIndicator.tsx
│ │ │ └── LanguageToggle.tsx
│ │ ├── visualization/ # 3D components
│ │ │ ├── Block.tsx
│ │ │ ├── Node.tsx
│ │ │ ├── ChainLine.tsx
│ │ │ ├── TransactionParticle.tsx
│ │ │ ├── Effects.tsx
│ │ │ └── scenes/ # Consensus-specific scenes
│ │ │ ├── PoWScene.tsx
│ │ │ ├── PoSScene.tsx
│ │ │ ├── RaftScene.tsx
│ │ │ └── QbftScene.tsx
│ │ └── providers/ # React providers
│ │
│ ├── hooks/ # Custom React hooks
│ │ ├── useAudio.ts # Sound effect management
│ │ ├── useSimulationState.ts # Centralized state
│ │ └── simulations/ # Consensus simulation logic
│ │ ├── usePoWSimulation.ts
│ │ ├── usePoSSimulation.ts
│ │ ├── useRaftSimulation.ts
│ │ └── useQbftSimulation.ts
│ │
│ ├── constants/ # Configuration
│ │ └── consensusInfo.ts # Consensus data & colors
│ │
│ ├── types/ # TypeScript definitions
│ │ └── consensus.ts # Core type definitions
│ │
│ └── i18n/ # Internationalization
│ ├── index.tsx # i18n provider & hook
│ ├── types.ts # Translation types
│ ├── en.ts # English translations
│ └── ko.ts # Korean translations
│
├── public/
│ ├── sounds/ # Audio files
│ └── screenshots/ # Demo images
│
├── .github/
│ └── workflows/ # CI/CD pipelines
│
└── package.json
Nakamoto Consensus - The original blockchain consensus mechanism.
Mining Process:
1. Collect transactions into a block
2. Find nonce where SHA256(block + nonce) < target
3. Broadcast block to network
4. Longest chain wins (most accumulated work)
Key Visualizations:
- Three mining pools (N.America, Europe, Asia) racing to find valid hash
- Network latency causing temporary forks
- Fork resolution: longest chain becomes main, others become orphaned
- Economic impact: orphaned miners lose ~$310K block reward
Security Model:
- 6 confirmations ≈ 0.02% reorg probability
- 51% attack requires majority hashpower
Casper FFG + LMD GHOST - Ethereum's hybrid consensus since The Merge.
Consensus Process:
1. Proposer selected based on stake (32 ETH minimum)
2. Block proposed for current slot (12 seconds)
3. Committee validators cast attestation votes
4. 2/3+ votes → Justified → Finalized (2 epochs)
Key Visualizations:
- Stake-proportional proposer selection
- Attestation votes flowing to blocks
- Justification and finalization status changes
- Slashing warnings for misbehavior
Security Model:
- Finality: ~13 minutes (2 epochs)
- Revert requires slashing 1/3 of stake (~$26B+)
CFT (Crash Fault Tolerant) - Designed for trusted private networks.
Consensus Process:
1. Transaction arrives at Leader
2. Leader appends to log
3. Leader replicates to Followers
4. Majority ACK (>50%) → Committed
Key Visualizations:
- Leader node with crown indicator
- Log replication lines to followers
- Replication count progress
- Instant finality on commit
Fault Tolerance:
- Can tolerate (N-1)/2 node crashes
- NOT Byzantine fault tolerant (assumes honest nodes)
- Heartbeat every 150ms
BFT (Byzantine Fault Tolerant) - Enterprise-grade consensus.
3-Phase Commit:
1. PRE-PREPARE: Proposer broadcasts block
2. PREPARE: Validators vote for agreement (2/3+)
3. COMMIT: Validators vote for finalization (2/3+)
Key Visualizations:
- Circular validator arrangement
- Vote lines showing PREPARE/COMMIT phases
- Quorum progress indicators
- Round-robin proposer rotation
Fault Tolerance:
- N ≥ 3f+1 validators required
- Tolerates up to 33% Byzantine (malicious) nodes
- Instant finality, no forks possible
| Metric | Score |
|---|---|
| Performance | 90+ |
| Accessibility | 95+ |
| Best Practices | 100 |
| SEO | 100 |
- Code Splitting: Dynamic imports for 3D components
- React.memo: Prevent unnecessary re-renders
- WebGL Context Management: Proper cleanup and error handling
- Font Optimization: System font stack with drei defaults
- Image Optimization: Next.js Image component
- Core visualization for 4 consensus mechanisms
- Bilingual support (EN/KO)
- Responsive design
- Audio feedback
- Add more consensus mechanisms (Tendermint, HotStuff)
- Interactive parameter adjustment
- Educational quiz mode
- VR/AR support
- Comparison mode (side-by-side)
See open issues for feature requests.
Contributions make the open-source community amazing! Any contributions are greatly appreciated.
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature) - Commit your Changes (
git commit -m 'Add some AmazingFeature') - Push to the Branch (
git push origin feature/AmazingFeature) - Open a Pull Request
- Follow existing code style (ESLint + Prettier)
- Write meaningful commit messages
- Update documentation for new features
- Add tests for critical functionality
Distributed under the MIT License. See LICENSE for more information.
Jinhyeok Kim




