SafeShipping is a blockchain-based logistics platform using smart contracts, decentralized oracles, and IoT integrations to automate, secure, and verify global shipping workflows.
This repository contains a comprehensive directory structure for developing and deploying the SafeShipping platform. For detailed information about the directory structure, please refer to the directory_structure.md file.
- Smart Contracts: Blockchain contracts for secure, transparent shipping workflows
- WASM Assembly Language: Web Assembly Language for performance and efficiency
- Backend API: Server-side application for business logic and data management
- Frontend Application: User interface for interacting with the platform
- IoT Integration: Components for connecting with IoT devices and sensors
- Oracle Services: Decentralized data feeds connecting smart contracts with external data
- Documentation: Comprehensive guides for developers and users
- Clone this repository
- Review the directory structure documentation
- Set up the development environment using Docker
- Begin implementing components based on the provided structure
bash bash ./docker/build/dev_compose.sh
This script was previously docker-compose_local_only.sh, now reorganized into docker/build/.
backend-api for manifest intake
oracle-service for token minting
blockchain-node for ledger simulation
bash
curl -X POST http://localhost:8080/api/intake/manifest
-H "Content-Type: application/json"
-d '{"sender":"Richard", "receiver":"Kalani", "carrier":"FedEx"}'
bash cd frontend npm run dev Which launched the Vite dev server at http://localhost:5173.
Choose your environment:
For manual development without containers.
wsl -d Ubuntu
cd ~/Projects/SafeShipping/backend
uvicorn src.main:app --host 0.0.0.0 --port=8080 --reload
Or launch via Docker Compose:
bash
bash docker/build/dev_compose.sh
πΉ Frontend (Windows Host)
bash
cd frontend
npm install
npm run dev
Access the UI at: http://localhost:5173
π§ͺ Dev Startup (Full Stack via Docker)
Runs all containers with dev tooling and hot reload.
πΉ Services
backend-api
oracle-service
blockchain-node
frontend
smart-contracts
πΉ Launch All
bash
cd docker
bash ./build/dev_compose.sh
Compose file used: docker/config/docker-compose.yml
Verify containers:
bash
docker ps
π Production Deployment
πΉ Docker Compose (Secure Build)
Use production compose file:
bash
docker compose -f docker/config/docker-compose.prod.yml up -d
Includes HTTPS, env injection, and production images.
πΉ Kubernetes (Optional)
If using K8s, apply manifests from:
k8s/
βββ deployment.yaml
βββ service.yaml
βββ ingress.yaml
bash
kubectl apply -f k8s/
π Manifest Workflow (Manual Test)
πΉ Submit Manifest via Curl
bash test CORS
curl -i -X OPTIONS http://localhost:3000/shipment \
-H "Origin: http://localhost:5173" \
-H "Access-Control-Request-Method: POST"
HTTP/1.1 204 No Content
X-Powered-By: Express
Access-Control-Allow-Origin: http://localhost:5173
Vary: Origin, Access-Control-Request-Headers
Access-Control-Allow-Methods: GET,HEAD,PUT,PATCH,POST,DELETE
Content-Length: 0
Date: Fri, 12 Sep 2025 19:48:22 GMT
Connection: keep-alive
Keep-Alive: timeout=5
bash test CORS
curl -i -X OPTIONS http://localhost:8080/api/intake/manifest \
-H "Origin: http://localhost:5173" \
-H "Access-Control-Request-Method: POST"
HTTP/1.1 204 No Content
X-Powered-By: Express
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: GET,HEAD,PUT,PATCH,POST,DELETE
Vary: Access-Control-Request-Headers
Content-Length: 0
Date: Fri, 12 Sep 2025 19:48:50 GMT
Connection: keep-alive
Keep-Alive: timeout=5
bash test MANIFEST
curl -i -X POST http://localhost:3000/shipment \
-H "Origin: http://localhost:5173" \
-H "Content-Type: application/json" \
-d `{
"action": "submit",
"agent": { "carrier": "FedEx" },
"shipment": {
"id": "MOCK-001",
"origin": "Denver, CO",
"destination": "San Diego, CA",
"contents": ["Books", "Electronics"],
"timestamp": "2025-09-12T18:30:00Z"
}`
HTTP/1.1 200 OK
X-Powered-By: Express
Access-Control-Allow-Origin: http://localhost:5173
Vary: Origin
Content-Type: application/json; charset=utf-8
Content-Length: 192
ETag: W/"c0-eUZOuRKqSOB3yxXBd+JYHxlLezw"
Date: Fri, 12 Sep 2025 19:51:52 GMT
Connection: keep-alive
Keep-Alive: timeout=5
{"status":"success","carrier":"FedEx","token":"mock-token-1z4ljwmf","blockchain_tx":"0xf4fd4fd088e53000000000000000000000000000000000000000000000000000","timestamp":"2025-09-12T19:51:52.475Z"}
πΉ Submit via Frontend Button
Fill out the form
Click "Submit via API"
Paste Manafest for Submission
Example Manafest
---
{
"carrier": "FedEx",
"origin": "Denver, CO",
"destination": "San Diego, CA",
"weight": "15lbs",
"dimensions": "18x12x10",
"insurance": true,
"transportMode": "air",
"priority": "Express",
"sender": "Acme Corp",
"receiver": "John Doe",
"contents": ["Books", "Electronics", "Clothing"],
"fragility": "High",
"departure_location": "Denver International Airport",
"departure_time": "2025-09-15T09:00:00Z",
"status_dispatch": "Dispatched",
"contract_hash": "0xabc123def456...",
"status_transit": "In Transit",
"customs_clearance": "Cleared",
"arrival_location": "San Diego International Airport",
"arrival_time": "2025-09-16T14:30:00Z",
"status_delivery": "Pending",
"notes": "Handle with care β fragile items"
}
---
Token will display on successful response
POST /audit hit β received: {
source: 'manual',
role: 'agent',
timestamp: '2025-10-10T16:36:14.298Z',
action: 'submitOrder'
}
DEBUG: Returning stubbed blockchain response: {
status: 'success',
carrier: 'FedEx',
token: 'mock-live-token-mi7qv8i5',
blockchain_tx: '0xad0f7d35160b9000000000000000000000000000000000000000000000000000',
timestamp: '2025-10-10T16:36:14.871Z',
contract_id: 'demo-contract-377'
}
POST /audit hit β received: {
source: 'manual',
role: 'agent',
timestamp: '2025-10-10T16:36:21.862Z',
action: 'submitOrder'
}
DEBUG: Returning stubbed blockchain response: {
status: 'success',
carrier: 'FedEx',
token: 'mock-live-token-0bs9zrfc',
blockchain_tx: '0x18983e2edfab4000000000000000000000000000000000000000000000000000',
timestamp: '2025-10-10T16:36:22.389Z',
contract_id: 'demo-contract-840'
}
-----------------------------------------------------------------------------------------
βοΈ Folder Structure Summary
SAFESHIPPING/
βββ backend/ # API logic, token minting
βββ frontend/ # Vite UI
βββ docker/
β βββ build/ # Shell scripts for builds
β βββ test/ # Shell scripts for testing
β βββ dev/ # Dev launchers
β βββ config/ # Compose YAMLs
β βββ frontend/ # Dockerfile.dev for UI
βββ k8s/ # Kubernetes manifests
βββ scripts/ # Blockchain test utils (curl)
βββ .env # Runtime env vars
βββ .env.example # Template env vars
βββ cleanup_root.sh # Root cleanup utility
βββ README.md # You are here
π§ Tips for Developers
π’ Always run backend before frontend if doing local dev
π Use cleanup_root.sh after major file restructuring
π¦ Manifest tokens are logged and traceable on-chain
π‘οΈ Write tests inside tests/ and run with pytest or npm test
π₯ Contributors
Name Role
Richard Lead Architect & Token Designer
Richard UX Systems & Compliance Logic
## License
This project is licensed under the GPL-3.0 License - see the [LICENSE](./LICENSE) file for details.