# softoft-orga/open-ticket-ai architecture

> Architecture diagram of the GitHub repository softoft-orga/open-ticket-ai, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-31). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/softoft-orga/open-ticket-ai
- Repository: https://github.com/softoft-orga/open-ticket-ai

## Overview

#### Purpose and Runtime Entry Points
Open Ticket AI is a Python runtime that classifies and routes support tickets using ML, then applies results back to ticket systems. Primary startup and composition points are `src/open_ticket_ai/main.py`, `src/open_ticket_ai/app.py`, and `src/open_ticket_ai/pipeline.py`. It is packaged as a core engine with pluggable classifier and ticket-system integrations.

#### Configuration, Application Assembly, and Workflows
Settings drive assembly of ticket-system services, classifier services, workflows, and API exposure. `src/open_ticket_ai/settings.py` supplies runtime configuration; `src/open_ticket_ai/app.py` builds the application; `src/open_ticket_ai/workflow_manager.py` owns configured workflow lifecycle. Deployment mounts config through `OT_AI_CONFIG`, with example/container assets in `deployment/config.yml`, `deployment/Dockerfile`, and `deployment/compose.yml`.

#### Pipe-Based Processing Model
The central execution abstraction is a pipe: units consume and enrich a shared execution context, and may be composed into workflows. Core contracts and context/result models are in `src/open_ticket_ai/core/pipes/pipe.py`, `src/open_ticket_ai/core/pipes/pipe_context_model.py`, and `src/open_ticket_ai/core/pipes/pipe_models.py`. This boundary enables plugins and reusable stages without coupling orchestration to concrete services.

#### Workflow Execution and Scheduling
Configured pipelines run through composite pipes and sequential orchestration/runner implementations. `src/open_ticket_ai/pipes/composite_pipe.py`, `src/open_ticket_ai/pipes/orchestrators/simple_sequential_orchestrator.py`, and `src/open_ticket_ai/pipes/pipe_runners/simple_sequential_runner.py` define execution flow. `src/open_ticket_ai/pipes/interval_trigger_pipe.py` periodically triggers work; templates such as `src/open_ticket_ai/pipes/templates/classify_and_route.py` assemble the standard fetch→classify→route workflow.

#### Ticket Acquisition and Mutation Boundary
Ticket-system pipes isolate workflow logic from vendor APIs: fetch tickets, update ticket fields/routing, and add notes. These stages are in `src/open_ticket_ai/pipes/ticket_system_pipes/fetch_tickets_pipe.py`, `src/open_ticket_ai/pipes/ticket_system_pipes/update_ticket_pipe.py`, and `src/open_ticket_ai/pipes/ticket_system_pipes/add_note_pipe.py`. The vendor-neutral contract and unified ticket models live in `src/open_ticket_ai/core/ticket_system_integration/ticket_system_service.py` and `src/open_ticket_ai/core/ticket_system_integration/unified_models.py`.

#### Classification Boundary and Implementations
Classification pipes send ticket content to an abstract AI classification service and place predictions into workflow context. Relevant contracts and stage are `src/open_ticket_ai/core/ai_classification_services/classification_service.py`, `src/open_ticket_ai/core/ai_classification_services/classification_models.py`, and `src/open_ticket_ai/pipes/classification_pipe.py`. The included local Hugging Face implementation is `src/open_ticket_ai/hf_local/hf_classification_service.py`; alternate providers can implement the same core interface.

#### External Interfaces and Integrations
The FastAPI-style HTTP layer exposes classification, ticket, workflow, and settings endpoints via `src/open_ticket_ai/api/app.py`, `src/open_ticket_ai/api/routers/classify.py`, and `src/open_ticket_ai/api/routers/workflows.py`. Concrete remote ticket-system adapters support Zammad and OTOBO/Znuny in `src/open_ticket_ai/zammad/zammad_ticket_system_service.py` and `src/open_ticket_ai/otobo_znuny/oto_znuny_ts_service.py`. Docker deploys the engine on port 8080; external dependencies are configured ticket-system APIs and the selected ML classifier/runtime.

