# lorisunjunbin/petp architecture

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

- Interactive diagram: https://gitdiagram.com/lorisunjunbin/petp
- Repository: https://github.com/lorisunjunbin/petp

## Overview

PET-P is a Python RPA toolkit for authoring and running configurable task workflows. In the main workflow, users configure Executions in the GUI, compose them into Pipelines, and run them; Pipelines invoke Executions, which process Tasks through processors and share results through runtime data. The README also documents headless and portable runtimes, cron scheduling, AI flow generation, MCP, and broad integration processors. Edges are based on the README or shown source/index references; several feature internals were not sampled, so their links are documented at subsystem level.

Main entry points: [`core/execution.py`](https://github.com/lorisunjunbin/petp/blob/master/core/execution.py) (Execution engine), [`core/pipeline.py`](https://github.com/lorisunjunbin/petp/blob/master/core/pipeline.py) (Pipeline), [`mvp/presenter/PETPPresenter.py`](https://github.com/lorisunjunbin/petp/blob/master/mvp/presenter/PETPPresenter.py) (GUI presenter), [`core/processors`](https://github.com/lorisunjunbin/petp/tree/master/core/processors) (Automation processors)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_authoring["Workflow authoring"]
  node_gui["PET-P GUI<br/>[PETPView.py]"]
  node_presenter["GUI presenter<br/>[PETPPresenter.py]"]
  node_ai_generator["AI flow generator"]
end

subgraph group_execution["Workflow runtime"]
  node_pipeline["Pipeline<br/>[pipeline.py]"]
  node_execution["Execution engine<br/>[execution.py]"]
  node_task["Task model<br/>[task.py]"]
  node_processor["Processor runtime<br/>[processor.py]"]
  node_loop["Loop control<br/>[loop.py]"]
  node_yaml["Workflow YAML<br/>[yamlro.py]"]
end

subgraph group_integrations["Processors and integrations"]
  node_processors["Automation processors"]
  node_llm["LLM clients"]
  node_database["Database adapters"]
end

subgraph group_services["Services and scheduling"]
  node_background["Background runtime"]
  node_cron["Cron scheduler<br/>[cron.py]"]
  node_http["HTTP service<br/>[HttpServer.py]"]
  node_http_handler["HTTP request handler"]
  node_mcp["MCP server<br/>[McpMixin.py]"]
  node_portable["Portable runtime<br/>[petp_run.py]"]
end

subgraph group_support["Shared support"]
  node_events["Runtime events<br/>[PETPEvent.py]"]
end

node_user(("Workflow author"))
node_external_ai{{"LLM providers"}}
node_external_clients(("HTTP clients and agents"))

node_user -->|"authors workflows"| node_gui
node_gui -.->|"edits workflows"| node_presenter
node_presenter -->|"runs workflows"| node_pipeline
node_presenter -.->|"requests generation"| node_ai_generator
node_ai_generator -->|"generates flows"| node_external_ai
node_pipeline -->|"invokes executions"| node_execution
node_pipeline -->|"saves pipeline"| node_yaml
node_execution -->|"loads execution"| node_yaml
node_execution -->|"processes tasks"| node_task
node_execution -->|"creates processors"| node_processor
node_execution -->|"controls loops"| node_loop
node_processor -.->|"dispatches tasks"| node_processors
node_processors -.->|"uses clients"| node_llm
node_processors -.->|"uses adapters"| node_database
node_background -->|"runs workflows"| node_pipeline
node_background -->|"manages schedules"| node_cron
node_http -->|"routes requests"| node_http_handler
node_http -->|"serves MCP"| node_mcp
node_external_clients -->|"sends requests"| node_http
node_mcp -->|"exposes tools"| node_external_clients
node_portable -->|"runs executions"| node_execution
node_execution -->|"publishes events"| node_events
node_llm -.->|"calls providers"| node_external_ai

click node_gui "https://github.com/lorisunjunbin/petp/blob/master/mvp/view/PETPView.py"
click node_presenter "https://github.com/lorisunjunbin/petp/blob/master/mvp/presenter/PETPPresenter.py"
click node_ai_generator "https://github.com/lorisunjunbin/petp/blob/master/core/ai/ExecutionGenerator.py"
click node_pipeline "https://github.com/lorisunjunbin/petp/blob/master/core/pipeline.py"
click node_execution "https://github.com/lorisunjunbin/petp/blob/master/core/execution.py"
click node_task "https://github.com/lorisunjunbin/petp/blob/master/core/task.py"
click node_processor "https://github.com/lorisunjunbin/petp/blob/master/core/processor.py"
click node_loop "https://github.com/lorisunjunbin/petp/blob/master/core/loop.py"
click node_yaml "https://github.com/lorisunjunbin/petp/blob/master/core/definition/yamlro.py"
click node_processors "https://github.com/lorisunjunbin/petp/tree/master/core/processors"
click node_llm "https://github.com/lorisunjunbin/petp/tree/master/core/processors/sub/llm"
click node_database "https://github.com/lorisunjunbin/petp/tree/master/core/processors/sub/dbprocessors"
click node_background "https://github.com/lorisunjunbin/petp/blob/master/core/runtime/BackgroundRuntime.py"
click node_cron "https://github.com/lorisunjunbin/petp/blob/master/core/cron/cron.py"
click node_http "https://github.com/lorisunjunbin/petp/blob/master/httpservice/HttpServer.py"
click node_http_handler "https://github.com/lorisunjunbin/petp/blob/master/httpservice/handlers/HttpRequestHandler.py"
click node_mcp "https://github.com/lorisunjunbin/petp/blob/master/httpservice/McpMixin.py"
click node_portable "https://github.com/lorisunjunbin/petp/blob/master/portable/petp_run.py"
click node_events "https://github.com/lorisunjunbin/petp/blob/master/mvp/presenter/event/PETPEvent.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_gui,node_presenter,node_ai_generator,node_external_clients toneBlue
class node_pipeline,node_execution,node_task,node_processor,node_loop,node_yaml toneAmber
class node_processors,node_llm,node_database toneMint
class node_background,node_cron,node_http,node_http_handler,node_mcp,node_portable toneRose
class node_events,node_user,node_external_ai toneIndigo
```

## Components

### Workflow authoring

- [PET-P GUI](https://github.com/lorisunjunbin/petp/blob/master/mvp/view/PETPView.py): `mvp/view/PETPView.py`
- [GUI presenter](https://github.com/lorisunjunbin/petp/blob/master/mvp/presenter/PETPPresenter.py): `mvp/presenter/PETPPresenter.py`
- [AI flow generator](https://github.com/lorisunjunbin/petp/blob/master/core/ai/ExecutionGenerator.py): `core/ai/ExecutionGenerator.py`

### Workflow runtime

- [Pipeline](https://github.com/lorisunjunbin/petp/blob/master/core/pipeline.py): `core/pipeline.py`
- [Execution engine](https://github.com/lorisunjunbin/petp/blob/master/core/execution.py): `core/execution.py`
- [Task model](https://github.com/lorisunjunbin/petp/blob/master/core/task.py): `core/task.py`
- [Processor runtime](https://github.com/lorisunjunbin/petp/blob/master/core/processor.py): `core/processor.py`
- [Loop control](https://github.com/lorisunjunbin/petp/blob/master/core/loop.py): `core/loop.py`
- [Workflow YAML](https://github.com/lorisunjunbin/petp/blob/master/core/definition/yamlro.py): `core/definition/yamlro.py`

### Processors and integrations

- [Automation processors](https://github.com/lorisunjunbin/petp/tree/master/core/processors): `core/processors`
- [LLM clients](https://github.com/lorisunjunbin/petp/tree/master/core/processors/sub/llm): `core/processors/sub/llm`
- [Database adapters](https://github.com/lorisunjunbin/petp/tree/master/core/processors/sub/dbprocessors): `core/processors/sub/dbprocessors`

### Services and scheduling

- [Background runtime](https://github.com/lorisunjunbin/petp/blob/master/core/runtime/BackgroundRuntime.py): `core/runtime/BackgroundRuntime.py`
- [Cron scheduler](https://github.com/lorisunjunbin/petp/blob/master/core/cron/cron.py): `core/cron/cron.py`
- [HTTP service](https://github.com/lorisunjunbin/petp/blob/master/httpservice/HttpServer.py): `httpservice/HttpServer.py`
- [HTTP request handler](https://github.com/lorisunjunbin/petp/blob/master/httpservice/handlers/HttpRequestHandler.py): `httpservice/handlers/HttpRequestHandler.py`
- [MCP server](https://github.com/lorisunjunbin/petp/blob/master/httpservice/McpMixin.py): `httpservice/McpMixin.py`
- [Portable runtime](https://github.com/lorisunjunbin/petp/blob/master/portable/petp_run.py): `portable/petp_run.py`

### Shared support

- [Runtime events](https://github.com/lorisunjunbin/petp/blob/master/mvp/presenter/event/PETPEvent.py): `mvp/presenter/event/PETPEvent.py`

### Other components

- **Workflow author**
- **LLM providers**
- **HTTP clients and agents**

## Connections

- Workflow author → PET-P GUI: authors workflows
- PET-P GUI → GUI presenter: edits workflows (evidence: `mvp/presenter/PETPPresenter.py`)
- GUI presenter → Pipeline: runs workflows (evidence: `mvp/presenter/PETPPresenter.py`)
- GUI presenter → AI flow generator: requests generation (evidence: `mvp/presenter/PETPPresenter.py`)
- AI flow generator → LLM providers: generates flows
- Pipeline → Execution engine: invokes executions (evidence: `core/pipeline.py`)
- Pipeline → Workflow YAML: saves pipeline (evidence: `core/pipeline.py`)
- Execution engine → Workflow YAML: loads execution (evidence: `core/execution.py`)
- Execution engine → Task model: processes tasks (evidence: `core/execution.py`)
- Execution engine → Processor runtime: creates processors (evidence: `core/execution.py`)
- Execution engine → Loop control: controls loops (evidence: `core/execution.py`)
- Processor runtime → Automation processors: dispatches tasks (evidence: `core/processors/CREATE_SFTP_CLIENTProcessor.py`)
- Automation processors → LLM clients: uses clients
- Automation processors → Database adapters: uses adapters
- Background runtime → Pipeline: runs workflows (evidence: `core/runtime/BackgroundRuntime.py`)
- Background runtime → Cron scheduler: manages schedules (evidence: `core/runtime/BackgroundRuntime.py`)
- HTTP service → HTTP request handler: routes requests (evidence: `httpservice/HttpServer.py`)
- HTTP service → MCP server: serves MCP (evidence: `httpservice/HttpServer.py`)
- HTTP clients and agents → HTTP service: sends requests
- MCP server → HTTP clients and agents: exposes tools
- Portable runtime → Execution engine: runs executions
- Execution engine → Runtime events: publishes events (evidence: `core/execution.py`)
- LLM clients → LLM providers: calls providers
