Skip to content

A simplified blockchain implementation with proof-of-work mining, REST API microservice, and React frontend for visualization.

Notifications You must be signed in to change notification settings

rahmanazhar/golang-blockchain

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Golang Blockchain with React Frontend

A simplified blockchain implementation with proof-of-work mining, REST API microservice, and React frontend for visualization.

Author

Rahman Azhar

About

This project implements a basic blockchain with proof-of-work mining and provides both a REST API microservice and a React-based frontend interface. The blockchain maintains data integrity through SHA-256 hashing and includes validation mechanisms to ensure chain consistency.

Features

  • Blockchain implementation with proof-of-work mining
  • Chain validation system
  • REST API endpoints for blockchain interaction
  • React frontend for blockchain visualization
  • Docker containerization for easy deployment

Project Structure

  • /pkg/blockchain: Core blockchain implementation
  • /api: REST API server implementation
  • /frontend: React frontend application
  • main.go: Backend application entry point
  • Dockerfile & docker-compose.yml: Container configuration

Running with Docker

  1. Build and start the services:
docker-compose up --build
  1. Access the application:

API Endpoints

GET /blockchain

Returns the current state of the blockchain and its validity status.

Response format:

{
    "blocks": [
        {
            "timestamp": 1234567890,
            "data": "Block Data",
            "hash": "block_hash",
            "prevHash": "previous_block_hash",
            "nonce": 123
        }
    ],
    "valid": true
}

POST /block

Adds a new block to the blockchain.

Request format:

{
    "data": "Your block data here"
}

Technical Details

  • Backend: Go
  • Frontend: React with Chakra UI
  • Containerization: Docker & Docker Compose
  • Hashing: SHA-256
  • State Management: React Hooks
  • API Communication: Axios
  • Styling: Chakra UI components

Development

To run the services separately for development:

  1. Backend:
go run main.go
  1. Frontend:
cd frontend
npm install
npm start

Features

  • Real-time blockchain visualization
  • Block mining with proof-of-work
  • Chain validation checking
  • Interactive block addition
  • Responsive design
  • Automatic chain updates

About

A simplified blockchain implementation with proof-of-work mining, REST API microservice, and React frontend for visualization.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published