# rkv762/setuhaul-fde-logistics-agent architecture

> Architecture diagram of the GitHub repository rkv762/setuhaul-fde-logistics-agent, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/rkv762/setuhaul-fde-logistics-agent
- Repository: https://github.com/rkv762/setuhaul-fde-logistics-agent

## Overview

SetuHaul is a conversational freight-exception service: a driver reports a delay or asks about a slot, the conversation engine parses and clarifies the message, then deterministic business rules check feasibility and manage holds or appointments against the supplied SQLite snapshot. The public demo adds an authenticated HTTP front door and AgentCore session wrapper; operational features include driver authentication, GPS check-ins, human escalation, audit logging, and an optional facility-wide scheduler. Edges reflect excerpted calls or README statements; unsampled UI and implementation details are not inferred.

Main entry points: [`src/setuhaul/conversation.py`](https://github.com/rkv762/setuhaul-fde-logistics-agent/blob/master/src/setuhaul/conversation.py) (Conversation engine), [`agentcore_app.py`](https://github.com/rkv762/setuhaul-fde-logistics-agent/blob/master/agentcore_app.py) (Session API), [`src/setuhaul/tools.py`](https://github.com/rkv762/setuhaul-fde-logistics-agent/blob/master/src/setuhaul/tools.py) (Capacity tools), [`src/setuhaul/scheduler_tool.py`](https://github.com/rkv762/setuhaul-fde-logistics-agent/blob/master/src/setuhaul/scheduler_tool.py) (Facility scheduler)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interfaces["Public interfaces"]
  node_front_door["HTTP front door<br/>[lambda_function.py]"]
  node_agentcore["Session API<br/>[agentcore_app.py]"]
end

subgraph group_conversation["Conversation handling"]
  node_conversation_engine["Conversation engine<br/>[conversation.py]"]
  node_message_parser["Message parser<br/>[nlu.py]"]
  node_llm_fallback["LLM fallback<br/>[llm_fallback.py]"]
end

subgraph group_operations["Freight operations"]
  node_business_tools["Capacity tools<br/>[tools.py]"]
  node_facility_scheduler["Facility scheduler<br/>[scheduler_tool.py]"]
  node_sim_clock["Simulated clock<br/>[clock.py]"]
  node_session_auth["Driver auth and GPS<br/>[agentcore_app.py]"]
end

subgraph group_state["State and observability"]
  node_sqlite_snapshot[("Operations database")]
  node_db_access["Database access<br/>[db.py]"]
  node_audit_logs["Structured logging<br/>[applog.py]"]
end

node_driver(("Driver"))
node_openrouter["OpenRouter API"]

node_driver -->|"sends request"| node_front_door
node_front_door -->|"forwards request"| node_agentcore
node_agentcore -->|"handles messages"| node_conversation_engine
node_agentcore -->|"dispatches actions"| node_business_tools
node_agentcore -->|"checks auth"| node_session_auth
node_conversation_engine -->|"parses messages"| node_message_parser
node_conversation_engine -->|"calls tools"| node_business_tools
node_conversation_engine -->|"uses simulated time"| node_sim_clock
node_conversation_engine -.->|"requests fallback"| node_llm_fallback
node_llm_fallback -->|"calls API"| node_openrouter
node_business_tools -->|"queries and updates"| node_db_access
node_db_access -->|"reads and writes"| node_sqlite_snapshot
node_facility_scheduler -->|"reads operations data"| node_sqlite_snapshot
node_facility_scheduler -->|"uses simulated time"| node_sim_clock
node_facility_scheduler -->|"uses scheduling rules"| node_business_tools
node_db_access -->|"emits events"| node_audit_logs
node_conversation_engine -->|"logs turns"| node_audit_logs
node_llm_fallback -->|"logs calls"| node_audit_logs

click node_front_door "https://github.com/rkv762/setuhaul-fde-logistics-agent/blob/master/deploy_front_door/lambda_function.py"
click node_agentcore "https://github.com/rkv762/setuhaul-fde-logistics-agent/blob/master/agentcore_app.py"
click node_conversation_engine "https://github.com/rkv762/setuhaul-fde-logistics-agent/blob/master/src/setuhaul/conversation.py"
click node_message_parser "https://github.com/rkv762/setuhaul-fde-logistics-agent/blob/master/src/setuhaul/nlu.py"
click node_llm_fallback "https://github.com/rkv762/setuhaul-fde-logistics-agent/blob/master/src/setuhaul/llm_fallback.py"
click node_business_tools "https://github.com/rkv762/setuhaul-fde-logistics-agent/blob/master/src/setuhaul/tools.py"
click node_facility_scheduler "https://github.com/rkv762/setuhaul-fde-logistics-agent/blob/master/src/setuhaul/scheduler_tool.py"
click node_sim_clock "https://github.com/rkv762/setuhaul-fde-logistics-agent/blob/master/src/setuhaul/clock.py"
click node_session_auth "https://github.com/rkv762/setuhaul-fde-logistics-agent/blob/master/agentcore_app.py"
click node_sqlite_snapshot "https://github.com/rkv762/setuhaul-fde-logistics-agent/blob/master/data/setuhaul_freight_operations.db"
click node_db_access "https://github.com/rkv762/setuhaul-fde-logistics-agent/blob/master/src/setuhaul/db.py"
click node_audit_logs "https://github.com/rkv762/setuhaul-fde-logistics-agent/blob/master/src/setuhaul/applog.py"

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_front_door,node_agentcore toneBlue
class node_conversation_engine,node_message_parser,node_llm_fallback toneAmber
class node_business_tools,node_facility_scheduler,node_sim_clock,node_session_auth,node_openrouter toneMint
class node_sqlite_snapshot,node_db_access,node_audit_logs toneRose
class node_driver toneIndigo
```

## Components

### Public interfaces

- [HTTP front door](https://github.com/rkv762/setuhaul-fde-logistics-agent/blob/master/deploy_front_door/lambda_function.py): `deploy_front_door/lambda_function.py`
- [Session API](https://github.com/rkv762/setuhaul-fde-logistics-agent/blob/master/agentcore_app.py): `agentcore_app.py`

### Conversation handling

- [Conversation engine](https://github.com/rkv762/setuhaul-fde-logistics-agent/blob/master/src/setuhaul/conversation.py): `src/setuhaul/conversation.py`
- [Message parser](https://github.com/rkv762/setuhaul-fde-logistics-agent/blob/master/src/setuhaul/nlu.py): `src/setuhaul/nlu.py`
- [LLM fallback](https://github.com/rkv762/setuhaul-fde-logistics-agent/blob/master/src/setuhaul/llm_fallback.py): `src/setuhaul/llm_fallback.py`

### Freight operations

- [Capacity tools](https://github.com/rkv762/setuhaul-fde-logistics-agent/blob/master/src/setuhaul/tools.py): `src/setuhaul/tools.py`
- [Facility scheduler](https://github.com/rkv762/setuhaul-fde-logistics-agent/blob/master/src/setuhaul/scheduler_tool.py): `src/setuhaul/scheduler_tool.py`
- [Simulated clock](https://github.com/rkv762/setuhaul-fde-logistics-agent/blob/master/src/setuhaul/clock.py): `src/setuhaul/clock.py`
- [Driver auth and GPS](https://github.com/rkv762/setuhaul-fde-logistics-agent/blob/master/agentcore_app.py): `agentcore_app.py`

### State and observability

- [Operations database](https://github.com/rkv762/setuhaul-fde-logistics-agent/blob/master/data/setuhaul_freight_operations.db): `data/setuhaul_freight_operations.db`
- [Database access](https://github.com/rkv762/setuhaul-fde-logistics-agent/blob/master/src/setuhaul/db.py): `src/setuhaul/db.py`
- [Structured logging](https://github.com/rkv762/setuhaul-fde-logistics-agent/blob/master/src/setuhaul/applog.py): `src/setuhaul/applog.py`

### Other components

- **Driver**
- **OpenRouter API**

## Connections

- Driver → HTTP front door: sends request (evidence: `deploy_front_door/lambda_function.py`)
- HTTP front door → Session API: forwards request (evidence: `deploy_front_door/lambda_function.py`)
- Session API → Conversation engine: handles messages (evidence: `agentcore_app.py`)
- Session API → Capacity tools: dispatches actions (evidence: `agentcore_app.py`)
- Session API → Driver auth and GPS: checks auth (evidence: `agentcore_app.py`)
- Conversation engine → Message parser: parses messages (evidence: `src/setuhaul/conversation.py`)
- Conversation engine → Capacity tools: calls tools (evidence: `src/setuhaul/conversation.py`)
- Conversation engine → Simulated clock: uses simulated time (evidence: `src/setuhaul/conversation.py`)
- Conversation engine → LLM fallback: requests fallback (evidence: `src/setuhaul/conversation.py`)
- LLM fallback → OpenRouter API: calls API (evidence: `src/setuhaul/llm_fallback.py`)
- Capacity tools → Database access: queries and updates (evidence: `src/setuhaul/tools.py`)
- Database access → Operations database: reads and writes (evidence: `src/setuhaul/db.py`)
- Facility scheduler → Operations database: reads operations data (evidence: `src/setuhaul/scheduler_tool.py`)
- Facility scheduler → Simulated clock: uses simulated time (evidence: `src/setuhaul/scheduler_tool.py`)
- Facility scheduler → Capacity tools: uses scheduling rules (evidence: `src/setuhaul/scheduler_tool.py`)
- Database access → Structured logging: emits events (evidence: `src/setuhaul/db.py`)
- Conversation engine → Structured logging: logs turns (evidence: `src/setuhaul/conversation.py`)
- LLM fallback → Structured logging: logs calls (evidence: `src/setuhaul/llm_fallback.py`)
