# frckeepit/llm-production-toolkit architecture

> Architecture diagram of the GitHub repository frckeepit/llm-production-toolkit, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-04-12). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/frckeepit/llm-production-toolkit
- Repository: https://github.com/frckeepit/llm-production-toolkit

## Overview

1. **Repository shape**
   - This is a Python package, not a service monolith. The source lives under `src/llm_production_toolkit`, with a top-level CLI entrypoint and five domain modules: `hallucination`, `bias`, `feedback`, `readiness`, and `compliance`.

2. **Primary architectural boundary**
   - Each module is independently usable through both a Python API and its own CLI subcommands.
   - The package is designed so teams can adopt just one capability at a time, rather than deploying a single integrated platform.

3. **Shared core layer**
   - `src/llm_production_toolkit/_models.py`, `_utils.py`, and `_version.py` provide package-wide internal support.
   - These files likely hold shared datatypes, helper functions, and version metadata used across the subpackages, while module-specific logic stays isolated.

4. **Hallucination subsystem**
   - `hallucination/evaluator.py` is the main evaluation engine for grounding checks.
   - It compares LLM output against source context and returns structured results via `hallucination/models.py`.
   - The README indicates this is the heaviest ML-oriented module and uses embedding similarity plus NLI entailment, so it is the part with the strongest dependency footprint and the most model-driven behavior.

5. **Bias subsystem**
   - `bias/evaluator.py` orchestrates controlled prompt variation against an injected `llm_callable`.
   - `bias/templates.py` defines the prompt variants, `bias/metrics.py` computes bias-related scores, and `bias/models.py` defines the report/result objects.
   - The data flow is: prompt templates → LLM calls → metric aggregation → report output.

6. **Feedback subsystem**
   - `feedback/collector.py` is the core ingestion/aggregation layer for user feedback events.
   - `feedback/models.py` defines entries and metric outputs, `feedback/metrics.py` computes satisfaction/usage statistics, and `feedback/db.py` persists data.
   - `feedback/app.py` and `feedback/cli.py` indicate two interfaces over the same storage-backed feedback pipeline: a REST server and a local CLI for querying metrics.
   - This module is the clearest runtime service in the repo and appears to depend on FastAPI or similar web-server tooling.

7. **Readiness subsystem**
   - `readiness/assessor.py` performs the production-readiness scoring workflow.
   - `readiness/checklist.py` holds the assessment criteria, and `readiness/models.py` structures scores and recommendations.
   - This is a mostly self-contained, core-dependency module aimed at operational maturity rather than model inference.

8. **Compliance subsystem**
   - `compliance/mapper.py` converts outputs from the other modules into higher-level compliance or best-practice mappings.
   - `compliance/frameworks.py` defines the target frameworks, and `compliance/models.py` structures the report objects.
   - This module acts as an aggregation/interpretation layer rather than a primary evaluator, consuming readiness and hallucination outputs in the examples and README.

9. **Command-line architecture**
   - `src/llm_production_toolkit/cli.py` is the package-level dispatcher, while each subpackage also has its own `cli.py`.
   - This suggests a command hierarchy where the top-level tool routes to domain-specific commands, but each domain can still run independently.
   - The examples in `examples/` mirror this split by showing standalone usage for each subsystem.

10. **Data flow between modules**
   - The typical flow is: raw inputs or LLM outputs enter a domain evaluator, the evaluator produces structured model objects, and those objects can then be summarized or mapped by compliance/reporting tools.
   - Feedback is the only clearly persistent loop: user events are stored in a database, then read back for rolling metrics.
   - Compliance is the cross-cutting consumer of multiple module outputs, while the other modules are mostly parallel and loosely coupled.

11. **Dependency and deployment profile**
   - The README explicitly calls out optional extras: hallucination has heavier ML dependencies, bias has its own text-processing dependency, feedback adds a web server layer, and readiness/compliance stay lightweight.
   - Architecturally, this keeps the core install small and pushes specialized runtime costs only into the modules that need them.

12. **Verification and delivery**
   - `tests/` contains module-specific test files for each major subsystem, which reinforces the repo’s bounded-module design.
   - `.github/workflows/ci.yml` indicates automated CI for package validation, likely running the test suite and linting against the source tree.

