An open API service indexing awesome lists of open source software.

https://github.com/rafirabby13/parcel-delivery-system

This is a role-based, secure, modular backend API for a Parcel Delivery Management System inspired by services like **Pathao Courier** or **Sundarban**. It allows users to register as **senders** or **receivers**, create parcel requests, track deliveries, and manage parcel statuses. Admins can manage users and parcels, enforce policies.
https://github.com/rafirabby13/parcel-delivery-system

bcryptjs cookie-parser cors dotenv expressjs nodejs typescript zod

Last synced: about 2 months ago
JSON representation

This is a role-based, secure, modular backend API for a Parcel Delivery Management System inspired by services like **Pathao Courier** or **Sundarban**. It allows users to register as **senders** or **receivers**, create parcel requests, track deliveries, and manage parcel statuses. Admins can manage users and parcels, enforce policies.

Awesome Lists containing this project

README

          

Live Site

###

https://parcel-delivery-system-zeta.vercel.app/

###

Parcel Delivery System

###

This is a role-based, secure, modular backend API for a Parcel Delivery Management System inspired by services like **Pathao Courier** or **Sundarban**. It allows users to register as **senders** or **receivers**, create parcel requests, track deliveries, and manage parcel statuses. Admins can manage users and parcels, enforce policies, and oversee delivery operations.

###

Technologies Used

###

- **Node.js** with **Express**
- **MongoDB** + **Mongoose**
- **JWT Authentication**
- **Zod** for input validation
- **bcrypt** for password hashing
- **TypeScript**
- **Role-based Access Control (RBAC)**

###


javascript logo

typescript logo

mongodb logo

express logo

eslint logo

nodejs logo

###

Features

###

โœ… Sender:

-Create a new parcel
-Cancel (if not picked up)
-View parcel history & status updates

โœ… Receiver:

-Track incoming parcels
-Confirm delivery
-View delivery logs

โœ… Admin:

-View/manage all users & parcels
-Block/unblock users
-Manually update parcel statuses
-Assign delivery personnel (optional)

###

๐Ÿ“œ Validation & Business Rules

###

*Senders can only cancel before dispatch.
*Receivers can confirm delivery.
*Blocked users are restricted.
*Parcel cancellation disallowed after PICKED_UP.
*Return requests allowed only in specific statuses (APPROVED, PICKED_UP, IN_TRANSIT).
*COD parcels can't be returned after dispatch.
*Admins override all roles and enforce status changes.

###

๐Ÿ” API Highlights

###

-Tracking ID Format: TRK-YYYYMMDD-XXXXXX
-Status transitions enforced via Zod
-Transactions used for payment cancel/refund & return logic
-All errors handled centrally with meaningful messages

###

๐Ÿ” Authentication & Authorization

###

--JWT-based auth with access and refresh tokens.

--Three roles:

-SENDER โ€“ Can create, cancel, and track their parcels
-RECEIVER โ€“ Can track, confirm delivery
-ADMIN โ€“ Full control over parcels, users, and status updates

--Passwords are hashed securely using bcrypt.

###

๐Ÿšš Parcel Lifecycle & Business Logic

###

REQUESTED โ†’ APPROVED โ†’ PICKED_UP โ†’ IN_TRANSIT โ†’ DELIVERED โ†’ RETURNED

###

๐Ÿงช API Testing (via Postman)

###

-JWT token handling
-Role access checks
-Parcel status changes
-Return and refund logic
-Blocked user edge cases

###

๐Ÿ” Role-Based Route Access

###

| Endpoint | Role Access |
| --------------------------- | --------------- |
| POST /auth/register | Public |
| POST /auth/login | Public |
| GET /parcels/me | Sender |
| POST /parcels | Sender |
| PATCH /parcels/\:id/cancel | Sender |
| GET /parcels/\:id | Sender/Receiver |
| PATCH /parcels/\:id/confirm | Receiver |
| GET /admin/parcels | Admin |
| PATCH /admin/users/\:id | Admin |
| PATCH /admin/parcels/\:id | Admin |

###

๐Ÿ“ฆ Parcel Schema Sample

###

{
trackingId: "TRK-20250731-123456",
senderId: ObjectId,
receiverId: ObjectId,
weight: Number,
status: 'IN_TRANSIT',
paymentMethod: 'COD' | 'PREPAID',
paymentStatus: 'PENDING' | 'PAID' | 'REFUNDED',
trackingEvents: [
{
status: 'PICKED_UP',
location: 'Banani',
note: 'Picked by rider',
updaterId: ObjectId,
timestamp: Date
}
]
}

###

โš™๏ธ Getting Started

###

๐Ÿ”„ Clone the Repo

###

git clone this repo
cd parcel-delivery-api

###

๐Ÿงช Run in Dev Mode

###

npm run dev

###

๐Ÿ”จ Build & Start

###

npm run build
npm start

###