# Overview

**OnDelivery API** (OSAS - OnDelivery Smart Agent System) is a comprehensive multi-courier shipping logistics platform built with Node.js. The system enables:

- **Multi-courier aggregation** - Integrate and manage multiple shipping partners (JNE, Lion Parcel, JT Cargo, AnteRaja, etc.)
- **Real-time package tracking** - Track shipments from pickup to delivery
- **Dynamic pricing** - Calculate shipping fees based on origin, destination, weight, and service type
- **Warehouse operations** - Manage scanning, manifesting, handovers, and quality control
- **Financial management** - Handle billing, commissions, and VIP customer pricing
- **Driver mobile app** - Support delivery drivers with marketplace integration
- **Marketplace integration** - Connect with multiple e-commerce platforms

**Project Name:** ondelivery-api  
**Version:** 1.0.0  
**Main Entry Point:** `ondeliv-backend.js`  
**Default Port:** 4220  
**License:** ISC

---

## Architecture & Technology Stack

### Core Technologies

| Technology | Version | Purpose |
|------------|---------|---------|
| **Node.js** | - | Runtime environment |
| **Express.js** | 5.2.1 | Web application framework |
| **PostgreSQL** | - | Primary database (dual setup: OSAS + ONMART) |
| **Sequelize** | 6.37.7 | ORM for database operations |

### Key Dependencies

**Authentication & Security:**
- `jsonwebtoken` (9.0.2) - JWT token generation and verification
- `passport` (0.7.0) - Authentication middleware
- `passport-http` (0.3.0) - HTTP Basic authentication
- `bcryptjs` (3.0.3) - Password hashing
- `helmet` (8.1.0) - Security headers
- `express-rate-limit` (8.2.1) - Rate limiting protection

**Data Validation & Processing:**
- `ajv` (8.17.1) - JSON schema validation
- `ajv-formats` (3.0.1) - Additional format validators
- `ajv-keywords` (5.1.0) - Extended validation keywords

**HTTP & External APIs:**
- `axios` (1.13.2) - HTTP client for external API calls
- `cors` (2.8.5) - Cross-origin resource sharing

**File Processing:**
- `multer` (2.0.2) - File upload handling
- `sharp` (0.34.5) - Image processing and optimization
- `exceljs` (4.4.0) - Excel file generation
- `pdfmake` (0.2.20) - PDF document generation
- `xlsx` (0.20.3) - Excel file parsing

**Utilities:**
- `moment` (2.30.1) / `dayjs` (1.11.19) - Date/time manipulation
- `lodash` (4.17.21) - Utility functions
- `node-cron` (4.2.1) - Scheduled tasks
- `nodemailer` (7.0.11) - Email sending
- `nanoid` (5.1.6) - Unique ID generation
- `morgan` (1.10.1) - HTTP request logging
- `cli-color` (2.0.4) - Colorized console output