# noorthistime/idm architecture

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

- Interactive diagram: https://gitdiagram.com/noorthistime/idm
- Repository: https://github.com/noorthistime/idm

## Overview

This is a delivery-operations dashboard and API for creating orders, registering and tracking agents, and assigning deliveries. The visible order workflow collects customer, priority, and location details, resolves an address, and submits an order; assignment and route-sequencing endpoints expose separate dispatch capabilities. The implementation includes a seeded in-memory store and distance-based logic. Some pages and API handlers were not sampled, so their downstream connections are omitted rather than inferred.

Main entry points: [`src/data/database.ts`](https://github.com/noorthistime/idm/blob/main/src/data/database.ts) (In-memory Database), [`idm-dashboard-ui/app/page.tsx`](https://github.com/noorthistime/idm/blob/main/idm-dashboard-ui/app/page.tsx) (Dashboard), [`src/components/CreateOrder.tsx`](https://github.com/noorthistime/idm/blob/main/src/components/CreateOrder.tsx) (Create Order), [`idm-dashboard-ui/app/orders/page.tsx`](https://github.com/noorthistime/idm/blob/main/idm-dashboard-ui/app/orders/page.tsx) (Orders Page)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["Operations UI"]
  node_dashboard["Dashboard<br/>[page.tsx]"]
  node_orders_page["Orders Page<br/>[page.tsx]"]
  node_agents_page["Agents Page<br/>[page.tsx]"]
  node_create_order["Create Order<br/>[CreateOrder.tsx]"]
  node_dispatcher_ui["Order Dispatcher<br/>[Dispatcher.tsx]"]
  node_agent_dashboard["Agent Dashboard<br/>[AgentDashboard.tsx]"]
  node_agent_registration["Agent Registration"]
  node_location_map["Location Map<br/>[LocationMap.tsx]"]
  node_system_map["System Map<br/>[SystemMap.tsx]"]
  node_dashboard_widgets["Dashboard Widgets"]
end

subgraph group_api["HTTP API"]
  node_agents_api["Agent API<br/>[route.ts]"]
  node_agent_detail_api["Agent Update API<br/>[route.ts]"]
  node_assignment_confirm_api["Assignment Confirm API<br/>[route.ts]"]
  node_assignment_recommend_api["Assignment Recommendation API<br/>[route.ts]"]
  node_order_api["Order API<br/>[route.ts]"]
  node_order_detail_api["Order Detail API<br/>[route.ts]"]
  node_route_api["Route Sequence API<br/>[route.ts]"]
end

subgraph group_services["Dispatch Services"]
  node_agent_service["Agent Service<br/>[agent.service.ts]"]
  node_assignment_service["Assignment Service"]
  node_order_service["Order Service<br/>[order.service.ts]"]
  node_route_service["Route Service<br/>[route.service.ts]"]
  node_distance["Distance Calculator<br/>[distance.ts]"]
end

subgraph group_state["Runtime State"]
  node_database[("In-memory Database<br/>[database.ts]")]
  node_seed["Initial Data<br/>[seed.ts]"]
end

node_operator(("Dispatcher"))
node_geocoder["Nominatim Geocoder"]

node_operator -.->|"opens"| node_dashboard
node_operator -.->|"opens"| node_orders_page
node_operator -.->|"opens"| node_agents_page
node_dashboard -->|"renders"| node_dashboard_widgets
node_dashboard -->|"fetches agents"| node_agents_api
node_dashboard -->|"fetches orders"| node_order_api
node_orders_page -->|"renders"| node_create_order
node_orders_page -->|"renders"| node_dispatcher_ui
node_agents_page -->|"renders"| node_agent_dashboard
node_agents_page -->|"renders"| node_agent_registration
node_create_order -->|"loads"| node_location_map
node_create_order -->|"resolves address"| node_geocoder
node_create_order -->|"submits order"| node_order_api
node_agents_api -->|"calls"| node_agent_service
node_agent_detail_api -->|"updates agent"| node_agent_service
node_assignment_confirm_api -->|"confirms assignment"| node_assignment_service
node_route_api -->|"gets sequence"| node_route_service
node_agent_service -->|"reads and writes"| node_database
node_assignment_service -->|"reads and updates"| node_database
node_assignment_service -->|"scores distance"| node_distance
node_route_service -->|"reads orders"| node_database
node_route_service -->|"measures distance"| node_distance
node_order_service -->|"uses store"| node_database
node_database -->|"loads initial data"| node_seed

click node_dashboard "https://github.com/noorthistime/idm/blob/main/idm-dashboard-ui/app/page.tsx"
click node_orders_page "https://github.com/noorthistime/idm/blob/main/idm-dashboard-ui/app/orders/page.tsx"
click node_agents_page "https://github.com/noorthistime/idm/blob/main/idm-dashboard-ui/app/agents/page.tsx"
click node_create_order "https://github.com/noorthistime/idm/blob/main/src/components/CreateOrder.tsx"
click node_dispatcher_ui "https://github.com/noorthistime/idm/blob/main/src/components/Dispatcher.tsx"
click node_agent_dashboard "https://github.com/noorthistime/idm/blob/main/src/components/AgentDashboard.tsx"
click node_agent_registration "https://github.com/noorthistime/idm/blob/main/src/components/AgentRegistration.tsx"
click node_location_map "https://github.com/noorthistime/idm/blob/main/src/components/LocationMap.tsx"
click node_system_map "https://github.com/noorthistime/idm/blob/main/src/components/SystemMap.tsx"
click node_dashboard_widgets "https://github.com/noorthistime/idm/tree/main/src/components/dashboard"
click node_agents_api "https://github.com/noorthistime/idm/blob/main/src/app/api/agents/route.ts"
click node_agent_detail_api "https://github.com/noorthistime/idm/blob/main/src/app/api/agents/%5Bid%5D/route.ts"
click node_assignment_confirm_api "https://github.com/noorthistime/idm/blob/main/src/app/api/assignment/confirm/route.ts"
click node_assignment_recommend_api "https://github.com/noorthistime/idm/blob/main/src/app/api/assignment/recommend/route.ts"
click node_order_api "https://github.com/noorthistime/idm/blob/main/src/app/api/orders/route.ts"
click node_order_detail_api "https://github.com/noorthistime/idm/blob/main/src/app/api/orders/%5Bid%5D/route.ts"
click node_route_api "https://github.com/noorthistime/idm/blob/main/src/app/api/agents/%5Bid%5D/route-sequence/route.ts"
click node_agent_service "https://github.com/noorthistime/idm/blob/main/src/services/agent.service.ts"
click node_assignment_service "https://github.com/noorthistime/idm/blob/main/src/services/assignment.service.ts"
click node_order_service "https://github.com/noorthistime/idm/blob/main/src/services/order.service.ts"
click node_route_service "https://github.com/noorthistime/idm/blob/main/src/services/route.service.ts"
click node_distance "https://github.com/noorthistime/idm/blob/main/src/utils/distance.ts"
click node_database "https://github.com/noorthistime/idm/blob/main/src/data/database.ts"
click node_seed "https://github.com/noorthistime/idm/blob/main/src/data/seed.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_dashboard,node_orders_page,node_agents_page,node_create_order,node_dispatcher_ui,node_agent_dashboard,node_agent_registration,node_location_map,node_system_map,node_dashboard_widgets toneBlue
class node_agents_api,node_agent_detail_api,node_assignment_confirm_api,node_assignment_recommend_api,node_order_api,node_order_detail_api,node_route_api toneAmber
class node_agent_service,node_assignment_service,node_order_service,node_route_service,node_distance toneMint
class node_database,node_seed toneRose
class node_operator,node_geocoder toneIndigo
```

## Components

### Operations UI

- [Dashboard](https://github.com/noorthistime/idm/blob/main/idm-dashboard-ui/app/page.tsx): `idm-dashboard-ui/app/page.tsx`
- [Orders Page](https://github.com/noorthistime/idm/blob/main/idm-dashboard-ui/app/orders/page.tsx): `idm-dashboard-ui/app/orders/page.tsx`
- [Agents Page](https://github.com/noorthistime/idm/blob/main/idm-dashboard-ui/app/agents/page.tsx): `idm-dashboard-ui/app/agents/page.tsx`
- [Create Order](https://github.com/noorthistime/idm/blob/main/src/components/CreateOrder.tsx): `src/components/CreateOrder.tsx`
- [Order Dispatcher](https://github.com/noorthistime/idm/blob/main/src/components/Dispatcher.tsx): `src/components/Dispatcher.tsx`
- [Agent Dashboard](https://github.com/noorthistime/idm/blob/main/src/components/AgentDashboard.tsx): `src/components/AgentDashboard.tsx`
- [Agent Registration](https://github.com/noorthistime/idm/blob/main/src/components/AgentRegistration.tsx): `src/components/AgentRegistration.tsx`
- [Location Map](https://github.com/noorthistime/idm/blob/main/src/components/LocationMap.tsx): `src/components/LocationMap.tsx`
- [System Map](https://github.com/noorthistime/idm/blob/main/src/components/SystemMap.tsx): `src/components/SystemMap.tsx`
- [Dashboard Widgets](https://github.com/noorthistime/idm/tree/main/src/components/dashboard): `src/components/dashboard`

### HTTP API

- [Agent API](https://github.com/noorthistime/idm/blob/main/src/app/api/agents/route.ts): `src/app/api/agents/route.ts`
- [Agent Update API](https://github.com/noorthistime/idm/blob/main/src/app/api/agents/%5Bid%5D/route.ts): `src/app/api/agents/[id]/route.ts`
- [Assignment Confirm API](https://github.com/noorthistime/idm/blob/main/src/app/api/assignment/confirm/route.ts): `src/app/api/assignment/confirm/route.ts`
- [Assignment Recommendation API](https://github.com/noorthistime/idm/blob/main/src/app/api/assignment/recommend/route.ts): `src/app/api/assignment/recommend/route.ts`
- [Order API](https://github.com/noorthistime/idm/blob/main/src/app/api/orders/route.ts): `src/app/api/orders/route.ts`
- [Order Detail API](https://github.com/noorthistime/idm/blob/main/src/app/api/orders/%5Bid%5D/route.ts): `src/app/api/orders/[id]/route.ts`
- [Route Sequence API](https://github.com/noorthistime/idm/blob/main/src/app/api/agents/%5Bid%5D/route-sequence/route.ts): `src/app/api/agents/[id]/route-sequence/route.ts`

### Dispatch Services

- [Agent Service](https://github.com/noorthistime/idm/blob/main/src/services/agent.service.ts): `src/services/agent.service.ts`
- [Assignment Service](https://github.com/noorthistime/idm/blob/main/src/services/assignment.service.ts): `src/services/assignment.service.ts`
- [Order Service](https://github.com/noorthistime/idm/blob/main/src/services/order.service.ts): `src/services/order.service.ts`
- [Route Service](https://github.com/noorthistime/idm/blob/main/src/services/route.service.ts): `src/services/route.service.ts`
- [Distance Calculator](https://github.com/noorthistime/idm/blob/main/src/utils/distance.ts): `src/utils/distance.ts`

### Runtime State

- [In-memory Database](https://github.com/noorthistime/idm/blob/main/src/data/database.ts): `src/data/database.ts`
- [Initial Data](https://github.com/noorthistime/idm/blob/main/src/data/seed.ts): `src/data/seed.ts`

### Other components

- **Dispatcher**
- **Nominatim Geocoder**

## Connections

- Dispatcher → Dashboard: opens
- Dispatcher → Orders Page: opens
- Dispatcher → Agents Page: opens
- Dashboard → Dashboard Widgets: renders (evidence: `idm-dashboard-ui/app/page.tsx`)
- Dashboard → Agent API: fetches agents (evidence: `idm-dashboard-ui/app/page.tsx`)
- Dashboard → Order API: fetches orders (evidence: `idm-dashboard-ui/app/page.tsx`)
- Orders Page → Create Order: renders (evidence: `idm-dashboard-ui/app/orders/page.tsx`)
- Orders Page → Order Dispatcher: renders (evidence: `idm-dashboard-ui/app/orders/page.tsx`)
- Agents Page → Agent Dashboard: renders (evidence: `idm-dashboard-ui/app/agents/page.tsx`)
- Agents Page → Agent Registration: renders (evidence: `idm-dashboard-ui/app/agents/page.tsx`)
- Create Order → Location Map: loads (evidence: `src/components/CreateOrder.tsx`)
- Create Order → Nominatim Geocoder: resolves address (evidence: `src/components/CreateOrder.tsx`)
- Create Order → Order API: submits order (evidence: `src/components/CreateOrder.tsx`)
- Agent API → Agent Service: calls (evidence: `src/app/api/agents/route.ts`)
- Agent Update API → Agent Service: updates agent (evidence: `src/app/api/agents/[id]/route.ts`)
- Assignment Confirm API → Assignment Service: confirms assignment (evidence: `src/app/api/assignment/confirm/route.ts`)
- Route Sequence API → Route Service: gets sequence (evidence: `src/app/api/agents/[id]/route-sequence/route.ts`)
- Agent Service → In-memory Database: reads and writes (evidence: `src/services/agent.service.ts`)
- Assignment Service → In-memory Database: reads and updates (evidence: `src/services/assignment.service.ts`)
- Assignment Service → Distance Calculator: scores distance (evidence: `src/services/assignment.service.ts`)
- Route Service → In-memory Database: reads orders (evidence: `src/services/route.service.ts`)
- Route Service → Distance Calculator: measures distance (evidence: `src/services/route.service.ts`)
- Order Service → In-memory Database: uses store (evidence: `src/services/order.service.ts`)
- In-memory Database → Initial Data: loads initial data (evidence: `src/data/database.ts`)
