Skip to content

An implementation of blockchain from scratch - A student attendance system based on Blockchain technology

License

Notifications You must be signed in to change notification settings

adeen-s/Blockendance

Repository files navigation

Blockendance - Blockchain Implementation from Scratch

A Complete Blockchain-based Attendance System Built from the Ground Up

Blockchain Python Flask License


πŸš€ Project Overview

Blockendance is a complete blockchain implementation built from scratch in Python, demonstrating core blockchain concepts through a practical attendance management system. This project showcases how to build a functional blockchain without relying on existing blockchain frameworks.

🎯 What Makes This Special

  • Pure Python Implementation: Every component built from scratch
  • Complete Blockchain Architecture: Genesis block, block creation, chain validation
  • Cryptographic Security: SHA-256 hashing and block linking
  • Real-world Application: Practical attendance management use case
  • Educational Value: Perfect for understanding blockchain fundamentals

πŸ”— Blockchain Architecture

Core Components

1. Block Structure

class Block:
    - index: Block position in chain
    - timestamp: Block creation time
    - data: Attendance records (JSON)
    - prev_hash: Previous block's hash
    - hash: Current block's SHA-256 hash

2. Genesis Block

  • First block in the chain (index 0)
  • No previous hash reference
  • Initializes the blockchain

3. Chain Validation

  • Cryptographic hash verification
  • Block linkage integrity
  • Tamper detection algorithms

4. Data Immutability

  • Once written, data cannot be modified
  • Any tampering breaks the chain
  • Cryptographic proof of integrity

πŸ› οΈ Implementation Details

File Structure

Blockendance/
β”œβ”€β”€ block.py           # Block class with hashing and validation
β”œβ”€β”€ genesis.py         # Genesis block creation
β”œβ”€β”€ newBlock.py        # New block creation and addition
β”œβ”€β”€ getBlock.py        # Block retrieval and search
β”œβ”€β”€ checkChain.py      # Blockchain integrity verification
β”œβ”€β”€ blockchain.py      # Main Flask application
└── templates/         # Web interface templates

Key Features

πŸ” Cryptographic Security

  • SHA-256 Hashing: Each block secured with cryptographic hash
  • Chain Linking: Blocks linked via previous block hashes
  • Tamper Detection: Any modification breaks the chain
  • Data Integrity: Immutable record storage

πŸ“Š Blockchain Operations

  • Block Creation: Automated block generation with proper indexing
  • Chain Validation: Complete integrity checking algorithms
  • Data Retrieval: Efficient search through blockchain
  • Statistics: Real-time blockchain analytics

🌐 Web Interface

  • Responsive Design: Modern Material Design UI
  • Form Validation: Client and server-side validation
  • Real-time Feedback: Live attendance counting
  • Error Handling: Comprehensive error management

πŸš€ Quick Start

Prerequisites

  • Python 3.6 or higher
  • pip package manager

Installation

  1. Clone the repository
git clone https://github.com/adeen-s/Blockendance.git
cd Blockendance
  1. Install dependencies
pip install Flask
  1. Run the application
python blockchain.py
  1. Access the application Open your browser and navigate to http://localhost:5001

πŸ“– How It Works

1. Genesis Block Creation

def create_genesis_block():
    genesis_data = {
        "type": "genesis",
        "message": "Genesis Block - Blockchain Initialized",
        "creator": "Blockendance System"
    }
    return Block(0, datetime.now(), genesis_data, "0")

2. Adding New Blocks

def next_block(last_block, data):
    this_index = last_block.index + 1
    this_timestamp = datetime.now()
    this_data = copy.deepcopy(data)
    this_prev_hash = last_block.hash
    return Block(this_index, this_timestamp, this_data, this_prev_hash)

3. Chain Validation

def check_integrity(chain):
    for i, block in enumerate(chain):
        if not block.is_valid():
            return f"Error: Block #{i} has invalid hash"
        if i > 0 and block.prev_hash != chain[i-1].hash:
            return f"Error: Block #{i} not properly linked"
    return "Blockchain integrity verified"

πŸŽ“ Educational Value

This project demonstrates:

  • Blockchain Fundamentals: Core concepts without complexity
  • Cryptographic Hashing: SHA-256 implementation
  • Data Structures: Linked list of blocks
  • Web Development: Flask framework integration
  • Security Principles: Immutability and integrity

πŸ” Use Cases

  • Educational: Learn blockchain development
  • Proof of Concept: Demonstrate blockchain applications
  • Research: Study blockchain behavior
  • Development: Base for larger blockchain projects

⚠️ Important Notes

  • Educational Purpose: This is a simplified blockchain for learning
  • No Consensus: Single-node implementation (no mining/proof-of-work)
  • Centralized: Runs on single Flask server
  • No Persistence: Data lost on restart (can be extended)

🀝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

πŸ“„ License

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

πŸ‘¨β€πŸ’» Author

Adeen Shukla - Initial work - GitHub


Built with ❀️ to demonstrate blockchain technology from scratch

About

An implementation of blockchain from scratch - A student attendance system based on Blockchain technology

Topics

Resources

License

Stars

Watchers

Forks