Deep DiveFull Stack

ParcelKoy

A web-based courier logistics platform managing the complete parcel delivery lifecycle — from merchant pickup requests to COD settlement.

Next.js
Node.js Modular Architecture
JWT
RBAC
Zod
parcekoy.com
parcel koy

Lifecycle

Pickup → COD

Roles

4 actor types

Security

JWT + RBAC + OTP

Stack

Next.js + Express


Project Overview

Built to simplify courier operations end to end

ParcelKoy streamlines parcel delivery operations, provides real-time tracking, reduces manual logistics errors, and scales with multi-role courier workflows.

What the platform covers

Parcel pickup requests

Rider assignment

Hub processing and routing

Real-time parcel tracking

Delivery confirmation

Cash on Delivery (COD) settlement

Improves handoff reliability across delivery stages

Supports scalable courier services across multiple roles

Keeps merchants, riders, and admins aligned on parcel state


Technical Architecture

A clean front-to-back structure built for scale

ParcelKoy keeps responsibilities separated so the frontend stays predictable while the backend remains modular and easy to extend.

Frontend — Next.js

Service Layer → Server Actions → Client Data Flow

1

Service layer owns API calls and network concerns.

2

Server actions wrap services with a centralized action wrapper.

3

Client components consume server actions and keep the UI focused.

Backend — Modular Express

1

route.ts handles API routing for each domain.

2

controllers.ts manages request flow and validation orchestration.

3

services.ts stores business logic and reusable operations.

4

validators.ts keeps Zod schemas and inferred types together.


Security & Validation

Strict controls across auth, access, and data integrity

The platform combines better-auth, JWT, RBAC, and Zod so the route layer, business logic, and forms all stay aligned on trust boundaries.

Authentication

better-auth and JWT with login, register, password reset, OTP validation, and token rotation.

Access Control

RBAC gates critical flows including block/delete user controls and role-specific logistics actions.

Validation

Zod keeps backend APIs and frontend forms type-safe and consistent from request to response.


User Roles & Access Control

Four roles, clearly separated responsibilities

RBAC controls permissions from platform administration to parcel delivery execution.

Super Admin

Owns platform-wide configuration and oversight.

  • Manage user roles and permissions
  • Configure system settings
  • Review audit logs
  • Control platform-level rules

Admin

Operates hubs, riders, and logistics flow.

  • Manage hubs and hub locations
  • Assign pickup and delivery riders
  • Track parcel movement through hubs
  • Handle COD collection and settlement

Merchant

Creates and monitors parcel delivery requests.

  • Create regular pickup or pick-and-drop requests
  • Provide weight, delivery type, and COD details
  • Track parcel status and cancel before pickup
  • Review delivery history and financial reports

Rider

Executes pickup and delivery assignments.

  • Accept or reject assigned tasks
  • Confirm pickup and update parcel status
  • Verify delivery with OTP
  • Add delivery notes when needed

Core Workflow

A strictly ordered delivery pipeline

Every parcel moves through a transparent logistics pipeline so merchants and receivers can follow each step with confidence.

01

Requested

02

Pickup Assigned

03

Picked Up

04

Received at Origin Hub

05

In Transit

06

Received at Destination Hub

07

Out for Delivery

08

Delivery Verification (OTP)

09

Delivered

Final
OTP verification at the final step adds a trust check before a parcel is marked delivered.

Delivery Services & Pricing

Flexible delivery options with dynamic pricing

Different delivery experiences with pricing adaptable to weight and delivery zone.

Home Delivery

Delivered directly to the receiver's address.

Pickup Point Delivery

Receiver collects the parcel from a designated hub or location.

Express Delivery

Available within Dhaka city with delivery within 24 hours.

Standard Delivery

Available nationwide with delivery within 48 to 72 hours.

Pricing factors

Weight

Measured per parcel

Zone

Based on delivery region

Tier

Aligned to speed level


Database Design

Structured around domain tables

Each domain is isolated into its own management module, keeping the codebase maintainable and scalable without collapsing into a single large service file.

Core domain tables

Users
Parcels
Hubs / Routes
Riders
Payments / COD
Audit Logs

ERD diagram — postresql tables and relationships

View Full ERD

Module structure per domain

route.ts

API routing

controllers.ts

Request orchestration

services.ts

Business logic

validators.ts

Zod schemas


Next Step

Explore the live product or review the codebase.

The links below connect you to the deployed frontend and the GitHub repositories that power ParcelKoy.