Main entry points: [`src/open_ticket_ai/app.py`](https://github.com/softoft-orga/open-ticket-ai/blob/dev/src/open_ticket_ai/app.py) (Application assembly), [`src/open_ticket_ai/pipes/templates/classify_and_route.py`](https://github.com/softoft-orga/open-ticket-ai/blob/dev/src/open_ticket_ai/pipes/templates/classify_and_route.py) (Classify & route template), [`src/open_ticket_ai/api/routers/classify.py`](https://github.com/softoft-orga/open-ticket-ai/blob/dev/src/open_ticket_ai/api/routers/classify.py) (Classify & workflow routes), [`src/open_ticket_ai/workflow_manager.py`](https://github.com/softoft-orga/open-ticket-ai/blob/dev/src/open_ticket_ai/workflow_manager.py) (Workflow manager)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Runtime Assembly"]
  node_main["Runtime entry<br/>Python entrypoint<br/>[main.py]"]
  node_app["Application assembly<br/>application factory<br/>[app.py]"]
  node_settings["Runtime settings<br/>configuration<br/>[settings.py]"]
  node_workflow_manager["Workflow manager<br/>lifecycle manager"]
  node_pipeline["Pipeline composition<br/>pipeline bootstrap<br/>[pipeline.py]"]
end

subgraph group_workflow["Pipe Workflows"]
  node_pipe_contract{{"Pipe contract &amp; context<br/>core abstraction<br/>[pipe.py]"}}
  node_composite_pipe["Composite workflow<br/>pipe composition<br/>[composite_pipe.py]"]
  node_orchestrator["Sequential orchestrator"]
  node_runner["Sequential runner<br/>pipe runner"]
  node_interval_trigger["Interval trigger<br/>scheduling pipe"]
  node_classify_route_template["Classify &amp; route template<br/>workflow template"]
end

subgraph group_boundaries["Integration Boundaries"]
  node_ticket_contract{{"Ticket service contract<br/>integration interface"}}
  node_ticket_pipes["Ticket fetch, update &amp; note<br/>ticket-system pipes"]
  node_classification_contract{{"Classification service contract<br/>ML interface"}}
  node_classification_pipe["Classification stage<br/>pipe stage"]
  node_hf_local["Local Hugging Face classifier<br/>classifier implementation"]
  node_ticket_adapters["Zammad / OTOBO adapters<br/>ticket adapters"]
end

subgraph group_interfaces["External Access"]
  node_api["HTTP API<br/>FastAPI application<br/>[app.py]"]
  node_api_routers["Classify &amp; workflow routes<br/>API routers<br/>[classify.py]"]
  node_external_ticket_systems(("Ticket-system APIs<br/>external service"))
end

node_main -->|"starts"| node_app
node_settings -->|"configures"| node_app
node_app -->|"composes"| node_pipeline
node_app -->|"registers workflows"| node_workflow_manager
node_app -->|"mounts"| node_api
node_pipeline -->|"uses"| node_classify_route_template
node_workflow_manager -->|"manages"| node_interval_trigger
node_interval_trigger -->|"triggers"| node_composite_pipe
node_classify_route_template -->|"builds"| node_composite_pipe
node_composite_pipe -->|"delegates execution"| node_orchestrator
node_orchestrator -->|"runs stages"| node_runner
node_runner -->|"uses context"| node_pipe_contract
node_classify_route_template -->|"fetches and mutates"| node_ticket_pipes
node_classify_route_template -->|"classifies"| node_classification_pipe
node_ticket_pipes -->|"depends on"| node_ticket_contract
node_classification_pipe -->|"requests prediction"| node_classification_contract
node_hf_local -->|"implements"| node_classification_contract
node_ticket_adapters -->|"implements"| node_ticket_contract
node_ticket_adapters -->|"calls"| node_external_ticket_systems
node_api -->|"includes"| node_api_routers
node_api_routers -->|"controls workflows"| node_workflow_manager
node_api_routers -->|"invokes classification"| node_classification_contract

click node_main "https://github.com/softoft-orga/open-ticket-ai/blob/dev/src/open_ticket_ai/main.py"
click node_app "https://github.com/softoft-orga/open-ticket-ai/blob/dev/src/open_ticket_ai/app.py"
click node_settings "https://github.com/softoft-orga/open-ticket-ai/blob/dev/src/open_ticket_ai/settings.py"
click node_workflow_manager "https://github.com/softoft-orga/open-ticket-ai/blob/dev/src/open_ticket_ai/workflow_manager.py"
click node_pipeline "https://github.com/softoft-orga/open-ticket-ai/blob/dev/src/open_ticket_ai/pipeline.py"
click node_pipe_contract "https://github.com/softoft-orga/open-ticket-ai/blob/dev/src/open_ticket_ai/core/pipes/pipe.py"
click node_composite_pipe "https://github.com/softoft-orga/open-ticket-ai/blob/dev/src/open_ticket_ai/pipes/composite_pipe.py"
click node_orchestrator "https://github.com/softoft-orga/open-ticket-ai/blob/dev/src/open_ticket_ai/pipes/orchestrators/simple_sequential_orchestrator.py"
click node_runner "https://github.com/softoft-orga/open-ticket-ai/blob/dev/src/open_ticket_ai/pipes/pipe_runners/simple_sequential_runner.py"
click node_interval_trigger "https://github.com/softoft-orga/open-ticket-ai/blob/dev/src/open_ticket_ai/pipes/interval_trigger_pipe.py"
click node_classify_route_template "https://github.com/softoft-orga/open-ticket-ai/blob/dev/src/open_ticket_ai/pipes/templates/classify_and_route.py"
click node_ticket_contract "https://github.com/softoft-orga/open-ticket-ai/blob/dev/src/open_ticket_ai/core/ticket_system_integration/ticket_system_service.py"
click node_ticket_pipes "https://github.com/softoft-orga/open-ticket-ai/blob/dev/src/open_ticket_ai/pipes/ticket_system_pipes/fetch_tickets_pipe.py"
click node_classification_contract "https://github.com/softoft-orga/open-ticket-ai/blob/dev/src/open_ticket_ai/core/ai_classification_services/classification_service.py"
click node_classification_pipe "https://github.com/softoft-orga/open-ticket-ai/blob/dev/src/open_ticket_ai/pipes/classification_pipe.py"
click node_hf_local "https://github.com/softoft-orga/open-ticket-ai/blob/dev/src/open_ticket_ai/hf_local/hf_classification_service.py"
click node_ticket_adapters "https://github.com/softoft-orga/open-ticket-ai/blob/dev/src/open_ticket_ai/zammad/zammad_ticket_system_service.py"
click node_api "https://github.com/softoft-orga/open-ticket-ai/blob/dev/src/open_ticket_ai/api/app.py"
click node_api_routers "https://github.com/softoft-orga/open-ticket-ai/blob/dev/src/open_ticket_ai/api/routers/classify.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_main,node_app,node_settings,node_workflow_manager,node_pipeline toneBlue
class node_pipe_contract,node_composite_pipe,node_orchestrator,node_runner,node_interval_trigger,node_classify_route_template toneAmber
class node_ticket_contract,node_ticket_pipes,node_classification_contract,node_classification_pipe,node_hf_local,node_ticket_adapters toneMint
class node_api,node_api_routers,node_external_ticket_systems toneRose
```

## Components

### Runtime Assembly

- [Runtime entry](https://github.com/softoft-orga/open-ticket-ai/blob/dev/src/open_ticket_ai/main.py): Python entrypoint · `src/open_ticket_ai/main.py`
- [Application assembly](https://github.com/softoft-orga/open-ticket-ai/blob/dev/src/open_ticket_ai/app.py): application factory · Builds configured services, workflows, and API exposure. · `src/open_ticket_ai/app.py`
- [Runtime settings](https://github.com/softoft-orga/open-ticket-ai/blob/dev/src/open_ticket_ai/settings.py): configuration · Loaded from the OT_AI_CONFIG-mounted configuration. · `src/open_ticket_ai/settings.py`
- [Workflow manager](https://github.com/softoft-orga/open-ticket-ai/blob/dev/src/open_ticket_ai/workflow_manager.py): lifecycle manager · `src/open_ticket_ai/workflow_manager.py`
- [Pipeline composition](https://github.com/softoft-orga/open-ticket-ai/blob/dev/src/open_ticket_ai/pipeline.py): pipeline bootstrap · `src/open_ticket_ai/pipeline.py`

### Pipe Workflows

- [Pipe contract & context](https://github.com/softoft-orga/open-ticket-ai/blob/dev/src/open_ticket_ai/core/pipes/pipe.py): core abstraction · Shared execution context and result models for reusable stages. · `src/open_ticket_ai/core/pipes/pipe.py`
- [Composite workflow](https://github.com/softoft-orga/open-ticket-ai/blob/dev/src/open_ticket_ai/pipes/composite_pipe.py): pipe composition · `src/open_ticket_ai/pipes/composite_pipe.py`
- [Sequential orchestrator](https://github.com/softoft-orga/open-ticket-ai/blob/dev/src/open_ticket_ai/pipes/orchestrators/simple_sequential_orchestrator.py): orchestrator · `src/open_ticket_ai/pipes/orchestrators/simple_sequential_orchestrator.py`
- [Sequential runner](https://github.com/softoft-orga/open-ticket-ai/blob/dev/src/open_ticket_ai/pipes/pipe_runners/simple_sequential_runner.py): pipe runner · `src/open_ticket_ai/pipes/pipe_runners/simple_sequential_runner.py`
- [Interval trigger](https://github.com/softoft-orga/open-ticket-ai/blob/dev/src/open_ticket_ai/pipes/interval_trigger_pipe.py): scheduling pipe · `src/open_ticket_ai/pipes/interval_trigger_pipe.py`
- [Classify & route template](https://github.com/softoft-orga/open-ticket-ai/blob/dev/src/open_ticket_ai/pipes/templates/classify_and_route.py): workflow template · Assembles the standard fetch → classify → route flow. · `src/open_ticket_ai/pipes/templates/classify_and_route.py`

### Integration Boundaries

- [Ticket service contract](https://github.com/softoft-orga/open-ticket-ai/blob/dev/src/open_ticket_ai/core/ticket_system_integration/ticket_system_service.py): integration interface · Vendor-neutral ticket operations and unified ticket models. · `src/open_ticket_ai/core/ticket_system_integration/ticket_system_service.py`
- [Ticket fetch, update & note](https://github.com/softoft-orga/open-ticket-ai/blob/dev/src/open_ticket_ai/pipes/ticket_system_pipes/fetch_tickets_pipe.py): ticket-system pipes · Reads tickets and applies routing fields or notes. · `src/open_ticket_ai/pipes/ticket_system_pipes/fetch_tickets_pipe.py`
- [Classification service contract](https://github.com/softoft-orga/open-ticket-ai/blob/dev/src/open_ticket_ai/core/ai_classification_services/classification_service.py): ML interface · Abstract prediction service and classification models. · `src/open_ticket_ai/core/ai_classification_services/classification_service.py`
- [Classification stage](https://github.com/softoft-orga/open-ticket-ai/blob/dev/src/open_ticket_ai/pipes/classification_pipe.py): pipe stage · Adds ticket predictions to the shared workflow context. · `src/open_ticket_ai/pipes/classification_pipe.py`
- [Local Hugging Face classifier](https://github.com/softoft-orga/open-ticket-ai/blob/dev/src/open_ticket_ai/hf_local/hf_classification_service.py): classifier implementation · `src/open_ticket_ai/hf_local/hf_classification_service.py`
- [Zammad / OTOBO adapters](https://github.com/softoft-orga/open-ticket-ai/blob/dev/src/open_ticket_ai/zammad/zammad_ticket_system_service.py): ticket adapters · Concrete remote ticket-system implementations. · `src/open_ticket_ai/zammad/zammad_ticket_system_service.py`

### External Access

- [HTTP API](https://github.com/softoft-orga/open-ticket-ai/blob/dev/src/open_ticket_ai/api/app.py): FastAPI application · Exposes classification, ticket, workflow, and settings operations. · `src/open_ticket_ai/api/app.py`
- [Classify & workflow routes](https://github.com/softoft-orga/open-ticket-ai/blob/dev/src/open_ticket_ai/api/routers/classify.py): API routers · `src/open_ticket_ai/api/routers/classify.py`
- **Ticket-system APIs**: external service

## Connections

- Runtime entry → Application assembly: starts
- Runtime settings → Application assembly: configures
- Application assembly → Pipeline composition: composes
- Application assembly → Workflow manager: registers workflows
- Application assembly → HTTP API: mounts
- Pipeline composition → Classify & route template: uses
- Workflow manager → Interval trigger: manages
- Interval trigger → Composite workflow: triggers
- Classify & route template → Composite workflow: builds
- Composite workflow → Sequential orchestrator: delegates execution
- Sequential orchestrator → Sequential runner: runs stages
- Sequential runner → Pipe contract & context: uses context
- Classify & route template → Ticket fetch, update & note: fetches and mutates
- Classify & route template → Classification stage: classifies
- Ticket fetch, update & note → Ticket service contract: depends on
- Classification stage → Classification service contract: requests prediction
- Local Hugging Face classifier → Classification service contract: implements
- Zammad / OTOBO adapters → Ticket service contract: implements
- Zammad / OTOBO adapters → Ticket-system APIs: calls
- HTTP API → Classify & workflow routes: includes
- Classify & workflow routes → Workflow manager: controls workflows
- Classify & workflow routes → Classification service contract: invokes classification
