Skip to content

IASSCMS/Order-Tracking-BlockTrack

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

58 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ”— BlockTrack – Blockchain-Powered Order Tracking System

This project implements a fullstack solution for a Blockchain-Based Order Tracking System, developed as part of Group 30 in the Intelligent and Smart Supply Chain Management System project.

It includes:

  • Hyperledger Fabric (blockchain ledger)
  • IPFS (for decentralized file storage)
  • Django REST Framework (backend API)
  • Angular (frontend for order interaction)

πŸ“¦ Folder Structure

blocktrack/
β”œβ”€β”€ blocktrack_backend/        # Django API project
β”‚   β”œβ”€β”€ api/                   # Views and IPFS utils
β”‚   β”œβ”€β”€ manage.py
β”‚   └── requirements.txt
β”œβ”€β”€ blocktrack_frontend/       # Angular frontend app
β”‚   β”œβ”€β”€ src/app/create-order/  # Order creation UI
β”‚   β”œβ”€β”€ src/app/read-order/    # Read order UI
β”‚   └── angular.json
β”œβ”€β”€ chaincode-order/           # Go chaincode
β”‚   └── order.go
β”œβ”€β”€ scripts/                   # Shell automation scripts
β”‚   └── invoke_order.sh
└── README.md

βš™οΈ Prerequisites

Before running this project, ensure you have:


πŸš€ How to Run the Project

1. Clone the Repo

git clone https://github.com/IASSCMS/Order-Tracking-BlockTrack.git
cd blocktrack

2. Start the Blockchain Network

From your Fabric samples directory:

curl -sSL https://bit.ly/2ysbOFE | bash -s -- -d -s
cd ./test-network

βœ… Note: Adjust -ccp if needed to point to your chaincode-order directory.

βš™οΈ One-Click Network Setup (Full Automation)

To make setup easier, we’ve included a shell script: scripts/setup_chaincode.sh

πŸ”§ What It Does:

  • Brings down any existing Fabric network
  • Starts the test network with 2 organizations (Org1 + Org2)
  • Packages the chaincode
  • Installs it on both peers
  • Approves chaincode definition for both orgs
  • Commits chaincode
  • Ready for backend integration!

πŸš€ To Run It:

chmod +x scripts/setup_chaincode.sh
./scripts/setup_chaincode.sh
πŸ” Make sure you're inside the test-network directory before running the script.

---

### 3. Start IPFS
Run either:
```bash
# Option A
Open IPFS Desktop

# Option B
ipfs daemon

4. Run the Django Backend

cd blocktrack_backend
python3 -m venv env
source env/bin/activate
pip install -r requirements.txt
python manage.py runserver

5. Shell Script Automation (Optional)

You can use a script for invoking blockchain:

chmod +x scripts/invoke_order.sh

The Django view will run this script with proper environment to interact with peer CLI.


6. Run the Angular Frontend

cd blocktrack_frontend
npm install
ng serve

Open your browser at: http://localhost:4200


7. Start the Database with Docker Compose

To start the database, use the provided docker-compose.yaml file:

cd blocktrack_backend
sudo docker-compose up -d

This will start the PostgreSQL database required for the backend.

8. Environment Variables

Ensure the following environment variables are set for the backend:

DATABASE_NAME=blocktrack_db
DATABASE_USER=blocktrack_user
DATABASE_PASSWORD=securepassword
DATABASE_HOST=localhost
DATABASE_PORT=5432
SECRET_KEY=your_secret_key_here
DEBUG=True
ALLOWED_HOSTS=*

9. Dummy Data

Run the dummy.py as follows:

# On Linux/MacOS
python manage.py shell < dummy.py

# On Windows
python manage.py shell < dummy.py

πŸ”Œ API Endpoints

Run the django app and visit /swagger to view the swagger-UI docs


πŸ–ΌοΈ Angular UI Pages

Route Function
/create-order Upload + register
/read-order Search order ID

πŸ§ͺ Testing with Postman

POST /api/create-order/

Body: form-data

Key Type Value
order_id Text order901
status Text Packed
timestamp Text 2025-05-02T22:00:00Z
document File upload any file

GET /api/read-order/order901/

  • Returns the blockchain order details in JSON.

πŸ”§ Chaincode Logic (Go)

Chaincode functions:

CreateOrder(ctx, id, status, timestamp, docHash)
ReadOrder(ctx, id)

Each order is stored like:

{
  "ID": "order901",
  "Status": "Packed",
  "Timestamp": "2025-05-02T22:00:00Z",
  "DocumentHash": "Qm..."
}

πŸ“‚ IPFS Integration

  • Files uploaded in Create Order go to IPFS.
  • CID is stored on blockchain.
  • You can access documents at:
https://ipfs.io/ipfs/<CID>

πŸ‘¨β€πŸ’Ό Project Notes

  • Developed by Group 30 – Blockchain-Based Order Tracking
  • Part of Group H: Intelligent and Smart Supply Chain Management System
  • Frontend + Backend + Chaincode fully working

About

Order Management and Supplier Request Management system with blockchain technology incorporated for data integrity and decentralization.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors