/go-basic-blockchain

๐ŸŽฏ Built Completely From Scratch: This blockchain implementation uses no third-party blockchain libraries (no go-ethereum, Bitcoin, Tendermint/Cosmos, etc.) and includes our custom Helios consensus algorithm - all created from the ground up to fully teach Go programming and blockchain development.

Primary LanguageGoApache License 2.0Apache-2.0

go-basic-blockchain

Buy Me A Coffee

Educational Blockchain Implementation in Go with Advanced Consensus & Comprehensive Learning Course

Welcome to go-basic-blockchain, an educational project designed to demystify blockchain technology through a hands-on, from-scratch implementation in Go. This project serves as both a comprehensive learning tool and a fully functional blockchain implementation for developers, students, and blockchain enthusiasts.

๐ŸŽฏ Built Completely From Scratch: This blockchain implementation uses no third-party blockchain libraries (no go-ethereum, Bitcoin, Tendermint/Cosmos, etc.) and includes our custom Helios consensus algorithm - all created from the ground up to fully teach Go programming and blockchain development.

๐Ÿš€ NEW: Complete Learning Course - This project now includes a comprehensive 19-section course covering everything from Go fundamentals to production deployment!

๐ŸŽฏ NEW: Fully Functional Blockchain Node - Complete, operational blockchain with continuous mining, proper data persistence, and smooth progress monitoring.

๐Ÿ“š Learning Course

This repository includes a comprehensive learning course with 19 sections organized into 4 phases:

Course Structure

  • Phase 1: Foundation (Sections 1-5) - Go fundamentals and basic blockchain
  • Phase 2: Advanced Features (Sections 6-10) - Advanced consensus and APIs
  • Phase 3: User Experience (Sections 11-15) - Web and mobile applications
  • Phase 4: Production Quality (Sections 16-19) - Testing and deployment

What You'll Learn

  • Go Programming: Master Go fundamentals, concurrency, and advanced patterns
  • Blockchain Development: Build complete blockchain systems from scratch
  • Advanced Consensus: Implement sophisticated consensus algorithms (Helios)
  • API Development: Create professional RESTful APIs with authentication
  • Web Development: Build responsive web applications with React
  • Mobile Development: Create cross-platform mobile apps with React Native
  • Testing: Implement comprehensive testing strategies
  • Deployment: Deploy production-ready applications

Course Features

  • 80-109 hours of comprehensive content
  • 19 sections with hands-on exercises
  • 19 quizzes with detailed answer keys
  • 4 major milestones with working deliverables
  • Production-ready portfolio project

Start Learning โ†’ | Complete Course Overview โ†’


๐Ÿ”ง Blockchain Implementation

Key Features

  • Built from Scratch: Every component implemented from the ground up
  • Advanced Consensus: Implements the Helios consensus algorithm with three-stage validation
  • Go Programming Language: Utilizing Go's simplicity and efficiency for complex systems
  • Readable JSON Format: Human-readable JSON for data structures and storage
  • No Third-Party Dependencies: Encourages deep understanding of core blockchain concepts
  • Educational Focus: Thoroughly commented and documented with design explanations
  • Optimized Test Suite: Fast, reliable tests with smart scrypt configuration
  • Sidechain Routing: Advanced transaction routing through specialized protocols
  • Continuous Mining: Automatic block creation and mining with proper state management
  • Professional Build System: Organized binary output with cross-compilation support

Current Status

  • Test Coverage: 39.8%
  • Test Suite Performance: ~9.5 seconds (30x faster than before)
  • Implementation Status: ~95% complete
  • Helios Consensus: โœ… Fully integrated and tested
  • Blockchain Functionality: โœ… Fully operational with continuous mining

๐Ÿš€ Quick Start

For Learning

  1. Start with the Learning Course
  2. Follow the structured progression through all 19 sections
  3. Build your blockchain step by step with hands-on exercises

For Blockchain Implementation

  1. Clone the repository:

    git clone https://github.com/yourusername/go-basic-blockchain.git
    cd go-basic-blockchain
  2. Install dependencies:

    go mod tidy
  3. Run tests to verify everything works:

    make test
  4. Start the blockchain node:

    make run

    Or run the binary directly:

    ./bin/release/gbbd
  5. Access the web interface at http://localhost:8200

๐Ÿ—๏ธ Architecture Overview

Helios Consensus Algorithm

The project implements the Helios consensus algorithm, a sophisticated three-stage consensus mechanism:

  1. Stage 1 - Proof Generation: Miners create cryptographic proofs for transaction validation
  2. Stage 2 - Sidechain Routing: Transactions are routed through specialized protocols (BANK, MESSAGE, etc.)
  3. Stage 3 - Block Finalization: Validated blocks are finalized with proof verification

Key Components

  • Blockchain Core: Main blockchain implementation with Helios integration and continuous mining
  • Wallet System: Encrypted wallet management with key derivation
  • API Layer: RESTful endpoints with authentication middleware
  • P2P Network: Peer-to-peer communication framework
  • Sidechain Router: Transaction routing through specialized protocols
  • Test Suite: Comprehensive testing with optimized performance
  • Progress Indicator: Real-time status monitoring with smooth updates
  • Build System: Professional Makefile with cross-compilation and organized output

