Skip to content

A modern, Python-based blockchain implementation focusing on simplicity, security, and scalability. RavenChain demonstrates core blockchain concepts while providing a foundation for building decentralized applications

License

Notifications You must be signed in to change notification settings

raythurman2386/ravenchain

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

22 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

RavenChain

A modern, Python-based blockchain implementation focusing on simplicity, security, and scalability. RavenChain demonstrates core blockchain concepts while providing a foundation for building decentralized applications.

πŸš€ Features

Current Features

  • βœ… Core blockchain implementation with proof-of-work mining
  • βœ… Secure wallet management with ECDSA cryptography
  • βœ… Transaction system with digital signatures
  • βœ… Bitcoin-style address generation
  • βœ… Interactive command-line interface
  • βœ… Persistent wallet storage
  • βœ… Chain validation and integrity checking
  • βœ… Mining rewards system
  • βœ… FastAPI-based REST API
  • βœ… Database persistence with PostgreSQL
  • βœ… Docker containerization

Planned Features

  • πŸ”„ Peer-to-peer networking
  • πŸ“Š Block explorer web interface
  • πŸ“œ Smart contract support
  • πŸ” UTXO model implementation
  • πŸ”’ Enhanced security features
  • ⚑ Performance optimizations

πŸ›  Technology Stack

  • Language: Python 3.13+
  • Cryptography: ecdsa, hashlib
  • Storage: PostgreSQL for blockchain persistence
  • Backend: FastAPI for REST API endpoints
  • Frontend: React 19 with TypeScript (planned)
  • Future Stack:
    • WebSocket for real-time updates
    • Redis for caching
    • Elasticsearch for block/transaction search (optional)

πŸ— Project Structure

ravenchain/
β”œβ”€β”€ ravenchain/              # Core package
β”‚   β”œβ”€β”€ __init__.py
β”‚   β”œβ”€β”€ block.py            # Block implementation
β”‚   β”œβ”€β”€ blockchain.py       # Main blockchain logic
β”‚   β”œβ”€β”€ transaction.py      # Transaction handling
β”‚   └── wallet.py           # Wallet management
β”œβ”€β”€ api/                    # FastAPI backend
β”‚   β”œβ”€β”€ __init__.py
β”‚   β”œβ”€β”€ main.py            # API entry point
β”‚   β”œβ”€β”€ routes/            # API route handlers
β”‚   β”‚   β”œβ”€β”€ block_routes.py
β”‚   β”‚   β”œβ”€β”€ mining_routes.py
β”‚   β”‚   β”œβ”€β”€ transaction_routes.py
β”‚   β”‚   └── wallet_routes.py
β”‚   └── database/          # Database models and config
β”‚       └── models.py
β”œβ”€β”€ config/                # Configuration
β”‚   β”œβ”€β”€ settings.py        # App settings
β”‚   └── logging.py         # Logging setup
β”œβ”€β”€ scripts/               # Utility scripts
β”œβ”€β”€ tests/                 # Test suite
β”œβ”€β”€ Dockerfile            # Docker build file
β”œβ”€β”€ docker-compose.yml    # Docker services config
└── requirements.txt      # Python dependencies

πŸš€ Quick Start

Prerequisites

  • Python 3.13 or higher
  • pip (Python package installer)

OR

  • Docker
  • Docker Compose

Installation

Using Python (Traditional Setup)

# Clone the repository
git clone https://github.com/yourusername/ravenchain.git
cd ravenchain

# Create and activate virtual environment
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate

# Install dependencies
pip install -e .

Using Docker 🐳

# Clone the repository
git clone https://github.com/yourusername/ravenchain.git
cd ravenchain

# Build and start the containers
docker-compose up --build

# Or run in detached mode
docker-compose up -d

The Docker setup provides:

  • Isolated development environment
  • Consistent dependencies across platforms
  • Easy setup for future features (API, database)
  • Production-ready container configuration

Running Tests with Docker

# Run tests in a new container
docker-compose run --rm ravenchain pytest

# Run tests with coverage
docker-compose run --rm ravenchain pytest --cov=ravenchain

🎯 Roadmap

Phase 1: Core Infrastructure Enhancement

  • Basic blockchain implementation
  • Wallet management system
  • Command-line interface
  • Transaction handling
  • Unit test coverage
  • Documentation improvements

Phase 2: Data Persistence & API

  • Implement PostgreSQL for blockchain storage
  • Design and implement FastAPI REST API
    • Block endpoints
    • Transaction endpoints
    • Wallet endpoints
    • Mining endpoints
  • API documentation with Swagger/OpenAPI
  • Request rate limiting
  • API authentication system

Phase 3: Networking & Distribution (Current)

  • P2P network implementation
    • Node discovery protocol
    • Block synchronization
    • Transaction broadcasting
  • Consensus mechanism improvements
  • Network state management
  • Peer management system

Phase 4: Smart Contracts & Advanced Features (Next)

  • Basic smart contract engine
  • Contract deployment system
  • Standard contract templates
  • Contract execution environment
  • Gas fee implementation

Phase 5: Performance & Security

  • UTXO model implementation
  • Merkle tree optimization
  • Chain pruning
  • Advanced security features
    • Double-spend protection
    • Sybil attack prevention
    • DDoS mitigation
  • Performance benchmarking

Phase 6: User Interface & Tools

  • Block explorer web interface
  • Wallet GUI application
  • Network monitoring tools
  • Development tools and SDKs

πŸ§ͺ Testing

pytest tests/

πŸ“– API Documentation

The REST API will provide the following endpoints:

# Authentication Endpoints
POST   /api/v1/auth/register       # Register a new user
POST   /api/v1/auth/login          # Login and get tokens
POST   /api/v1/auth/refresh        # Refresh access token
GET    /api/v1/auth/me             # Get current user info
PUT    /api/v1/auth/me             # Update current user info

# Admin Endpoints
GET    /api/v1/admin/users         # List all users (admin only)
GET    /api/v1/admin/users/{id}    # Get user details (admin only)
PUT    /api/v1/admin/users/{id}    # Update user (admin only) 
DELETE /api/v1/admin/users/{id}    # Delete user (admin only)

# Block Endpoints
GET    /api/v1/blocks              # List blocks
GET    /api/v1/blocks/{hash}       # Get block details
GET    /api/v1/blocks/latest       # Get latest block

# Transaction Endpoints
GET    /api/v1/transactions        # List transactions
POST   /api/v1/transactions        # Create transaction

# Wallet Endpoints
GET    /api/v1/wallets/{address}   # Get wallet info

# Mining Endpoints
POST   /api/v1/mine                # Mine new block

Detailed API documentation is available via Swagger UI at /docs.

🀝 Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

πŸ“ License

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

πŸ™ Acknowledgments

  • Built with Python's cryptographic libraries
  • Inspired by blockchain technology principles
  • Community contributions and feedback

πŸ“ž Contact

Ray Thurman - @raythurman2386

Project Link: https://github.com/raythurman2386/ravenchain

About

A modern, Python-based blockchain implementation focusing on simplicity, security, and scalability. RavenChain demonstrates core blockchain concepts while providing a foundation for building decentralized applications

Resources

License

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published