# rishitsura/optideliver-ai-powered-delivery-optimization-system architecture

> Architecture diagram of the GitHub repository rishitsura/optideliver-ai-powered-delivery-optimization-system, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-25). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/rishitsura/optideliver-ai-powered-delivery-optimization-system
- Repository: https://github.com/rishitsura/optideliver-ai-powered-delivery-optimization-system

## Overview

##### Project Type and Purpose
- This is a full-stack, multi-component delivery management system with three distinct front-end applications (Sender Interface, Postman App, Route Optimization Dashboard), a back-end service to handle orders and user data, and auxiliary data-science assets (Dataset.csv, prediction.ipynb).

##### Top-Level Components (from file tree & README)
A. Sender Interface
- A React + Vite + TypeScript web app (src/, public/, tailwind.config.js, etc.)
- Includes an embedded Node.js server under src/server (Order/User models, Twilio service, server.ts)
B. Postman App
- A standalone React + Leaflet front-end for delivery personnel (project/src/…, .env, .bolt, etc.)
- No dedicated back-end in this folder—presumably uses the same order API
C. Route Optimization Dashboard
- React + Vite app with custom route-optimization utilities (src/utils/route.ts, prediction.ipynb for ML experiments)
D. Data Assets & Pipelines
- Dataset.csv (historical data)
- prediction.ipynb (Jupyter notebook for route-optimization experiments)
E. Shared Resources
- Central Database (e.g., PostgreSQL or MongoDB)
- External services: Twilio (SMS), Map tile & geocoding APIs

##### Relationships and Data Flows
- Sender UI → HTTP REST API → Back-end server → Database (orders, users)
- Back-end server → Twilio API (to send status updates)
- Delivery Agent UI (Postman App) → HTTP REST API → Back-end server → Database (read/write order status)
- Route Dashboard → either
- pulls data via HTTP REST API → Back-end server → Database
- or loads precomputed routes from a micro-service powered by the data-science pipeline
- Data-Science Notebook & scripts read Dataset.csv → train/validate optimization algorithm → export utilities (e.g., src/utils/route.ts) or populate a route-service

##### Architectural Patterns & Design Principles
- Separation of Concerns: Three distinct front-ends, one common back-end API
- Component-based UI (React components / hooks for map, forms, lists)
- MVC / Layered pattern on the server:
- Models: src/server/models
- Services: Twilio, route-calc
- Controllers / server.ts routes
- Utility libraries for shared logic (distance, metrics, route computations)