๐Ÿ“Š Project Structure

go-basic-blockchain/
โ”œโ”€โ”€ learn/                    # Comprehensive learning course (19 sections)
โ”‚   โ”œโ”€โ”€ README.md            # Course overview and navigation
โ”‚   โ”œโ”€โ”€ COURSE_OVERVIEW.md   # Detailed course guide
โ”‚   โ”œโ”€โ”€ phase1/              # Foundation (Sections 1-5)
โ”‚   โ”œโ”€โ”€ phase2/              # Advanced Features (Sections 6-10)
โ”‚   โ”œโ”€โ”€ phase3/              # User Experience (Sections 11-15)
โ”‚   โ””โ”€โ”€ phase4/              # Production Quality (Sections 16-19)
โ”œโ”€โ”€ cmd/                     # Application entry points
โ”‚   โ”œโ”€โ”€ gbb-cli/            # Command-line interface
โ”‚   โ”œโ”€โ”€ chaind/             # Blockchain daemon
โ”‚   โ””โ”€โ”€ demo/               # Demo applications
โ”œโ”€โ”€ internal/               # Core blockchain implementation
โ”‚   โ”œโ”€โ”€ helios/             # Helios consensus algorithm
โ”‚   โ”œโ”€โ”€ menu/               # User interface components
โ”‚   โ””โ”€โ”€ progress/           # Progress tracking
โ”œโ”€โ”€ docs/                   # Technical documentation
โ”œโ”€โ”€ test/                   # Test files and examples
โ”œโ”€โ”€ bin/                    # Compiled binaries
โ”œโ”€โ”€ data/                   # Blockchain data storage
โ”œโ”€โ”€ scripts/                # Build and deployment scripts
โ””โ”€โ”€ postman/                # API testing collections

๐Ÿ“š Documentation

Learning Resources

Technical Documentation

๐Ÿงช Testing

The project includes a comprehensive test suite with optimized performance:

  • Test Coverage: 39.8%
  • Test Execution Time: ~9.5 seconds (30x faster than before)
  • Smart Scrypt Configuration: Automatic switching between test and production security levels
  • Timeout Protection: All tests have 60-second timeouts to prevent hanging
  • Helios Tests: Comprehensive testing of the consensus algorithm
  • Blockchain Tests: All blockchain functionality tests passing

Run tests with:

make test

๐Ÿ”ง Development

Building

make build          # Build release binary
make debug          # Build debug binary with debugging symbols
make build-all      # Build for all platforms (Linux, Windows, macOS, ARM64, AMD64)

Running

make run            # Build and run release binary
make run-bin        # Run existing release binary
make debug          # Build and run debug binary with delve debugger
./bin/release/gbbd  # Run release binary directly
./bin/debug/gbbd    # Run debug binary directly

Testing

make test           # Run all tests
make test-short     # Run short tests
make test-unit      # Run unit tests only
make test-coverage  # Run with coverage

Development

make setup          # Setup dependencies
make fmt            # Format code
make lint           # Run linter
make clean          # Clean build artifacts
make clean-data     # Clean blockchain data
make clean-all      # Clean everything

Release

make release        # Build all cross-compiled binaries

Documentation Generation

make docs

๐Ÿ“ˆ Performance

  • Test Suite: 30x faster execution (9.5 seconds vs 5+ minutes)
  • Scrypt Optimization: Smart configuration for development vs production
  • Memory Usage: Optimized for educational use
  • Network Latency: Minimal overhead in P2P communication
  • Blockchain Operation: Continuous mining with proper state management
  • Progress Display: Smooth, non-flickering status updates

๐Ÿ—๏ธ Build System

The project features a professional build system with:

  • Cross-Compilation: Build for Linux, Windows, macOS (ARM64, AMD64)
  • Binary Organization: Separate bin/debug/ and bin/release/ directories
  • Go 1.22 Compatibility: Latest Go version with toolchain specification
  • Dependency Management: Proper go.mod and go.sum handling
  • Clean Targets: Organized cleanup with dependency preservation

๐ŸŽฏ Learning Paths

For Complete Beginners

  1. Start with Phase 1: Foundation
  2. Complete all sections in order
  3. Build your first blockchain in Section 5
  4. Progress through each phase sequentially

For Experienced Developers

  1. Review Phase 1 for Go/blockchain basics
  2. Jump to Phase 2 for advanced features
  3. Focus on Phase 3 for user interfaces
  4. Complete Phase 4 for production deployment

For Specific Skills

๐Ÿค Contributing

We welcome contributions! Please see our Contributing Guide for details.

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.


Ready to explore the future of blockchain technology? Choose your path:

๐ŸŽ“ Start Learning โ†’ - Begin the comprehensive 19-section course
๐Ÿ”ง Explore Implementation โ†’ - Dive into the technical documentation
๐Ÿš€ Quick Start โ†’ - Get the blockchain running immediately

Transform from beginner to production-ready blockchain developer with our complete learning experience!