# crtmitchn/courier architecture

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

- Interactive diagram: https://gitdiagram.com/crtmitchn/courier
- Repository: https://github.com/crtmitchn/courier

## Overview

Courier is a TypeScript tray application for tracking parcels through ParcelsApp. On launch it prompts for a tracking number and destination country, then periodically fetches shipment data, compares the latest status with persisted state, notifies on changes, and presents tracking history in the system tray; clicking the tracking number copies it. The sampled entry point owns most runtime behavior, so several components share its path. The excerpts do not show the complete API request or tray event wiring; uncertain links are omitted or marked unverified.

Main entry points: [`src/index.ts`](https://github.com/crtmitchn/courier/blob/master/src/index.ts) (Application cycle), [`src/tracking.json`](https://github.com/crtmitchn/courier/blob/master/src/tracking.json) (Tracking settings), [`src/laststate.json`](https://github.com/crtmitchn/courier/blob/master/src/laststate.json) (Last status), [`src/types.ts`](https://github.com/crtmitchn/courier/blob/master/src/types.ts) (Response types)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interaction["User interaction"]
  node_prompt["Tracking prompt<br/>[index.ts]"]
  node_notification["Desktop notification<br/>[index.ts]"]
  node_tray["Tray display<br/>[index.ts]"]
  node_clipboard["Clipboard copy<br/>[index.ts]"]
end

subgraph group_tracking["Tracking workflow"]
  node_entry["Application cycle<br/>[index.ts]"]
  node_request["Shipment lookup<br/>[index.ts]"]
  node_response_types["Response types<br/>[types.ts]"]
  node_change_check["Status comparison<br/>[index.ts]"]
end

subgraph group_state["Persisted state"]
  node_tracking_config[("Tracking settings<br/>[tracking.json]")]
  node_last_status[("Last status<br/>[laststate.json]")]
end

node_user(("User"))
node_parcelsapp{{"ParcelsApp API"}}

node_user -->|"enters details"| node_prompt
node_entry -->|"requests input"| node_prompt
node_prompt -->|"writes settings"| node_tracking_config
node_entry -->|"starts cycle"| node_request
node_request -->|"reads settings"| node_tracking_config
node_request -.->|"requests tracking"| node_parcelsapp
node_request -->|"returns response"| node_response_types
node_entry -->|"reads status"| node_last_status
node_entry -->|"compares status"| node_change_check
node_change_check -->|"writes changed status"| node_last_status
node_change_check -->|"notifies change"| node_notification
node_entry -->|"displays shipment"| node_tray
node_user -->|"opens tray"| node_tray
node_user -->|"clicks tracking number"| node_clipboard

click node_entry "https://github.com/crtmitchn/courier/blob/master/src/index.ts"
click node_prompt "https://github.com/crtmitchn/courier/blob/master/src/index.ts"
click node_tracking_config "https://github.com/crtmitchn/courier/blob/master/src/tracking.json"
click node_request "https://github.com/crtmitchn/courier/blob/master/src/index.ts"
click node_response_types "https://github.com/crtmitchn/courier/blob/master/src/types.ts"
click node_last_status "https://github.com/crtmitchn/courier/blob/master/src/laststate.json"
click node_change_check "https://github.com/crtmitchn/courier/blob/master/src/index.ts"
click node_notification "https://github.com/crtmitchn/courier/blob/master/src/index.ts"
click node_tray "https://github.com/crtmitchn/courier/blob/master/src/index.ts"
click node_clipboard "https://github.com/crtmitchn/courier/blob/master/src/index.ts"

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_prompt,node_notification,node_tray,node_clipboard,node_user toneBlue
class node_entry,node_request,node_response_types,node_change_check toneAmber
class node_tracking_config,node_last_status,node_parcelsapp toneMint
```

## Components

### User interaction

- [Tracking prompt](https://github.com/crtmitchn/courier/blob/master/src/index.ts): `src/index.ts`
- [Desktop notification](https://github.com/crtmitchn/courier/blob/master/src/index.ts): `src/index.ts`
- [Tray display](https://github.com/crtmitchn/courier/blob/master/src/index.ts): `src/index.ts`
- [Clipboard copy](https://github.com/crtmitchn/courier/blob/master/src/index.ts): `src/index.ts`

### Tracking workflow

- [Application cycle](https://github.com/crtmitchn/courier/blob/master/src/index.ts): `src/index.ts`
- [Shipment lookup](https://github.com/crtmitchn/courier/blob/master/src/index.ts): `src/index.ts`
- [Response types](https://github.com/crtmitchn/courier/blob/master/src/types.ts): `src/types.ts`
- [Status comparison](https://github.com/crtmitchn/courier/blob/master/src/index.ts): `src/index.ts`

### Persisted state

- [Tracking settings](https://github.com/crtmitchn/courier/blob/master/src/tracking.json): `src/tracking.json`
- [Last status](https://github.com/crtmitchn/courier/blob/master/src/laststate.json): `src/laststate.json`

### Other components

- **User**
- **ParcelsApp API**

## Connections

- User → Tracking prompt: enters details (evidence: `README.md`)
- Application cycle → Tracking prompt: requests input (evidence: `src/index.ts`)
- Tracking prompt → Tracking settings: writes settings (evidence: `src/index.ts`)
- Application cycle → Shipment lookup: starts cycle (evidence: `src/index.ts`)
- Shipment lookup → Tracking settings: reads settings (evidence: `src/index.ts`)
- Shipment lookup → ParcelsApp API: requests tracking
- Shipment lookup → Response types: returns response (evidence: `src/index.ts`)
- Application cycle → Last status: reads status (evidence: `src/index.ts`)
- Application cycle → Status comparison: compares status (evidence: `src/index.ts`)
- Status comparison → Last status: writes changed status (evidence: `src/index.ts`)
- Status comparison → Desktop notification: notifies change (evidence: `src/index.ts`)
- Application cycle → Tray display: displays shipment (evidence: `src/index.ts`)
- User → Tray display: opens tray (evidence: `README.md`)
- User → Clipboard copy: clicks tracking number (evidence: `README.md`)
