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 .envnpm installnpm run devdocker-compose up --buildRun the test suite using Jest:
npm 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.
This project is licensed under the ISC License.