- Sender Interface
- Postman App
- Route Optimization Dashboard
- Twilio SMS Service
- Tile / Geocoding API
6. Connect:
- Server → Database (“READ/WRITE orders & users”)
- Server → Twilio (“SMS notifications via Twilio SDK”)
- Data-Science → Server or file store (“Push route-optimization utilities/models”)
- Route Dashboard → Server or Route Service (“GET optimized routes”)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Front-end Applications
    subgraph "Sender Interface (Web App)" 
        direction TB
        SI["Sender Interface"]:::frontend
        SI_UTIL1["distance.ts"]:::frontend
        SI_UTIL2["metrics.ts"]:::frontend
    end

    subgraph "Postman App (Delivery UI)"
        direction TB
        PA["Postman App"]:::frontend
        PA_DASH["Dashboard.tsx"]:::frontend
        PA_LIST["DeliveryList.tsx"]:::frontend
        PA_MAP["DeliveryMap Components"]:::frontend
        PA_UTIL1["distance.ts"]:::frontend
        PA_UTIL2["metrics.ts"]:::frontend
    end

    subgraph "Route Optimization Dashboard"
        direction TB
        RD["Route Optimization Dashboard"]:::frontend
        RD_PF["PointForm.tsx"]:::frontend
        RD_RL["RouteLines.tsx"]:::frontend
        RD_RI["RouteInfo.tsx"]:::frontend
        RD_UTIL["route.ts"]:::frontend
    end

    %% Back-end API Server
    subgraph "API Server (Node.js / Express)" 
        direction TB
        Controller["server.ts"]:::backend
        ModelOrder["Order.ts"]:::backend
        ModelUser["User.ts"]:::backend
        ServiceTwilio["twilio.ts"]:::backend
    end

    %% Database and External Services
    DB[(Delivery DB)]:::database
    TW["Twilio SMS Service"]:::external
    MAP["Map Tile & Geocoding API"]:::external

    %% Data-Science Pipeline
    subgraph "Data-Science Pipeline" 
        direction TB
        DS_DATA["Dataset.csv"]:::pipeline
        DS_NOTE["prediction.ipynb"]:::pipeline
    end

    %% Connections
    SI -->|REST API| Controller
    PA -->|REST API| Controller
    RD -->|GET optimized routes| Controller
    Controller -->|CRUD orders & users| DB
    Controller -->|SMS notifications via Twilio SDK| TW
    SI -->|Map services| MAP
    PA -->|Map services| MAP
    DS_NOTE -->|Train/validate models| DS_DATA
    DS_NOTE -->|Exports route utils| RD_UTIL
    DS_NOTE -->|Push route utilities| Controller

    %% Click Events
    click SI "https://github.com/rishitsura/optideliver-ai-powered-delivery-optimization-system/tree/main/Sender-interface/"
    click SI_UTIL1 "https://github.com/rishitsura/optideliver-ai-powered-delivery-optimization-system/blob/main/Sender-interface/src/utils/distance.ts"
    click SI_UTIL2 "https://github.com/rishitsura/optideliver-ai-powered-delivery-optimization-system/blob/main/Sender-interface/src/utils/metrics.ts"
    click Controller "https://github.com/rishitsura/optideliver-ai-powered-delivery-optimization-system/blob/main/Sender-interface/src/server/server.ts"
    click ModelOrder "https://github.com/rishitsura/optideliver-ai-powered-delivery-optimization-system/blob/main/Sender-interface/src/server/models/Order.ts"
    click ModelUser "https://github.com/rishitsura/optideliver-ai-powered-delivery-optimization-system/blob/main/Sender-interface/src/server/models/User.ts"
    click ServiceTwilio "https://github.com/rishitsura/optideliver-ai-powered-delivery-optimization-system/blob/main/Sender-interface/src/server/services/twilio.ts"
    click PA "https://github.com/rishitsura/optideliver-ai-powered-delivery-optimization-system/tree/main/Postman-app/project/"
    click PA_DASH "https://github.com/rishitsura/optideliver-ai-powered-delivery-optimization-system/blob/main/Postman-app/project/src/components/Dashboard.tsx"
    click PA_LIST "https://github.com/rishitsura/optideliver-ai-powered-delivery-optimization-system/blob/main/Postman-app/project/src/components/DeliveryList.tsx"
    click PA_MAP "https://github.com/rishitsura/optideliver-ai-powered-delivery-optimization-system/tree/main/Postman-app/project/src/components/DeliveryMap/"
    click PA_UTIL1 "https://github.com/rishitsura/optideliver-ai-powered-delivery-optimization-system/blob/main/Postman-app/project/src/utils/distance.ts"
    click PA_UTIL2 "https://github.com/rishitsura/optideliver-ai-powered-delivery-optimization-system/blob/main/Postman-app/project/src/utils/metrics.ts"
    click RD_PF "https://github.com/rishitsura/optideliver-ai-powered-delivery-optimization-system/blob/main/Route-optimization-dashboard/route/project/src/components/PointForm.tsx"
    click RD_RL "https://github.com/rishitsura/optideliver-ai-powered-delivery-optimization-system/blob/main/Route-optimization-dashboard/route/project/src/components/RouteLines.tsx"
    click RD_RI "https://github.com/rishitsura/optideliver-ai-powered-delivery-optimization-system/blob/main/Route-optimization-dashboard/route/project/src/components/RouteInfo.tsx"
    click RD_UTIL "https://github.com/rishitsura/optideliver-ai-powered-delivery-optimization-system/blob/main/Route-optimization-dashboard/route/project/src/utils/route.ts"
    click DS_DATA "https://github.com/rishitsura/optideliver-ai-powered-delivery-optimization-system/blob/main/Dataset.csv"
    click DS_NOTE "https://github.com/rishitsura/optideliver-ai-powered-delivery-optimization-system/blob/main/prediction.ipynb"

    %% Styles
    classDef frontend fill:#c2f7b0,stroke:#2d8f0f
    classDef backend fill:#aecbfa,stroke:#1e50a2
    classDef database fill:#78e0e0,stroke:#0f6663
    classDef external fill:#e0e0e0,stroke:#636363
    classDef pipeline fill:#ffd8a8,stroke:#c57b00
```
