# elyes-ghouma/automated-email-order-processing architecture

> Architecture diagram of the GitHub repository elyes-ghouma/automated-email-order-processing, 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/elyes-ghouma/automated-email-order-processing
- Repository: https://github.com/elyes-ghouma/automated-email-order-processing

## Overview

Vectorys Automated Planification turns Gmail messages into logistics orders, using a local LLM to classify intent and extract structured data, then processing Excel attachments and producing Sage WMS output. Operators use the Streamlit interface to monitor runs, maintain client and stocker data, and correct or reprocess uncertain cases. The sampled code shows the UI launching the processing routine and parts of AI analysis, order handling, and Excel generation; several workflow links and capabilities are supported only by the README, so those edges cite it.

Main entry points: [`functions.py`](https://github.com/elyes-ghouma/automated-email-order-processing/blob/main/functions.py) (Order handling), [`main.py`](https://github.com/elyes-ghouma/automated-email-order-processing/blob/main/main.py) (Streamlit dashboard), [`parametres.json`](https://github.com/elyes-ghouma/automated-email-order-processing/blob/main/parametres.json) (Processing configuration), [`templates`](https://github.com/elyes-ghouma/automated-email-order-processing/tree/main/templates) (Prompt and form templates)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ingest["Email Intake"]
  node_mail_intake["Mail retrieval<br/>[functions.py]"]
  node_mail_extract["Mail and attachments<br/>[functions.py]"]
end

subgraph group_processing["Order Processing"]
  node_ai_setup["AI agent setup<br/>[functions.py]"]
  node_mail_analysis["Mail classification<br/>[functions.py]"]
  node_pair_match["Client matching<br/>[functions.py]"]
  node_excel_process["Excel extraction<br/>[functions.py]"]
  node_order_process["Order handling<br/>[functions.py]"]
  node_sage_output["Sage form generation<br/>[functions.py]"]
  node_templates["Prompt and form templates"]
end

subgraph group_review["Operations Interface"]
  node_dashboard["Streamlit dashboard<br/>[main.py]"]
  node_human_review["Manual correction<br/>[main.py]"]
end

subgraph group_data["Local Data"]
  node_config["Processing configuration<br/>[parametres.json]"]
  node_order_store[("Orders and files<br/>[functions.py]")]
  node_registers[("Mail and JSONL registers<br/>[functions.py]")]
end

node_operator(("Operator"))
node_gmail["Gmail inbox"]
node_ollama["Ollama model"]
node_sage["Sage WMS"]

node_operator -->|"runs and reviews"| node_dashboard
node_dashboard -->|"launches processing"| node_mail_intake
node_gmail -->|"provides messages"| node_mail_intake
node_mail_intake -->|"retrieves attachments"| node_mail_extract
node_mail_extract -->|"provides mail content"| node_mail_analysis
node_ai_setup -->|"invokes model"| node_ollama
node_templates -->|"configures prompts"| node_ai_setup
node_mail_analysis -->|"matches client"| node_pair_match
node_mail_analysis -->|"provides extracted data"| node_order_process
node_mail_extract -->|"supplies attachment"| node_excel_process
node_excel_process -->|"provides order data"| node_order_process
node_order_process -->|"generates output"| node_sage_output
node_sage_output -->|"creates WMS files"| node_sage
node_order_process -->|"flags uncertain cases"| node_human_review
node_human_review -->|"corrects and reprocesses"| node_order_process
node_order_process -->|"stores orders"| node_order_store
node_mail_intake -->|"records mail data"| node_registers
node_dashboard -->|"reads and edits records"| node_registers
node_dashboard -->|"updates settings"| node_config
node_order_process -->|"reads processing settings"| node_config

click node_dashboard "https://github.com/elyes-ghouma/automated-email-order-processing/blob/main/main.py"
click node_mail_intake "https://github.com/elyes-ghouma/automated-email-order-processing/blob/main/functions.py"
click node_mail_extract "https://github.com/elyes-ghouma/automated-email-order-processing/blob/main/functions.py"
click node_ai_setup "https://github.com/elyes-ghouma/automated-email-order-processing/blob/main/functions.py"
click node_mail_analysis "https://github.com/elyes-ghouma/automated-email-order-processing/blob/main/functions.py"
click node_pair_match "https://github.com/elyes-ghouma/automated-email-order-processing/blob/main/functions.py"
click node_excel_process "https://github.com/elyes-ghouma/automated-email-order-processing/blob/main/functions.py"
click node_order_process "https://github.com/elyes-ghouma/automated-email-order-processing/blob/main/functions.py"
click node_sage_output "https://github.com/elyes-ghouma/automated-email-order-processing/blob/main/functions.py"
click node_human_review "https://github.com/elyes-ghouma/automated-email-order-processing/blob/main/main.py"
click node_config "https://github.com/elyes-ghouma/automated-email-order-processing/blob/main/parametres.json"
click node_order_store "https://github.com/elyes-ghouma/automated-email-order-processing/blob/main/functions.py"
click node_registers "https://github.com/elyes-ghouma/automated-email-order-processing/blob/main/functions.py"
click node_templates "https://github.com/elyes-ghouma/automated-email-order-processing/tree/main/templates"

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_mail_intake,node_mail_extract toneBlue
class node_ai_setup,node_mail_analysis,node_pair_match,node_excel_process,node_order_process,node_sage_output,node_templates toneAmber
class node_dashboard,node_human_review toneMint
class node_config,node_order_store,node_registers toneRose
class node_operator,node_gmail,node_ollama,node_sage toneIndigo
```

## Components

### Email Intake

- [Mail retrieval](https://github.com/elyes-ghouma/automated-email-order-processing/blob/main/functions.py): `functions.py`
- [Mail and attachments](https://github.com/elyes-ghouma/automated-email-order-processing/blob/main/functions.py): `functions.py`

### Order Processing

- [AI agent setup](https://github.com/elyes-ghouma/automated-email-order-processing/blob/main/functions.py): `functions.py`
- [Mail classification](https://github.com/elyes-ghouma/automated-email-order-processing/blob/main/functions.py): `functions.py`
- [Client matching](https://github.com/elyes-ghouma/automated-email-order-processing/blob/main/functions.py): `functions.py`
- [Excel extraction](https://github.com/elyes-ghouma/automated-email-order-processing/blob/main/functions.py): `functions.py`
- [Order handling](https://github.com/elyes-ghouma/automated-email-order-processing/blob/main/functions.py): `functions.py`
- [Sage form generation](https://github.com/elyes-ghouma/automated-email-order-processing/blob/main/functions.py): `functions.py`
- [Prompt and form templates](https://github.com/elyes-ghouma/automated-email-order-processing/tree/main/templates): `templates`

### Operations Interface

- [Streamlit dashboard](https://github.com/elyes-ghouma/automated-email-order-processing/blob/main/main.py): `main.py`
- [Manual correction](https://github.com/elyes-ghouma/automated-email-order-processing/blob/main/main.py): `main.py`

### Local Data

- [Processing configuration](https://github.com/elyes-ghouma/automated-email-order-processing/blob/main/parametres.json): `parametres.json`
- [Orders and files](https://github.com/elyes-ghouma/automated-email-order-processing/blob/main/functions.py): `functions.py`
- [Mail and JSONL registers](https://github.com/elyes-ghouma/automated-email-order-processing/blob/main/functions.py): `functions.py`

### Other components

- **Operator**
- **Gmail inbox**
- **Ollama model**
- **Sage WMS**

## Connections

- Operator → Streamlit dashboard: runs and reviews (evidence: `README.md`)
- Streamlit dashboard → Mail retrieval: launches processing (evidence: `main.py`)
- Gmail inbox → Mail retrieval: provides messages (evidence: `README.md`)
- Mail retrieval → Mail and attachments: retrieves attachments (evidence: `README.md`)
- Mail and attachments → Mail classification: provides mail content (evidence: `README.md`)
- AI agent setup → Ollama model: invokes model (evidence: `functions.py`)
- Prompt and form templates → AI agent setup: configures prompts (evidence: `README.md`)
- Mail classification → Client matching: matches client (evidence: `functions.py`)
- Mail classification → Order handling: provides extracted data (evidence: `README.md`)
- Mail and attachments → Excel extraction: supplies attachment (evidence: `README.md`)
- Excel extraction → Order handling: provides order data (evidence: `README.md`)
- Order handling → Sage form generation: generates output (evidence: `functions.py`)
- Sage form generation → Sage WMS: creates WMS files (evidence: `README.md`)
- Order handling → Manual correction: flags uncertain cases (evidence: `README.md`)
- Manual correction → Order handling: corrects and reprocesses (evidence: `README.md`)
- Order handling → Orders and files: stores orders (evidence: `README.md`)
- Mail retrieval → Mail and JSONL registers: records mail data (evidence: `README.md`)
- Streamlit dashboard → Mail and JSONL registers: reads and edits records (evidence: `main.py`)
- Streamlit dashboard → Processing configuration: updates settings (evidence: `main.py`)
- Order handling → Processing configuration: reads processing settings (evidence: `functions.py`)