13. **How to draw it**
   - A good diagram would show one shared package core feeding five independent modules.
   - Show feedback as the only module with persistence and a server boundary, hallucination/bias as evaluator pipelines, readiness as a checklist/scoring pipeline, and compliance as the downstream mapper that consumes outputs from the others.

Main entry points: [`src/llm_production_toolkit/compliance/mapper.py`](https://github.com/frckeepit/llm-production-toolkit/blob/main/src/llm_production_toolkit/compliance/mapper.py) (Compliance mapper), [`src/llm_production_toolkit/cli.py`](https://github.com/frckeepit/llm-production-toolkit/blob/main/src/llm_production_toolkit/cli.py) (Toolkit CLI), [`src/llm_production_toolkit/feedback/collector.py`](https://github.com/frckeepit/llm-production-toolkit/blob/main/src/llm_production_toolkit/feedback/collector.py) (Feedback collector), [`src/llm_production_toolkit/_models.py`](https://github.com/frckeepit/llm-production-toolkit/blob/main/src/llm_production_toolkit/_models.py) (Core models)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_core["Shared core"]
  node_core_models["Core models<br/>shared types<br/>[_models.py]"]
  node_core_utils["Core utils<br/>shared helpers<br/>[_utils.py]"]
  node_core_version["Version info<br/>metadata<br/>[_version.py]"]
end

subgraph group_domains["Domain modules"]
  node_hallucination_eval["Hallucination eval<br/>grounding evaluator<br/>[evaluator.py]"]
  node_hallucination_models["Hallucination models<br/>result schemas<br/>[models.py]"]
  node_bias_eval["Bias eval<br/>prompt evaluator<br/>[evaluator.py]"]
  node_bias_templates["Bias templates<br/>prompt variants<br/>[templates.py]"]
  node_bias_metrics["Bias metrics<br/>scoring<br/>[metrics.py]"]
  node_readiness_assessor["Readiness assessor<br/>scoring workflow<br/>[assessor.py]"]
end

subgraph group_ops["Operational layer"]
  node_feedback_app["Feedback app<br/>web service<br/>[app.py]"]
  node_feedback_collector["Feedback collector<br/>ingestion<br/>[collector.py]"]
  node_feedback_db[("Feedback DB<br/>storage<br/>[db.py]")]
  node_feedback_metrics["Feedback metrics<br/>analytics<br/>[metrics.py]"]
  node_compliance_mapper["Compliance mapper<br/>report mapper<br/>[mapper.py]"]
  node_compliance_frameworks["Frameworks<br/>framework defs<br/>[frameworks.py]"]
  node_compliance_models["Compliance models<br/>report schemas<br/>[models.py]"]
end

subgraph group_interfaces["Command interfaces"]
  node_pkg_cli["Toolkit CLI<br/>dispatcher<br/>[cli.py]"]
  node_hallucination_cli["Hallucination CLI<br/>subcommand<br/>[cli.py]"]
  node_bias_cli["Bias CLI<br/>subcommand<br/>[cli.py]"]
  node_feedback_cli["Feedback CLI<br/>subcommand<br/>[cli.py]"]
  node_readiness_cli["Readiness CLI<br/>subcommand<br/>[cli.py]"]
  node_compliance_cli["Compliance CLI<br/>subcommand<br/>[cli.py]"]
end

node_pkg_cli -->|"routes to"| node_hallucination_cli
node_pkg_cli -->|"routes to"| node_bias_cli
node_pkg_cli -->|"routes to"| node_feedback_cli
node_pkg_cli -->|"routes to"| node_readiness_cli
node_pkg_cli -->|"routes to"| node_compliance_cli
node_hallucination_eval -->|"returns"| node_hallucination_models
node_hallucination_eval -->|"uses"| node_core_models
node_hallucination_eval -->|"uses"| node_core_utils
node_bias_eval -->|"drives"| node_bias_templates
node_bias_eval -->|"aggregates"| node_bias_metrics
node_bias_eval -->|"uses"| node_core_models
node_feedback_app -->|"serves"| node_feedback_collector
node_feedback_collector -->|"persists"| node_feedback_db
node_feedback_collector -->|"computes"| node_feedback_metrics
node_feedback_collector -->|"uses"| node_core_models
node_readiness_assessor -->|"uses"| node_core_models
node_readiness_assessor -->|"uses"| node_core_utils
node_compliance_mapper -->|"maps to"| node_compliance_frameworks
node_compliance_mapper -->|"returns"| node_compliance_models
node_compliance_mapper -->|"consumes"| node_hallucination_models
node_compliance_mapper -->|"consumes"| node_readiness_assessor
node_compliance_mapper -->|"uses"| node_core_models
node_hallucination_cli -->|"invokes"| node_hallucination_eval
node_bias_cli -->|"invokes"| node_bias_eval
node_feedback_cli -->|"invokes"| node_feedback_collector
node_readiness_cli -->|"invokes"| node_readiness_assessor
node_compliance_cli -->|"invokes"| node_compliance_mapper
node_core_version -.->|"shared metadata"| node_pkg_cli

click node_pkg_cli "https://github.com/frckeepit/llm-production-toolkit/blob/main/src/llm_production_toolkit/cli.py"
click node_core_models "https://github.com/frckeepit/llm-production-toolkit/blob/main/src/llm_production_toolkit/_models.py"
click node_core_utils "https://github.com/frckeepit/llm-production-toolkit/blob/main/src/llm_production_toolkit/_utils.py"
click node_core_version "https://github.com/frckeepit/llm-production-toolkit/blob/main/src/llm_production_toolkit/_version.py"
click node_hallucination_eval "https://github.com/frckeepit/llm-production-toolkit/blob/main/src/llm_production_toolkit/hallucination/evaluator.py"
click node_hallucination_models "https://github.com/frckeepit/llm-production-toolkit/blob/main/src/llm_production_toolkit/hallucination/models.py"
click node_bias_eval "https://github.com/frckeepit/llm-production-toolkit/blob/main/src/llm_production_toolkit/bias/evaluator.py"
click node_bias_templates "https://github.com/frckeepit/llm-production-toolkit/blob/main/src/llm_production_toolkit/bias/templates.py"
click node_bias_metrics "https://github.com/frckeepit/llm-production-toolkit/blob/main/src/llm_production_toolkit/bias/metrics.py"
click node_feedback_app "https://github.com/frckeepit/llm-production-toolkit/blob/main/src/llm_production_toolkit/feedback/app.py"
click node_feedback_collector "https://github.com/frckeepit/llm-production-toolkit/blob/main/src/llm_production_toolkit/feedback/collector.py"
click node_feedback_db "https://github.com/frckeepit/llm-production-toolkit/blob/main/src/llm_production_toolkit/feedback/db.py"
click node_feedback_metrics "https://github.com/frckeepit/llm-production-toolkit/blob/main/src/llm_production_toolkit/feedback/metrics.py"
click node_readiness_assessor "https://github.com/frckeepit/llm-production-toolkit/blob/main/src/llm_production_toolkit/readiness/assessor.py"
click node_compliance_mapper "https://github.com/frckeepit/llm-production-toolkit/blob/main/src/llm_production_toolkit/compliance/mapper.py"
click node_compliance_frameworks "https://github.com/frckeepit/llm-production-toolkit/blob/main/src/llm_production_toolkit/compliance/frameworks.py"
click node_compliance_models "https://github.com/frckeepit/llm-production-toolkit/blob/main/src/llm_production_toolkit/compliance/models.py"
click node_hallucination_cli "https://github.com/frckeepit/llm-production-toolkit/blob/main/src/llm_production_toolkit/hallucination/cli.py"
click node_bias_cli "https://github.com/frckeepit/llm-production-toolkit/blob/main/src/llm_production_toolkit/bias/cli.py"
click node_feedback_cli "https://github.com/frckeepit/llm-production-toolkit/blob/main/src/llm_production_toolkit/feedback/cli.py"
click node_readiness_cli "https://github.com/frckeepit/llm-production-toolkit/blob/main/src/llm_production_toolkit/readiness/cli.py"
click node_compliance_cli "https://github.com/frckeepit/llm-production-toolkit/blob/main/src/llm_production_toolkit/compliance/cli.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_core_models,node_core_utils,node_core_version toneBlue
class node_hallucination_eval,node_hallucination_models,node_bias_eval,node_bias_templates,node_bias_metrics,node_readiness_assessor toneAmber
class node_feedback_app,node_feedback_collector,node_feedback_db,node_feedback_metrics,node_compliance_mapper,node_compliance_frameworks,node_compliance_models toneMint
class node_pkg_cli,node_hallucination_cli,node_bias_cli,node_feedback_cli,node_readiness_cli,node_compliance_cli toneRose
```

## Components

### Shared core

Package-wide models, utilities, and version metadata.

- [Core models](https://github.com/frckeepit/llm-production-toolkit/blob/main/src/llm_production_toolkit/_models.py): shared types · Package-wide internal data structures shared across modules. · `src/llm_production_toolkit/_models.py`
- [Core utils](https://github.com/frckeepit/llm-production-toolkit/blob/main/src/llm_production_toolkit/_utils.py): shared helpers · Common helper functions used by subpackages. · `src/llm_production_toolkit/_utils.py`
- [Version info](https://github.com/frckeepit/llm-production-toolkit/blob/main/src/llm_production_toolkit/_version.py): metadata · Package version metadata and release identity. · `src/llm_production_toolkit/_version.py`

### Domain modules

Independent capabilities exposed as Python APIs and CLI subcommands.

- [Hallucination eval](https://github.com/frckeepit/llm-production-toolkit/blob/main/src/llm_production_toolkit/hallucination/evaluator.py): grounding evaluator · Compares model output against source context for hallucination checks. · `src/llm_production_toolkit/hallucination/evaluator.py`
- [Hallucination models](https://github.com/frckeepit/llm-production-toolkit/blob/main/src/llm_production_toolkit/hallucination/models.py): result schemas · Structured outputs for grounding and support checks. · `src/llm_production_toolkit/hallucination/models.py`
- [Bias eval](https://github.com/frckeepit/llm-production-toolkit/blob/main/src/llm_production_toolkit/bias/evaluator.py): prompt evaluator · Orchestrates controlled prompt variation against an LLM callable. · `src/llm_production_toolkit/bias/evaluator.py`
- [Bias templates](https://github.com/frckeepit/llm-production-toolkit/blob/main/src/llm_production_toolkit/bias/templates.py): prompt variants · Template set used to generate comparison prompts. · `src/llm_production_toolkit/bias/templates.py`
- [Bias metrics](https://github.com/frckeepit/llm-production-toolkit/blob/main/src/llm_production_toolkit/bias/metrics.py): scoring · Aggregates bias-related measurements into scores. · `src/llm_production_toolkit/bias/metrics.py`
- [Readiness assessor](https://github.com/frckeepit/llm-production-toolkit/blob/main/src/llm_production_toolkit/readiness/assessor.py): scoring workflow · Evaluates production-readiness criteria and recommendations. · `src/llm_production_toolkit/readiness/assessor.py`

### Operational layer

Persistence, service boundary, and cross-module reporting.

- [Feedback app](https://github.com/frckeepit/llm-production-toolkit/blob/main/src/llm_production_toolkit/feedback/app.py): web service · REST interface over the feedback storage pipeline. · `src/llm_production_toolkit/feedback/app.py`
- [Feedback collector](https://github.com/frckeepit/llm-production-toolkit/blob/main/src/llm_production_toolkit/feedback/collector.py): ingestion · Ingests and aggregates user feedback events. · `src/llm_production_toolkit/feedback/collector.py`
- [Feedback DB](https://github.com/frckeepit/llm-production-toolkit/blob/main/src/llm_production_toolkit/feedback/db.py): storage · Persistence layer for feedback records and query data. · `src/llm_production_toolkit/feedback/db.py`
- [Feedback metrics](https://github.com/frckeepit/llm-production-toolkit/blob/main/src/llm_production_toolkit/feedback/metrics.py): analytics · Computes satisfaction and usage statistics from stored events. · `src/llm_production_toolkit/feedback/metrics.py`
- [Compliance mapper](https://github.com/frckeepit/llm-production-toolkit/blob/main/src/llm_production_toolkit/compliance/mapper.py): report mapper · Maps outputs from other modules into compliance and best-practice views. · `src/llm_production_toolkit/compliance/mapper.py`
- [Frameworks](https://github.com/frckeepit/llm-production-toolkit/blob/main/src/llm_production_toolkit/compliance/frameworks.py): framework defs · Target compliance and best-practice framework definitions. · `src/llm_production_toolkit/compliance/frameworks.py`
- [Compliance models](https://github.com/frckeepit/llm-production-toolkit/blob/main/src/llm_production_toolkit/compliance/models.py): report schemas · Structured compliance report objects. · `src/llm_production_toolkit/compliance/models.py`

### Command interfaces

Top-level and per-domain CLI entrypoints.

- [Toolkit CLI](https://github.com/frckeepit/llm-production-toolkit/blob/main/src/llm_production_toolkit/cli.py): dispatcher · Top-level command dispatcher for domain subcommands. · `src/llm_production_toolkit/cli.py`
- [Hallucination CLI](https://github.com/frckeepit/llm-production-toolkit/blob/main/src/llm_production_toolkit/hallucination/cli.py): subcommand · Domain-specific command entrypoint for hallucination checks. · `src/llm_production_toolkit/hallucination/cli.py`
- [Bias CLI](https://github.com/frckeepit/llm-production-toolkit/blob/main/src/llm_production_toolkit/bias/cli.py): subcommand · Domain-specific command entrypoint for bias evaluation. · `src/llm_production_toolkit/bias/cli.py`
- [Feedback CLI](https://github.com/frckeepit/llm-production-toolkit/blob/main/src/llm_production_toolkit/feedback/cli.py): subcommand · Local command entrypoint for querying feedback metrics. · `src/llm_production_toolkit/feedback/cli.py`
- [Readiness CLI](https://github.com/frckeepit/llm-production-toolkit/blob/main/src/llm_production_toolkit/readiness/cli.py): subcommand · Domain-specific command entrypoint for readiness assessment. · `src/llm_production_toolkit/readiness/cli.py`
- [Compliance CLI](https://github.com/frckeepit/llm-production-toolkit/blob/main/src/llm_production_toolkit/compliance/cli.py): subcommand · Domain-specific command entrypoint for compliance reporting. · `src/llm_production_toolkit/compliance/cli.py`

## Connections

- Toolkit CLI → Hallucination CLI: routes to · Top-level CLI dispatches into hallucination commands.
- Toolkit CLI → Bias CLI: routes to · Top-level CLI dispatches into bias commands.
- Toolkit CLI → Feedback CLI: routes to · Top-level CLI dispatches into feedback commands.
- Toolkit CLI → Readiness CLI: routes to · Top-level CLI dispatches into readiness commands.
- Toolkit CLI → Compliance CLI: routes to · Top-level CLI dispatches into compliance commands.
- Hallucination eval → Hallucination models: returns · Evaluator produces structured hallucination results.
- Hallucination eval → Core models: uses · Shares internal data structures.
- Hallucination eval → Core utils: uses · Uses common helper logic.
- Bias eval → Bias templates: drives · Evaluation builds prompt variants from templates.
- Bias eval → Bias metrics: aggregates · Evaluation folds outputs into bias scores.
- Bias eval → Core models: uses · Shares internal data structures.
- Feedback app → Feedback collector: serves · Web layer delegates ingestion and query handling.
- Feedback collector → Feedback DB: persists · Collector stores and retrieves feedback records.
- Feedback collector → Feedback metrics: computes · Collector feeds stored events into analytics.
- Feedback collector → Core models: uses · Shares internal data structures.
- Readiness assessor → Core models: uses · Shares internal data structures.
- Readiness assessor → Core utils: uses · Uses common helper logic.
- Compliance mapper → Frameworks: maps to · Maps assessments onto target frameworks.
- Compliance mapper → Compliance models: returns · Produces compliance report objects.
- Compliance mapper → Hallucination models: consumes · Uses hallucination outputs as input signals.
- Compliance mapper → Readiness assessor: consumes · Uses readiness outputs as input signals.
- Compliance mapper → Core models: uses · Shares internal data structures.
- Hallucination CLI → Hallucination eval: invokes · CLI wraps the hallucination evaluator.
- Bias CLI → Bias eval: invokes · CLI wraps the bias evaluator.
- Feedback CLI → Feedback collector: invokes · CLI queries the feedback pipeline.
- Readiness CLI → Readiness assessor: invokes · CLI wraps readiness assessment.
- Compliance CLI → Compliance mapper: invokes · CLI wraps compliance mapping.
- Version info → Toolkit CLI: shared metadata · Package metadata is available to the top-level tool.
