# ramk90/llm_complaint_workflow architecture

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

- Interactive diagram: https://gitdiagram.com/ramk90/llm_complaint_workflow
- Repository: https://github.com/ramk90/llm_complaint_workflow

## Overview

This is a complaint-document processing product with CLI and FastAPI entry points. Users submit one file or a directory; orchestration extracts document text, creates validated complaint analysis, drafts a customer email and internal executive summary, then persists per-case artifacts and a consolidated CSV for batches. The graph separates access, workflow, analysis, and outputs. Source excerpts support the main calls and persistence; README documents capabilities and endpoint behavior, while unsampled details are not expanded.

Main entry points: [`src/orchestrator.py`](https://github.com/ramk90/llm_complaint_workflow/blob/main/src/orchestrator.py) (Workflow orchestrator), [`src/chains.py`](https://github.com/ramk90/llm_complaint_workflow/blob/main/src/chains.py) (Structured complaint analysis), [`src/schemas.py`](https://github.com/ramk90/llm_complaint_workflow/blob/main/src/schemas.py) (Validated result schemas), [`main.py`](https://github.com/ramk90/llm_complaint_workflow/blob/main/main.py) (CLI entry)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_access["User access"]
  node_cli["CLI entry<br/>[main.py]"]
  node_api["FastAPI service<br/>[app.py]"]
end

subgraph group_workflow["Workflow control"]
  node_orchestrator["Workflow orchestrator<br/>[orchestrator.py]"]
  node_ingest["File text extraction<br/>[ingest.py]"]
  node_config["Runtime configuration<br/>[config.py]"]
end

subgraph group_analysis["Complaint analysis"]
  node_complaint["Structured complaint analysis<br/>[chains.py]"]
  node_customer_email["Customer email drafting<br/>[chains.py]"]
  node_executive_summary["Executive summary<br/>[chains.py]"]
  node_schemas["Validated result schemas<br/>[schemas.py]"]
end

subgraph group_outputs["Case outputs"]
  node_case_artifacts["Per-case artifacts<br/>[orchestrator.py]"]
  node_csv_report["Batch CSV report<br/>[orchestrator.py]"]
end

node_user(("CLI / API user"))
node_gemini{{"Google Gemini"}}

node_user -->|"runs"| node_cli
node_user -->|"calls"| node_api
node_cli -->|"dispatches"| node_orchestrator
node_api -->|"dispatches"| node_orchestrator
node_orchestrator -->|"extracts text"| node_ingest
node_orchestrator -->|"analyzes text"| node_complaint
node_orchestrator -->|"requests draft"| node_customer_email
node_orchestrator -->|"requests summary"| node_executive_summary
node_orchestrator -->|"writes files"| node_case_artifacts
node_orchestrator -->|"writes report"| node_csv_report
node_orchestrator -->|"uses settings"| node_config
node_complaint -->|"sends prompt"| node_gemini
node_customer_email -->|"sends prompt"| node_gemini
node_executive_summary -->|"sends prompt"| node_gemini
node_complaint -->|"validates as"| node_schemas
node_customer_email -->|"validates as"| node_schemas
node_executive_summary -->|"validates as"| node_schemas

click node_cli "https://github.com/ramk90/llm_complaint_workflow/blob/main/main.py"
click node_api "https://github.com/ramk90/llm_complaint_workflow/blob/main/app.py"
click node_orchestrator "https://github.com/ramk90/llm_complaint_workflow/blob/main/src/orchestrator.py"
click node_ingest "https://github.com/ramk90/llm_complaint_workflow/blob/main/src/ingest.py"
click node_config "https://github.com/ramk90/llm_complaint_workflow/blob/main/src/config.py"
click node_complaint "https://github.com/ramk90/llm_complaint_workflow/blob/main/src/chains.py"
click node_customer_email "https://github.com/ramk90/llm_complaint_workflow/blob/main/src/chains.py"
click node_executive_summary "https://github.com/ramk90/llm_complaint_workflow/blob/main/src/chains.py"
click node_schemas "https://github.com/ramk90/llm_complaint_workflow/blob/main/src/schemas.py"
click node_case_artifacts "https://github.com/ramk90/llm_complaint_workflow/blob/main/src/orchestrator.py"
click node_csv_report "https://github.com/ramk90/llm_complaint_workflow/blob/main/src/orchestrator.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_cli,node_api,node_user toneBlue
class node_orchestrator,node_ingest,node_config toneAmber
class node_complaint,node_customer_email,node_executive_summary,node_schemas toneMint
class node_case_artifacts,node_csv_report toneRose
class node_gemini toneIndigo
```

## Components

### User access

- [CLI entry](https://github.com/ramk90/llm_complaint_workflow/blob/main/main.py): `main.py`
- [FastAPI service](https://github.com/ramk90/llm_complaint_workflow/blob/main/app.py): `app.py`

### Workflow control

- [Workflow orchestrator](https://github.com/ramk90/llm_complaint_workflow/blob/main/src/orchestrator.py): `src/orchestrator.py`
- [File text extraction](https://github.com/ramk90/llm_complaint_workflow/blob/main/src/ingest.py): `src/ingest.py`
- [Runtime configuration](https://github.com/ramk90/llm_complaint_workflow/blob/main/src/config.py): `src/config.py`

### Complaint analysis

- [Structured complaint analysis](https://github.com/ramk90/llm_complaint_workflow/blob/main/src/chains.py): `src/chains.py`
- [Customer email drafting](https://github.com/ramk90/llm_complaint_workflow/blob/main/src/chains.py): `src/chains.py`
- [Executive summary](https://github.com/ramk90/llm_complaint_workflow/blob/main/src/chains.py): `src/chains.py`
- [Validated result schemas](https://github.com/ramk90/llm_complaint_workflow/blob/main/src/schemas.py): `src/schemas.py`

### Case outputs

- [Per-case artifacts](https://github.com/ramk90/llm_complaint_workflow/blob/main/src/orchestrator.py): `src/orchestrator.py`
- [Batch CSV report](https://github.com/ramk90/llm_complaint_workflow/blob/main/src/orchestrator.py): `src/orchestrator.py`

### Other components

- **CLI / API user**
- **Google Gemini**

## Connections

- CLI / API user → CLI entry: runs (evidence: `README.md`)
- CLI / API user → FastAPI service: calls (evidence: `README.md`)
- CLI entry → Workflow orchestrator: dispatches (evidence: `main.py`)
- FastAPI service → Workflow orchestrator: dispatches (evidence: `app.py`)
- Workflow orchestrator → File text extraction: extracts text (evidence: `src/orchestrator.py`)
- Workflow orchestrator → Structured complaint analysis: analyzes text (evidence: `src/orchestrator.py`)
- Workflow orchestrator → Customer email drafting: requests draft (evidence: `src/orchestrator.py`)
- Workflow orchestrator → Executive summary: requests summary (evidence: `src/orchestrator.py`)
- Workflow orchestrator → Per-case artifacts: writes files (evidence: `src/orchestrator.py`)
- Workflow orchestrator → Batch CSV report: writes report (evidence: `src/orchestrator.py`)
- Workflow orchestrator → Runtime configuration: uses settings (evidence: `src/orchestrator.py`)
- Structured complaint analysis → Google Gemini: sends prompt (evidence: `src/chains.py`)
- Customer email drafting → Google Gemini: sends prompt (evidence: `src/chains.py`)
- Executive summary → Google Gemini: sends prompt (evidence: `src/chains.py`)
- Structured complaint analysis → Validated result schemas: validates as (evidence: `src/chains.py`)
- Customer email drafting → Validated result schemas: validates as (evidence: `src/chains.py`)
- Executive summary → Validated result schemas: validates as (evidence: `src/chains.py`)
