# anush273/meridian-support-draft-agent architecture

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

- Interactive diagram: https://gitdiagram.com/anush273/meridian-support-draft-agent
- Repository: https://github.com/anush273/meridian-support-draft-agent

## Overview

Meridian is a small CLI tool that prepares a support-reply draft for one fictional case and prints it for human review; it does not take action on the customer’s behalf. The workflow selects a case, assembles facts and policy instructions, applies deterministic checks, optionally calls a configured model, validates the result, and prints it. Its key branches include local Ollama and cloud OpenRouter backends, prerecorded offline demos, and a safe unavailable result. Relationships not visible in the sampled source are based on README descriptions.

Main entry points: [`app.py`](https://github.com/anush273/meridian-support-draft-agent/blob/main/app.py) (CLI and orchestration), [`setup_env.py`](https://github.com/anush273/meridian-support-draft-agent/blob/main/setup_env.py) (Interactive setup), [`cases.json`](https://github.com/anush273/meridian-support-draft-agent/blob/main/cases.json) (Support cases), [`task.md`](https://github.com/anush273/meridian-support-draft-agent/blob/main/task.md) (Drafting task)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_cli["CLI and review"]
  node_app["CLI and orchestration<br/>[app.py]"]
end

subgraph group_context["Case and policy context"]
  node_cases["Support cases<br/>[cases.json]"]
  node_task["Drafting task<br/>[task.md]"]
  node_definitions["Term definitions<br/>[definitions.md]"]
  node_contract["Output contract"]
  node_policy["Business policy<br/>[policy.md]"]
  node_evidence["Evidence map<br/>[evidence_map.json]"]
end

subgraph group_resolution["Draft resolution"]
  node_resolver["Deterministic checks<br/>[app.py]"]
  node_backend["Backend selection<br/>[app.py]"]
  node_validation["Response validation<br/>[app.py]"]
  node_unavailable["Safe unavailable result<br/>[app.py]"]
  node_demo["Offline demo results<br/>[demo_outputs.json]"]
end

subgraph group_configuration["Backend configuration"]
  node_setup["Interactive setup<br/>[setup_env.py]"]
  node_envexample["Backend settings example<br/>[.env.example]"]
end

node_reviewer(("Human reviewer"))
node_terminal["Terminal"]
node_ollama["Ollama model service"]
node_openrouter["OpenRouter service"]

node_reviewer -->|"selects case"| node_app
node_app -->|"loads case"| node_cases
node_app -->|"loads and adapts"| node_task
node_app -->|"loads context"| node_definitions
node_app -->|"loads contract"| node_contract
node_app -->|"loads policy"| node_policy
node_app -->|"loads and checks"| node_evidence
node_app -->|"resolves case"| node_resolver
node_resolver -->|"calls when needed"| node_backend
node_backend -->|"calls model"| node_ollama
node_backend -->|"calls model"| node_openrouter
node_app -->|"loads in demo mode"| node_demo
node_app -->|"validates response"| node_validation
node_validation -->|"falls back on failure"| node_unavailable
node_resolver -->|"returns on failure"| node_unavailable
node_app -->|"prints sections"| node_terminal
node_terminal -->|"shows draft"| node_reviewer
node_reviewer -->|"configures backend"| node_setup
node_setup -->|"uses settings"| node_envexample

click node_app "https://github.com/anush273/meridian-support-draft-agent/blob/main/app.py"
click node_cases "https://github.com/anush273/meridian-support-draft-agent/blob/main/cases.json"
click node_task "https://github.com/anush273/meridian-support-draft-agent/blob/main/task.md"
click node_definitions "https://github.com/anush273/meridian-support-draft-agent/blob/main/definitions.md"
click node_contract "https://github.com/anush273/meridian-support-draft-agent/blob/main/contractDefinitions.md"
click node_policy "https://github.com/anush273/meridian-support-draft-agent/blob/main/policy.md"
click node_evidence "https://github.com/anush273/meridian-support-draft-agent/blob/main/evidence_map.json"
click node_resolver "https://github.com/anush273/meridian-support-draft-agent/blob/main/app.py"
click node_backend "https://github.com/anush273/meridian-support-draft-agent/blob/main/app.py"
click node_validation "https://github.com/anush273/meridian-support-draft-agent/blob/main/app.py"
click node_unavailable "https://github.com/anush273/meridian-support-draft-agent/blob/main/app.py"
click node_demo "https://github.com/anush273/meridian-support-draft-agent/blob/main/demo_outputs.json"
click node_setup "https://github.com/anush273/meridian-support-draft-agent/blob/main/setup_env.py"
click node_envexample "https://github.com/anush273/meridian-support-draft-agent/blob/main/.env.example"

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_app,node_reviewer toneBlue
class node_cases,node_task,node_definitions,node_contract,node_policy,node_evidence toneAmber
class node_resolver,node_backend,node_validation,node_unavailable,node_demo,node_openrouter toneMint
class node_setup,node_envexample toneRose
class node_terminal,node_ollama toneIndigo
```

## Components

### CLI and review

- [CLI and orchestration](https://github.com/anush273/meridian-support-draft-agent/blob/main/app.py): `app.py`

### Case and policy context

- [Support cases](https://github.com/anush273/meridian-support-draft-agent/blob/main/cases.json): `cases.json`
- [Drafting task](https://github.com/anush273/meridian-support-draft-agent/blob/main/task.md): `task.md`
- [Term definitions](https://github.com/anush273/meridian-support-draft-agent/blob/main/definitions.md): `definitions.md`
- [Output contract](https://github.com/anush273/meridian-support-draft-agent/blob/main/contractDefinitions.md): `contractDefinitions.md`
- [Business policy](https://github.com/anush273/meridian-support-draft-agent/blob/main/policy.md): `policy.md`
- [Evidence map](https://github.com/anush273/meridian-support-draft-agent/blob/main/evidence_map.json): `evidence_map.json`

### Draft resolution

- [Deterministic checks](https://github.com/anush273/meridian-support-draft-agent/blob/main/app.py): `app.py`
- [Backend selection](https://github.com/anush273/meridian-support-draft-agent/blob/main/app.py): `app.py`
- [Response validation](https://github.com/anush273/meridian-support-draft-agent/blob/main/app.py): `app.py`
- [Safe unavailable result](https://github.com/anush273/meridian-support-draft-agent/blob/main/app.py): `app.py`
- [Offline demo results](https://github.com/anush273/meridian-support-draft-agent/blob/main/demo_outputs.json): `demo_outputs.json`

### Backend configuration

- [Interactive setup](https://github.com/anush273/meridian-support-draft-agent/blob/main/setup_env.py): `setup_env.py`
- [Backend settings example](https://github.com/anush273/meridian-support-draft-agent/blob/main/.env.example): `.env.example`

### Other components

- **Human reviewer**
- **Terminal**
- **Ollama model service**
- **OpenRouter service**

## Connections

- Human reviewer → CLI and orchestration: selects case (evidence: `README.md`)
- CLI and orchestration → Support cases: loads case (evidence: `README.md`)
- CLI and orchestration → Drafting task: loads and adapts (evidence: `README.md`)
- CLI and orchestration → Term definitions: loads context (evidence: `README.md`)
- CLI and orchestration → Output contract: loads contract (evidence: `README.md`)
- CLI and orchestration → Business policy: loads policy (evidence: `README.md`)
- CLI and orchestration → Evidence map: loads and checks (evidence: `README.md`)
- CLI and orchestration → Deterministic checks: resolves case (evidence: `README.md`)
- Deterministic checks → Backend selection: calls when needed (evidence: `README.md`)
- Backend selection → Ollama model service: calls model (evidence: `README.md`)
- Backend selection → OpenRouter service: calls model (evidence: `README.md`)
- CLI and orchestration → Offline demo results: loads in demo mode (evidence: `README.md`)
- CLI and orchestration → Response validation: validates response (evidence: `app.py`)
- Response validation → Safe unavailable result: falls back on failure (evidence: `README.md`)
- Deterministic checks → Safe unavailable result: returns on failure (evidence: `README.md`)
- CLI and orchestration → Terminal: prints sections (evidence: `README.md`)
- Terminal → Human reviewer: shows draft (evidence: `README.md`)
- Human reviewer → Interactive setup: configures backend (evidence: `README.md`)
- Interactive setup → Backend settings example: uses settings (evidence: `README.md`)
