FlexDelivery24 API

A comprehensive delivery management platform built with NestJS, providing job creation, delivery matching, bidding, rewards, reviews, and comprehensive admin functionality.

Table of Contents

Features

πŸ” Authentication & Authorization

πŸ“¦ Jobs & Deliveries

🚚 Delivery Offers

πŸ’° Rewards & Points

⭐ Reviews & Ratings

πŸ“„ KYC & Document Verification

πŸ‘₯ User Management

πŸ’° Wallet Management

πŸ’³ Payments & Transactions

🏦 Withdrawal Management

πŸ’Έ Tax & Fee Management

πŸ—ΊοΈ Serviceable Areas

πŸ“Š Admin Dashboard

πŸ“§ Contact Management

πŸ”’ Formula Management

πŸ“ Admin Activity Logs

πŸ”” Notifications

Architecture

This application follows Clean Architecture principles with clear separation of concerns:

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚      Presentation Layer             β”‚
β”‚  (Controllers, Guards, Interceptors)β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
               β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚      Application Layer               β”‚
β”‚  (Use Cases, DTOs, Mappers)         β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
               β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚      Domain Layer                    β”‚
β”‚  (Entities, Interfaces, Services)    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
               β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚      Infrastructure Layer            β”‚
β”‚  (Repositories, External Services)   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Module Structure

Project Structure

src/
β”œβ”€β”€ config/                 # Application configuration
β”œβ”€β”€ database/              # Database migrations
β”‚   └── migrations/
β”œβ”€β”€ modules/
β”‚   β”œβ”€β”€ shared/           # Shared business logic
β”‚   β”‚   β”œβ”€β”€ application/  # Use cases, DTOs, mappers
β”‚   β”‚   β”œβ”€β”€ domain/       # Domain entities, interfaces
β”‚   β”‚   β”œβ”€β”€ infrastructure/ # Repositories, services, external APIs
β”‚   β”‚   β”œβ”€β”€ common/       # Utilities, constants, decorators
β”‚   β”‚   β”œβ”€β”€ errors/       # Error handling
β”‚   β”‚   └── presentation/ # Guards, interceptors, filters
β”‚   β”œβ”€β”€ web/              # Web controllers (includes admin)
β”‚   β”‚   └── controllers/
β”‚   └── mobile/           # Mobile controllers (user-only)
β”‚       └── controllers/
└── main.ts               # Application entry point

For detailed structure documentation, see:

Getting Started

Prerequisites

Installation

# Install dependencies
npm install

# Copy environment file
cp .env.example .env

# Configure environment variables
# Edit .env with your database credentials, API keys, etc.

Environment Variables

Required environment variables (see .env.example):

Database Setup

# Run migrations
npm run migration:run:batch

# Seed initial data (roles, permissions)
npm run seed

Running the Application

# Development
npm run start:dev

# Production
npm run build
npm run start:prod

The API will be available at http://localhost:32901

API Documentation

API documentation is available via Swagger UI when the application is running:

API Response Format

All API responses follow a standard format:

{
  success: boolean;
  message: string;
  data?: any;           // Present if data exists
  errors?: any;         // Present if errors exist
  statusCode: number;
  timestamp: string;
}

Paginated Responses

Paginated responses include metadata:

{
  success: boolean;
  message: string;
  data: {
    docs: any[];        // Array of results
    meta: {
      total: number;
      page: number;
      limit: number;
      totalPages: number;
      hasNextPage: boolean;
      hasPrevPage: boolean;
    }
  };
  statusCode: number;
  timestamp: string;
}

Authentication

Login Flow

  1. POST /api/v1/web/auth/login or /api/v1/mobile/auth/login

  2. OTP Verification (if phone not verified)

Token Usage

Include the access token in the Authorization header:

Authorization: Bearer <access_token>

Role-Based Access

Modules

Shared Module

Core business logic shared between web and mobile:

Web Module

Web-specific controllers:

Mobile Module

Mobile-specific controllers:

Database

Migrations

Database schema is managed through TypeORM migrations:

Key Tables

See Database README for details.

Development

Code Style

Adding New Features

  1. Create DTOs in src/modules/shared/application/dto/
  2. Create Use Case in src/modules/shared/application/use-cases/[feature]/
  3. Create/Update Repository if needed
  4. Create Controller in src/modules/web/controllers/ and/or src/modules/mobile/controllers/
  5. Register in appropriate module

Testing

# Unit tests
npm run test

# E2E tests
npm run test:e2e

# Test coverage
npm run test:cov

Scripts

# Development
npm run start:dev

# Build
npm run build

# Production
npm run start:prod

# Migrations
npm run migration:run
npm run migration:revert
npm run migration:generate -- -n MigrationName

# Format code
npm run format

# Lint
npm run lint

Key Conventions

Naming Conventions

Response Format

Error Handling

Admin Endpoints

Technology Stack

License

[Your License Here]

Support

For issues and questions, please contact the development team.