# joeriqi/invoiceguard-my architecture

> Architecture diagram of the GitHub repository joeriqi/invoiceguard-my, 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/joeriqi/invoiceguard-my
- Repository: https://github.com/joeriqi/invoiceguard-my

## Overview

InvoiceGuard MY is a prototype for Malaysian SME invoice intake and MyInvois pre-submission checks. Its documented workflow generates or loads invoices, extracts structured fields, validates them with deterministic rules, and routes risky cases to human review; evaluation and ROI/EDA support the prototype. Users can explore results in Streamlit or the static dashboard. The tree contains a duplicate `invoiceguard-my/` subtree; this map follows the root-level source files shown in the excerpts. Some dashboard capabilities are documented but its runtime wiring is not sampled.

Main entry points: [`app/streamlit_app.py`](https://github.com/joeriqi/invoiceguard-my/blob/main/app/streamlit_app.py) (Interactive app), [`src/invoiceguard/evaluate.py`](https://github.com/joeriqi/invoiceguard-my/blob/main/src/invoiceguard/evaluate.py) (System evaluation), [`src/invoiceguard/validate.py`](https://github.com/joeriqi/invoiceguard-my/blob/main/src/invoiceguard/validate.py) (Deterministic checks), [`src/invoiceguard/cli.py`](https://github.com/joeriqi/invoiceguard-my/blob/main/src/invoiceguard/cli.py) (Command interface)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_intake["Invoice intake"]
  node_cli["Command interface<br/>[cli.py]"]
  node_corpus["Synthetic invoices<br/>[synth.py]"]
  node_extract["Field extraction<br/>[extract.py]"]
  node_tools["OCR tool discovery<br/>[tools.py]"]
  node_schema["Invoice data model<br/>[schema.py]"]
  node_params["Runtime parameters<br/>[params.yaml]"]
end

subgraph group_checks["Validation and routing"]
  node_rules["Rule catalogue<br/>[rules.yaml]"]
  node_codes["Validation code lists<br/>[codes.py]"]
  node_validate["Deterministic checks<br/>[validate.py]"]
  node_route["Human review routing<br/>[route.py]"]
end

subgraph group_analysis["Evaluation and analysis"]
  node_evaluate["System evaluation<br/>[evaluate.py]"]
  node_eda["Invoice analytics<br/>[eda.py]"]
  node_roi["ROI simulation<br/>[roi.py]"]
end

subgraph group_interfaces["User interfaces"]
  node_streamlit["Interactive app<br/>[streamlit_app.py]"]
  node_dashboard["Static dashboard<br/>[index.html]"]
end

node_user(("SME user"))

node_user -->|"runs commands"| node_cli
node_user -->|"uses app"| node_streamlit
node_user -->|"views results"| node_dashboard
node_cli -->|"generates data"| node_corpus
node_cli -->|"runs extraction"| node_extract
node_cli -->|"runs evaluation"| node_evaluate
node_cli -->|"runs analytics"| node_eda
node_cli -->|"checks tools"| node_tools
node_corpus -->|"uses code lists"| node_codes
node_corpus -->|"uses helpers"| node_tools
node_extract -->|"returns model"| node_schema
node_extract -->|"locates OCR tools"| node_tools
node_validate -->|"checks model"| node_schema
node_validate -->|"checks code lists"| node_codes
node_validate -->|"loads rules"| node_rules
node_route -->|"uses findings"| node_validate
node_route -->|"reads fields"| node_schema
node_evaluate -->|"builds extractions"| node_extract
node_evaluate -->|"loads corpus"| node_corpus
node_evaluate -->|"validates invoices"| node_validate
node_evaluate -->|"routes findings"| node_route
node_evaluate -->|"scores fields"| node_schema
node_eda -->|"loads invoice data"| node_corpus
node_streamlit -->|"recomputes results"| node_evaluate
node_streamlit -->|"loads suppliers"| node_corpus
node_streamlit -->|"reruns checks"| node_validate
node_streamlit -->|"shows decisions"| node_route
node_streamlit -.->|"models ROI"| node_roi
node_streamlit -.->|"presents EDA"| node_eda
node_streamlit -.->|"reads assumptions"| node_params
node_dashboard -.->|"presents metrics"| node_evaluate
node_dashboard -.->|"reruns browser rules"| node_validate
node_dashboard -.->|"offers ROI simulator"| node_roi
node_dashboard -.->|"presents EDA"| node_eda

click node_cli "https://github.com/joeriqi/invoiceguard-my/blob/main/src/invoiceguard/cli.py"
click node_corpus "https://github.com/joeriqi/invoiceguard-my/blob/main/src/invoiceguard/synth.py"
click node_extract "https://github.com/joeriqi/invoiceguard-my/blob/main/src/invoiceguard/extract.py"
click node_tools "https://github.com/joeriqi/invoiceguard-my/blob/main/src/invoiceguard/tools.py"
click node_schema "https://github.com/joeriqi/invoiceguard-my/blob/main/src/invoiceguard/schema.py"
click node_rules "https://github.com/joeriqi/invoiceguard-my/blob/main/config/rules.yaml"
click node_codes "https://github.com/joeriqi/invoiceguard-my/blob/main/src/invoiceguard/codes.py"
click node_validate "https://github.com/joeriqi/invoiceguard-my/blob/main/src/invoiceguard/validate.py"
click node_route "https://github.com/joeriqi/invoiceguard-my/blob/main/src/invoiceguard/route.py"
click node_evaluate "https://github.com/joeriqi/invoiceguard-my/blob/main/src/invoiceguard/evaluate.py"
click node_eda "https://github.com/joeriqi/invoiceguard-my/blob/main/src/invoiceguard/eda.py"
click node_roi "https://github.com/joeriqi/invoiceguard-my/blob/main/src/invoiceguard/roi.py"
click node_streamlit "https://github.com/joeriqi/invoiceguard-my/blob/main/app/streamlit_app.py"
click node_dashboard "https://github.com/joeriqi/invoiceguard-my/blob/main/dashboard/dist/index.html"
click node_params "https://github.com/joeriqi/invoiceguard-my/blob/main/config/params.yaml"

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_cli,node_corpus,node_extract,node_tools,node_schema,node_params,node_user toneBlue
class node_rules,node_codes,node_validate,node_route toneAmber
class node_evaluate,node_eda,node_roi toneMint
class node_streamlit,node_dashboard toneRose
```

## Components

### Invoice intake

- [Command interface](https://github.com/joeriqi/invoiceguard-my/blob/main/src/invoiceguard/cli.py): `src/invoiceguard/cli.py`
- [Synthetic invoices](https://github.com/joeriqi/invoiceguard-my/blob/main/src/invoiceguard/synth.py): `src/invoiceguard/synth.py`
- [Field extraction](https://github.com/joeriqi/invoiceguard-my/blob/main/src/invoiceguard/extract.py): `src/invoiceguard/extract.py`
- [OCR tool discovery](https://github.com/joeriqi/invoiceguard-my/blob/main/src/invoiceguard/tools.py): `src/invoiceguard/tools.py`
- [Invoice data model](https://github.com/joeriqi/invoiceguard-my/blob/main/src/invoiceguard/schema.py): `src/invoiceguard/schema.py`
- [Runtime parameters](https://github.com/joeriqi/invoiceguard-my/blob/main/config/params.yaml): `config/params.yaml`

### Validation and routing

- [Rule catalogue](https://github.com/joeriqi/invoiceguard-my/blob/main/config/rules.yaml): `config/rules.yaml`
- [Validation code lists](https://github.com/joeriqi/invoiceguard-my/blob/main/src/invoiceguard/codes.py): `src/invoiceguard/codes.py`
- [Deterministic checks](https://github.com/joeriqi/invoiceguard-my/blob/main/src/invoiceguard/validate.py): `src/invoiceguard/validate.py`
- [Human review routing](https://github.com/joeriqi/invoiceguard-my/blob/main/src/invoiceguard/route.py): `src/invoiceguard/route.py`

### Evaluation and analysis

- [System evaluation](https://github.com/joeriqi/invoiceguard-my/blob/main/src/invoiceguard/evaluate.py): `src/invoiceguard/evaluate.py`
- [Invoice analytics](https://github.com/joeriqi/invoiceguard-my/blob/main/src/invoiceguard/eda.py): `src/invoiceguard/eda.py`
- [ROI simulation](https://github.com/joeriqi/invoiceguard-my/blob/main/src/invoiceguard/roi.py): `src/invoiceguard/roi.py`

### User interfaces

- [Interactive app](https://github.com/joeriqi/invoiceguard-my/blob/main/app/streamlit_app.py): `app/streamlit_app.py`
- [Static dashboard](https://github.com/joeriqi/invoiceguard-my/blob/main/dashboard/dist/index.html): `dashboard/dist/index.html`

### Other components

- **SME user**

## Connections

- SME user → Command interface: runs commands (evidence: `README.md`)
- SME user → Interactive app: uses app (evidence: `README.md`)
- SME user → Static dashboard: views results (evidence: `README.md`)
- Command interface → Synthetic invoices: generates data (evidence: `src/invoiceguard/cli.py`)
- Command interface → Field extraction: runs extraction (evidence: `src/invoiceguard/cli.py`)
- Command interface → System evaluation: runs evaluation (evidence: `src/invoiceguard/cli.py`)
- Command interface → Invoice analytics: runs analytics (evidence: `src/invoiceguard/cli.py`)
- Command interface → OCR tool discovery: checks tools (evidence: `src/invoiceguard/cli.py`)
- Synthetic invoices → Validation code lists: uses code lists (evidence: `src/invoiceguard/synth.py`)
- Synthetic invoices → OCR tool discovery: uses helpers (evidence: `src/invoiceguard/synth.py`)
- Field extraction → Invoice data model: returns model (evidence: `src/invoiceguard/extract.py`)
- Field extraction → OCR tool discovery: locates OCR tools (evidence: `src/invoiceguard/extract.py`)
- Deterministic checks → Invoice data model: checks model (evidence: `src/invoiceguard/validate.py`)
- Deterministic checks → Validation code lists: checks code lists (evidence: `src/invoiceguard/validate.py`)
- Deterministic checks → Rule catalogue: loads rules (evidence: `src/invoiceguard/validate.py`)
- Human review routing → Deterministic checks: uses findings (evidence: `src/invoiceguard/route.py`)
- Human review routing → Invoice data model: reads fields (evidence: `src/invoiceguard/route.py`)
- System evaluation → Field extraction: builds extractions (evidence: `src/invoiceguard/evaluate.py`)
- System evaluation → Synthetic invoices: loads corpus (evidence: `src/invoiceguard/evaluate.py`)
- System evaluation → Deterministic checks: validates invoices (evidence: `src/invoiceguard/evaluate.py`)
- System evaluation → Human review routing: routes findings (evidence: `src/invoiceguard/evaluate.py`)
- System evaluation → Invoice data model: scores fields (evidence: `src/invoiceguard/evaluate.py`)
- Invoice analytics → Synthetic invoices: loads invoice data (evidence: `src/invoiceguard/eda.py`)
- Interactive app → System evaluation: recomputes results (evidence: `app/streamlit_app.py`)
- Interactive app → Synthetic invoices: loads suppliers (evidence: `app/streamlit_app.py`)
- Interactive app → Deterministic checks: reruns checks (evidence: `app/streamlit_app.py`)
- Interactive app → Human review routing: shows decisions (evidence: `app/streamlit_app.py`)
- Interactive app → ROI simulation: models ROI (evidence: `README.md`)
- Interactive app → Invoice analytics: presents EDA (evidence: `README.md`)
- Interactive app → Runtime parameters: reads assumptions (evidence: `README.md`)
- Static dashboard → System evaluation: presents metrics (evidence: `README.md`)
- Static dashboard → Deterministic checks: reruns browser rules (evidence: `README.md`)
- Static dashboard → ROI simulation: offers ROI simulator (evidence: `README.md`)
- Static dashboard → Invoice analytics: presents EDA (evidence: `README.md`)
