SwiftChain_Backend is the core API service for SwiftChain, a Blockchain-Powered Logistics & Escrow Delivery Platform. It connects individuals, businesses, and independent drivers in a decentralized logistics economy, ensuring trust through escrow payments and smart contracts.
SwiftChain revolutionizes logistics by enabling existing transport assets (motorcycles, trucks, independent couriers) to participate in a shared economy. It addresses trust issues in delivery services through blockchain-powered escrow mechanisms.
Traditional logistics are often centralized, expensive, and lack trust between unknown parties. SwiftChain bridges this gap by locking payments in escrow until delivery is confirmed.
The platform empowers:
- Small Logistics Operators & Drivers: Access to a steady stream of delivery requests.
- Underserved Communities: Access to global payments via Stellar's borderless network.
- Cross-Border Merchants: Seamless settlement for international goods movement.
- 🌍 African Logistics Markets
- 🏢 SMEs & E-commerce Merchants
- 🛵 Courier Startups & Independent Drivers
- 🚢 Cross-Border Trade Facilitators
- Delivery Commission Fees: Percentage of each successful delivery.
- Escrow Service Charges: Small fee for securing the transaction.
- Enterprise Logistics APIs: Subscription for high-volume business integration.
- Cross-Border Settlement Fees: Currency conversion and transfer fees.
- Premium Analytics: Insights for fleet owners and businesses.
SwiftChain operates as a distributed system across three repositories:
- SwiftChain_Frontend: Next.js + TypeScript + TailwindCSS (User Interface)
- SwiftChain_Backend: Node.js + Express.js + TypeScript + MongoDB (Core Logic)
- SwiftChain_SmartContract: Stellar Soroban + Rust (Escrow & Trust)
The backend serves as the central hub connecting the frontend, database, and blockchain layers. Key responsibilities include:
- REST API for platform operations.
- Authentication & Authorization (JWT, RBAC).
- Delivery & Shipment Management (CRUD, Tracking).
- Driver Assignment Algorithms.
- File Upload Services (Receipts, Proof of Delivery).
- Real-Time Updates (WebSockets/Polling).
- Blockchain Integration Layer (Stellar/Soroban events).
- Runtime: Node.js
- Framework: Express.js
- Language: TypeScript
- Database: MongoDB (with Mongoose ODM)
- Authentication: JWT (JSON Web Tokens)
- Validation: Zod
- File Storage: Cloudinary / AWS S3
- Real-Time: Socket.io / Polling
- Documentation: Swagger / OpenAPI
- Logging: Winston
- Containerization: Docker & Docker Compose
- CI/CD: GitHub Actions
- Users: Register, Login, Create Requests.
- Drivers: Register, Verify, Accept Jobs.
- Admins: Platform Management.
- Security: JWT-based stateless auth with Role-Based Access Control (RBAC).
- Create Delivery: Customer details, pickup/drop-off locations, package info.
- Delivery List: Filtering, pagination, and status tracking.
- Status Workflow: Pending -> Assigned -> Picked Up -> In Transit -> Delivered.
- Mechanism to assign available drivers to pending delivery requests.
- Shipment Tracking: Detailed tracking of goods.
- Escrow Logic: Integration with Stellar Smart Contracts to lock/release funds based on delivery status.
- Secure upload of delivery receipts, images, and documents (PDF/JPG).
POST /auth/register- Register a new user/driver.POST /auth/login- Authenticate and retrieve token.
POST /deliveries- Create a new delivery request.GET /deliveries- Retrieve a list of deliveries (with filters).PUT /deliveries/:id/assign- Assign a driver to a delivery.
POST /shipments- Create a shipment record.GET /shipments- Get shipment details.
POST /uploads- Upload proof of delivery or documents.
- Authentication System (Register/Login/JWT).
- Core Delivery CRUD Endpoints.
- Driver Assignment Logic.
- MongoDB Schema Design.
- Basic Validation & Error Handling.
- Stellar Payment Service Integration.
- Escrow Payment Initiation Endpoints.
- Transaction Tracking.
- Payment Verification Webhooks.
- Soroban Smart Contract Interaction Layer.
- Blockchain Event Listeners.
- Escrow Release Verification Logic.
- Delivery Proof Validation on Chain.
- Logistics Analytics & Reporting APIs.
- Fleet Management Features.
- Reputation & Scoring System for Drivers.
- Cross-Border Payment Logic.
- Advanced Monitoring (Prometheus/Grafana).
SwiftChain_Backend/
├── .github/
│ └── workflows/
│ └── ci.yml # GitHub Actions CI pipeline
├── docs/ # Documentation files
├── postman/ # Postman collections
├── scripts/ # Utility scripts (seed, migration)
├── src/
│ ├── config/ # Environment & App Config
│ ├── controllers/ # Request Handlers
│ ├── services/ # Business Logic
│ ├── routes/ # API Route Definitions
│ ├── middlewares/ # Express Middlewares (Auth, Error, Validation)
│ ├── models/ # Mongoose Models
│ ├── repositories/ # Data Access Layer
│ ├── validators/ # Zod/Joi Schemas
│ ├── utils/ # Helper Functions
│ ├── types/ # TypeScript Type Definitions
│ ├── interfaces/ # TypeScript Interfaces
│ ├── events/ # Event Emitters/Handlers
│ ├── sockets/ # WebSocket Handlers
│ ├── uploads/ # File Upload Logic
│ ├── blockchain/ # Stellar/Soroban Integration
│ ├── database/ # DB Connection Logic
│ ├── app.ts # Express App Setup
│ └── server.ts # Entry Point
├── tests/ # Unit & Integration Tests
├── .env.example # Environment Variables Example
├── .eslintrc # Linter Config
├── .prettierrc # Formatter Config
├── docker-compose.yml # Docker Services
├── Dockerfile # Docker Build Instructions
├── package.json # Dependencies & Scripts
├── tsconfig.json # TypeScript Config
└── README.md # Project Documentation- Node.js v18+
- MongoDB v6.0+
- Docker (Optional)
git clone https://github.com/your-org/SwiftChain_Backend.git
cd SwiftChain_BackendCopy the example environment file and update the values.
cp .env.example .envpnpm installpnpm run devdocker-compose up --buildRun the test suite using Jest:
pnpm test- Fork the repository.
- Create a feature branch (
git checkout -b feature/amazing-feature). - Commit your changes (
git commit -m 'Add some amazing feature'). - Push to the branch (
git push origin feature/amazing-feature). - Open a Pull Request.
linked PR 5,4,6
This project is licensed under the ISC License.