# oaksat/cooranadination architecture

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

- Interactive diagram: https://gitdiagram.com/oaksat/cooranadination
- Repository: https://github.com/oaksat/cooranadination

## Overview

AI Freight Coordination turns inbound multilingual beer-shipment emails into validated, planned, quoted and—after explicit approval—booked freight orders. The principal flow runs from email ingestion through a per-order Step Functions workflow, with customer clarification and representative review as human gates. DynamoDB-backed persistence and an outbox support durable state and outbound mail. The README documents the end-to-end stages and AWS services; source excerpts and the index clarify selected implementation ownership, but several workflow and API details are not sampled.

Main entry points: [`src/freight/workflow/steps.py`](https://github.com/oaksat/cooranadination/blob/main/src/freight/workflow/steps.py) (Workflow steps), [`src/freight/workflow/graph.py`](https://github.com/oaksat/cooranadination/blob/main/src/freight/workflow/graph.py) (Order execution), [`infra/stacks/storage_stack.py`](https://github.com/oaksat/cooranadination/blob/main/infra/stacks/storage_stack.py) (Inbound S3), [`src/freight/handlers/ingest.py`](https://github.com/oaksat/cooranadination/blob/main/src/freight/handlers/ingest.py) (Ingest handler)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ingestion["Email intake"]
  node_s3[("Inbound S3<br/>[storage_stack.py]")]
  node_sqs["Ingest queue<br/>[storage_stack.py]"]
  node_ingest_handler["Ingest handler<br/>[ingest.py]"]
  node_ingest_logic["Email routing<br/>[ingest.py]"]
  node_email_compose["Email composition<br/>[compose.py]"]
end

subgraph group_workflow["Order workflow"]
  node_state_machine["Order execution<br/>[graph.py]"]
  node_steps["Workflow steps<br/>[steps.py]"]
  node_confirmation["Order confirmation<br/>[steps.py]"]
end

subgraph group_domain["Freight domain"]
  node_extract["Shipment extraction<br/>[extractor.py]"]
  node_validation["Request validation<br/>[rules.py]"]
  node_planning["Cargo planning<br/>[quoting.py]"]
  node_alternatives["Option ranking<br/>[alternatives.py]"]
end

subgraph group_interfaces["Human interfaces"]
  node_dashboard["Rep dashboard<br/>[app.js]"]
  node_rep_api["Rep API<br/>[rep_api.py]"]
  node_choice["Customer choice<br/>[choose.py]"]
  node_links["Signed links<br/>[links.py]"]
end

subgraph group_runtime["Runtime services"]
  node_provider_client["Provider client<br/>[client.py]"]
  node_repo[("Order repository<br/>[repo.py]")]
  node_outbox[("Mail outbox<br/>[outbox.py]")]
  node_outbox_sender["Outbox sender<br/>[outbox_sender.py]"]
end

node_customer(("Customer"))
node_inbound(("Inbound email"))
node_bedrock{{"Bedrock LLM"}}
node_providers{{"Mock freight providers<br/>[mock_app.py]"}}
node_rep(("Sales representative"))
node_ses{{"Amazon SES"}}

node_customer -->|"sends order"| node_inbound
node_inbound -->|"writes email"| node_s3
node_s3 -->|"queues event"| node_sqs
node_sqs -->|"invokes"| node_ingest_handler
node_ingest_handler -->|"routes email"| node_ingest_logic
node_ingest_logic -->|"starts order"| node_state_machine
node_state_machine -->|"dispatches steps"| node_steps
node_steps -->|"extracts details"| node_extract
node_extract -->|"requests language extraction"| node_bedrock
node_steps -->|"validates request"| node_validation
node_steps -->|"drafts questions"| node_email_compose
node_email_compose -->|"asks clarification"| node_customer
node_steps -->|"plans shipment"| node_planning
node_steps -->|"requests quotes"| node_provider_client
node_provider_client -->|"calls providers"| node_providers
node_steps -->|"ranks options"| node_alternatives
node_steps -->|"routes review"| node_rep_api
node_rep_api -->|"serves dashboard"| node_dashboard
node_rep -->|"reviews quote"| node_dashboard
node_steps -->|"creates signed links"| node_links
node_customer -->|"approves option"| node_choice
node_choice -->|"resumes execution"| node_state_machine
node_steps -->|"persists transitions"| node_repo
node_repo -->|"records outgoing mail"| node_outbox
node_outbox -->|"triggers sender"| node_outbox_sender
node_outbox_sender -->|"sends email"| node_ses
node_steps -->|"confirms booking"| node_confirmation
node_confirmation -->|"emails confirmation"| node_customer

click node_s3 "https://github.com/oaksat/cooranadination/blob/main/infra/stacks/storage_stack.py"
click node_sqs "https://github.com/oaksat/cooranadination/blob/main/infra/stacks/storage_stack.py"
click node_ingest_handler "https://github.com/oaksat/cooranadination/blob/main/src/freight/handlers/ingest.py"
click node_ingest_logic "https://github.com/oaksat/cooranadination/blob/main/src/freight/workflow/ingest.py"
click node_state_machine "https://github.com/oaksat/cooranadination/blob/main/src/freight/workflow/graph.py"
click node_steps "https://github.com/oaksat/cooranadination/blob/main/src/freight/workflow/steps.py"
click node_extract "https://github.com/oaksat/cooranadination/blob/main/src/freight/extraction/extractor.py"
click node_validation "https://github.com/oaksat/cooranadination/blob/main/src/freight/domain/rules.py"
click node_email_compose "https://github.com/oaksat/cooranadination/blob/main/src/freight/email/compose.py"
click node_planning "https://github.com/oaksat/cooranadination/blob/main/src/freight/planning/quoting.py"
click node_provider_client "https://github.com/oaksat/cooranadination/blob/main/src/freight/providers/client.py"
click node_providers "https://github.com/oaksat/cooranadination/blob/main/src/freight/providers/mock_app.py"
click node_alternatives "https://github.com/oaksat/cooranadination/blob/main/src/freight/planning/alternatives.py"
click node_dashboard "https://github.com/oaksat/cooranadination/blob/main/src/freight/dashboard/app.js"
click node_rep_api "https://github.com/oaksat/cooranadination/blob/main/src/freight/handlers/rep_api.py"
click node_choice "https://github.com/oaksat/cooranadination/blob/main/src/freight/handlers/choose.py"
click node_links "https://github.com/oaksat/cooranadination/blob/main/src/freight/workflow/links.py"
click node_repo "https://github.com/oaksat/cooranadination/blob/main/src/freight/persistence/repo.py"
click node_outbox "https://github.com/oaksat/cooranadination/blob/main/src/freight/email/outbox.py"
click node_outbox_sender "https://github.com/oaksat/cooranadination/blob/main/src/freight/workflow/outbox_sender.py"
click node_confirmation "https://github.com/oaksat/cooranadination/blob/main/src/freight/workflow/steps.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_s3,node_sqs,node_ingest_handler,node_ingest_logic,node_email_compose toneBlue
class node_state_machine,node_steps,node_confirmation toneAmber
class node_extract,node_validation,node_planning,node_alternatives toneMint
class node_dashboard,node_rep_api,node_choice,node_links toneRose
class node_provider_client,node_repo,node_outbox,node_outbox_sender,node_customer,node_inbound,node_bedrock,node_providers,node_rep,node_ses toneIndigo
```

## Components

### Email intake

- [Inbound S3](https://github.com/oaksat/cooranadination/blob/main/infra/stacks/storage_stack.py): `infra/stacks/storage_stack.py`
- [Ingest queue](https://github.com/oaksat/cooranadination/blob/main/infra/stacks/storage_stack.py): `infra/stacks/storage_stack.py`
- [Ingest handler](https://github.com/oaksat/cooranadination/blob/main/src/freight/handlers/ingest.py): `src/freight/handlers/ingest.py`
- [Email routing](https://github.com/oaksat/cooranadination/blob/main/src/freight/workflow/ingest.py): `src/freight/workflow/ingest.py`
- [Email composition](https://github.com/oaksat/cooranadination/blob/main/src/freight/email/compose.py): `src/freight/email/compose.py`

### Order workflow

- [Order execution](https://github.com/oaksat/cooranadination/blob/main/src/freight/workflow/graph.py): `src/freight/workflow/graph.py`
- [Workflow steps](https://github.com/oaksat/cooranadination/blob/main/src/freight/workflow/steps.py): `src/freight/workflow/steps.py`
- [Order confirmation](https://github.com/oaksat/cooranadination/blob/main/src/freight/workflow/steps.py): `src/freight/workflow/steps.py`

### Freight domain

- [Shipment extraction](https://github.com/oaksat/cooranadination/blob/main/src/freight/extraction/extractor.py): `src/freight/extraction/extractor.py`
- [Request validation](https://github.com/oaksat/cooranadination/blob/main/src/freight/domain/rules.py): `src/freight/domain/rules.py`
- [Cargo planning](https://github.com/oaksat/cooranadination/blob/main/src/freight/planning/quoting.py): `src/freight/planning/quoting.py`
- [Option ranking](https://github.com/oaksat/cooranadination/blob/main/src/freight/planning/alternatives.py): `src/freight/planning/alternatives.py`

### Human interfaces

- [Rep dashboard](https://github.com/oaksat/cooranadination/blob/main/src/freight/dashboard/app.js): `src/freight/dashboard/app.js`
- [Rep API](https://github.com/oaksat/cooranadination/blob/main/src/freight/handlers/rep_api.py): `src/freight/handlers/rep_api.py`
- [Customer choice](https://github.com/oaksat/cooranadination/blob/main/src/freight/handlers/choose.py): `src/freight/handlers/choose.py`
- [Signed links](https://github.com/oaksat/cooranadination/blob/main/src/freight/workflow/links.py): `src/freight/workflow/links.py`

### Runtime services

- [Provider client](https://github.com/oaksat/cooranadination/blob/main/src/freight/providers/client.py): `src/freight/providers/client.py`
- [Order repository](https://github.com/oaksat/cooranadination/blob/main/src/freight/persistence/repo.py): `src/freight/persistence/repo.py`
- [Mail outbox](https://github.com/oaksat/cooranadination/blob/main/src/freight/email/outbox.py): `src/freight/email/outbox.py`
- [Outbox sender](https://github.com/oaksat/cooranadination/blob/main/src/freight/workflow/outbox_sender.py): `src/freight/workflow/outbox_sender.py`

### Other components

- **Customer**
- **Inbound email**
- **Bedrock LLM**
- [Mock freight providers](https://github.com/oaksat/cooranadination/blob/main/src/freight/providers/mock_app.py): `src/freight/providers/mock_app.py`
- **Sales representative**
- **Amazon SES**

## Connections

- Customer → Inbound email: sends order (evidence: `README.md`)
- Inbound email → Inbound S3: writes email (evidence: `README.md`)
- Inbound S3 → Ingest queue: queues event (evidence: `infra/stacks/storage_stack.py`)
- Ingest queue → Ingest handler: invokes
- Ingest handler → Email routing: routes email (evidence: `src/freight/handlers/ingest.py`)
- Email routing → Order execution: starts order (evidence: `src/freight/workflow/ingest.py`)
- Order execution → Workflow steps: dispatches steps (evidence: `README.md`)
- Workflow steps → Shipment extraction: extracts details (evidence: `README.md`)
- Shipment extraction → Bedrock LLM: requests language extraction (evidence: `README.md`)
- Workflow steps → Request validation: validates request (evidence: `README.md`)
- Workflow steps → Email composition: drafts questions (evidence: `README.md`)
- Email composition → Customer: asks clarification (evidence: `README.md`)
- Workflow steps → Cargo planning: plans shipment (evidence: `README.md`)
- Workflow steps → Provider client: requests quotes (evidence: `README.md`)
- Provider client → Mock freight providers: calls providers (evidence: `README.md`)
- Workflow steps → Option ranking: ranks options (evidence: `README.md`)
- Workflow steps → Rep API: routes review (evidence: `README.md`)
- Rep API → Rep dashboard: serves dashboard (evidence: `README.md`)
- Sales representative → Rep dashboard: reviews quote (evidence: `README.md`)
- Workflow steps → Signed links: creates signed links (evidence: `README.md`)
- Customer → Customer choice: approves option (evidence: `README.md`)
- Customer choice → Order execution: resumes execution (evidence: `README.md`)
- Workflow steps → Order repository: persists transitions (evidence: `README.md`)
- Order repository → Mail outbox: records outgoing mail (evidence: `src/freight/persistence/repo.py`)
- Mail outbox → Outbox sender: triggers sender (evidence: `README.md`)
- Outbox sender → Amazon SES: sends email (evidence: `README.md`)
- Workflow steps → Order confirmation: confirms booking (evidence: `README.md`)
- Order confirmation → Customer: emails confirmation (evidence: `README.md`)
