A simple blockchain implementation using Node.js and Express with a frontend interface. This project demonstrates basic blockchain concepts including proof-of-work, block validation, and data persistence.
This project was created as part of the Node.js course assignment. It implements a basic blockchain with:
- Block creation with transaction data (sender, recipient, amount)
- Proof-of-Work mining system
- Chain validation
- Simple web interface
- RESTful API: Create, list, and validate blocks
- MVC Pattern: Models, Views (frontend), Controllers
- ES6 Modules: Modern JavaScript syntax
- Blockchain Features:
- Proof-of-Work mining
- Chain validation
- Data persistence
- Error Handling: Centralized error management
- Testing: Jest-based TDD approach
- Node.js (v18 or newer)
- npm
- Install dependencies:
npm install- Start the server:
npm run dev- Open in browser:
http://localhost:3000
project-2/
├── public/ # Frontend files
├── models/ # Blockchain logic
├── controllers/ # API controllers
├── routes/ # API routes
├── utils/ # Helper functions
├── tests/ # Jest tests
└── blockchain.json # Data storage
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/blocks | Get all blocks |
| POST | /api/blocks | Add new block |
| GET | /api/blocks/validate | Validate chain |
Run tests with:
npm testTests cover:
- Block creation
- Mining process
- Chain validation
- Data integrity