# rajatdhoot123/indian-courier-api architecture

> Architecture diagram of the GitHub repository rajatdhoot123/indian-courier-api, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-21). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/rajatdhoot123/indian-courier-api
- Repository: https://github.com/rajatdhoot123/indian-courier-api

## Overview

This is a Next.js courier-tracking app and JSON API. A user can enter a carrier and tracking ID in the web UI, but the UI's request path does not match the documented API route, so that connection is not shown as working. The documented API workflow accepts a courier and tracking ID, loads AfterShip's tracking page in a browser, extracts checkpoint data, and returns JSON. The README lists supported carriers; the sampled endpoint uses AfterShip for tracking. The graph separates endpoint handling, browser access, and parsing, though these implementation stages share one source file.

Main entry points: [`pages/index.page.js`](https://github.com/rajatdhoot123/indian-courier-api/blob/main/pages/index.page.js) (Tracking form), [`pages/api/track/[courier]/[trackingId]/index.page.js`](https://github.com/rajatdhoot123/indian-courier-api/blob/main/pages/api/track/%5Bcourier%5D/%5BtrackingId%5D/index.page.js) (Tracking endpoint), [`constants/index.js`](https://github.com/rajatdhoot123/indian-courier-api/blob/main/constants/index.js) (Carrier options)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web interface"]
  node_home["Tracking form<br/>[index.page.js]"]
  node_carrier_options["Carrier options<br/>[index.js]"]
  node_tracking_table["Results table<br/>[index.page.js]"]
  node_failure_message["Failure message<br/>[index.page.js]"]
  node_api_client["API caller<br/>[index.page.js]"]
end

subgraph group_tracking["Tracking API"]
  node_route["Tracking endpoint<br/>[index.page.js]"]
  node_json_response["JSON result<br/>[index.page.js]"]
end

subgraph group_runtime["Tracking runtime"]
  node_page_setup["Browser page setup<br/>[index.page.js]"]
  node_browser["Headless browser"]
  node_checkpoint_extract["Checkpoint extraction<br/>[index.page.js]"]
  node_html_parser["HTML parser<br/>[index.page.js]"]
end

node_user(("Tracking user"))
node_api_user(("API consumer"))
node_aftership["AfterShip tracking"]

node_user -->|"enters tracking"| node_home
node_home -->|"renders choices"| node_carrier_options
node_home -->|"submits lookup"| node_api_client
node_api_client -.-> node_route
node_home -->|"renders results"| node_tracking_table
node_home -->|"renders failure"| node_failure_message
node_api_user -->|"requests tracking"| node_route
node_route -->|"creates page"| node_page_setup
node_page_setup -->|"launches browser"| node_browser
node_page_setup -->|"navigates to"| node_aftership
node_route -->|"reads page content"| node_checkpoint_extract
node_checkpoint_extract -->|"parses HTML"| node_html_parser
node_route -->|"returns JSON"| node_json_response

click node_home "https://github.com/rajatdhoot123/indian-courier-api/blob/main/pages/index.page.js"
click node_carrier_options "https://github.com/rajatdhoot123/indian-courier-api/blob/main/constants/index.js"
click node_tracking_table "https://github.com/rajatdhoot123/indian-courier-api/blob/main/pages/index.page.js"
click node_failure_message "https://github.com/rajatdhoot123/indian-courier-api/blob/main/pages/index.page.js"
click node_api_client "https://github.com/rajatdhoot123/indian-courier-api/blob/main/pages/index.page.js"
click node_route "https://github.com/rajatdhoot123/indian-courier-api/blob/main/pages/api/track/%5Bcourier%5D/%5BtrackingId%5D/index.page.js"
click node_page_setup "https://github.com/rajatdhoot123/indian-courier-api/blob/main/pages/api/track/%5Bcourier%5D/%5BtrackingId%5D/index.page.js"
click node_checkpoint_extract "https://github.com/rajatdhoot123/indian-courier-api/blob/main/pages/api/track/%5Bcourier%5D/%5BtrackingId%5D/index.page.js"
click node_html_parser "https://github.com/rajatdhoot123/indian-courier-api/blob/main/pages/api/track/%5Bcourier%5D/%5BtrackingId%5D/index.page.js"
click node_json_response "https://github.com/rajatdhoot123/indian-courier-api/blob/main/pages/api/track/%5Bcourier%5D/%5BtrackingId%5D/index.page.js"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_home,node_carrier_options,node_tracking_table,node_failure_message,node_api_client,node_user toneBlue
class node_route,node_json_response toneAmber
class node_page_setup,node_browser,node_checkpoint_extract,node_html_parser,node_api_user toneMint
class node_aftership toneIndigo
```

## Components

### Web interface

- [Tracking form](https://github.com/rajatdhoot123/indian-courier-api/blob/main/pages/index.page.js): `pages/index.page.js`
- [Carrier options](https://github.com/rajatdhoot123/indian-courier-api/blob/main/constants/index.js): `constants/index.js`
- [Results table](https://github.com/rajatdhoot123/indian-courier-api/blob/main/pages/index.page.js): `pages/index.page.js`
- [Failure message](https://github.com/rajatdhoot123/indian-courier-api/blob/main/pages/index.page.js): `pages/index.page.js`
- [API caller](https://github.com/rajatdhoot123/indian-courier-api/blob/main/pages/index.page.js): `pages/index.page.js`

### Tracking API

- [Tracking endpoint](https://github.com/rajatdhoot123/indian-courier-api/blob/main/pages/api/track/%5Bcourier%5D/%5BtrackingId%5D/index.page.js): `pages/api/track/[courier]/[trackingId]/index.page.js`
- [JSON result](https://github.com/rajatdhoot123/indian-courier-api/blob/main/pages/api/track/%5Bcourier%5D/%5BtrackingId%5D/index.page.js): `pages/api/track/[courier]/[trackingId]/index.page.js`

### Tracking runtime

- [Browser page setup](https://github.com/rajatdhoot123/indian-courier-api/blob/main/pages/api/track/%5Bcourier%5D/%5BtrackingId%5D/index.page.js): `pages/api/track/[courier]/[trackingId]/index.page.js`
- **Headless browser**
- [Checkpoint extraction](https://github.com/rajatdhoot123/indian-courier-api/blob/main/pages/api/track/%5Bcourier%5D/%5BtrackingId%5D/index.page.js): `pages/api/track/[courier]/[trackingId]/index.page.js`
- [HTML parser](https://github.com/rajatdhoot123/indian-courier-api/blob/main/pages/api/track/%5Bcourier%5D/%5BtrackingId%5D/index.page.js): `pages/api/track/[courier]/[trackingId]/index.page.js`

### Other components

- **Tracking user**
- **API consumer**
- **AfterShip tracking**

## Connections

- Tracking user → Tracking form: enters tracking (evidence: `pages/index.page.js`)
- Tracking form → Carrier options: renders choices (evidence: `pages/index.page.js`)
- Tracking form → API caller: submits lookup (evidence: `pages/index.page.js`)
- API caller → Tracking endpoint
- Tracking form → Results table: renders results (evidence: `pages/index.page.js`)
- Tracking form → Failure message: renders failure (evidence: `pages/index.page.js`)
- API consumer → Tracking endpoint: requests tracking (evidence: `README.md`)
- Tracking endpoint → Browser page setup: creates page (evidence: `pages/api/track/[courier]/[trackingId]/index.page.js`)
- Browser page setup → Headless browser: launches browser (evidence: `pages/api/track/[courier]/[trackingId]/index.page.js`)
- Browser page setup → AfterShip tracking: navigates to (evidence: `pages/api/track/[courier]/[trackingId]/index.page.js`)
- Tracking endpoint → Checkpoint extraction: reads page content (evidence: `pages/api/track/[courier]/[trackingId]/index.page.js`)
- Checkpoint extraction → HTML parser: parses HTML (evidence: `pages/api/track/[courier]/[trackingId]/index.page.js`)
- Tracking endpoint → JSON result: returns JSON (evidence: `pages/api/track/[courier]/[trackingId]/index.page.js`)
