# pkr-lab/docflowengine architecture

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

- Interactive diagram: https://gitdiagram.com/pkr-lab/docflowengine
- Repository: https://github.com/pkr-lab/docflowengine

## Overview

DocFlowEngine is a PowerShell document-watching and filing tool. Its documented workflow starts with a user running the script, reads configured paths and rules, detects new documents in source folders, renames them, and copies them into a target structure; DryRun allows actions to be previewed. The tree exposes separate engine modules for these responsibilities, plus state, locking, naming, and copy-back/forward behavior. No source excerpts were provided, so internal module calls and the precise roles of several helpers are not asserted; documented workflow edges cite the README.

Main entry points: [`scripts/DocFlowEngine.ps1`](https://github.com/pkr-lab/docflowengine/blob/main/scripts/DocFlowEngine.ps1) (Engine runner), [`scripts/DocFlowEngine/CopyForward.ps1`](https://github.com/pkr-lab/docflowengine/blob/main/scripts/DocFlowEngine/CopyForward.ps1) (Folder monitoring), [`scripts/DocFlowEngine/State.ps1`](https://github.com/pkr-lab/docflowengine/blob/main/scripts/DocFlowEngine/State.ps1) (New-document detection), [`scripts/DocFlowEngine/Rename.ps1`](https://github.com/pkr-lab/docflowengine/blob/main/scripts/DocFlowEngine/Rename.ps1) (Rule-based renaming)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_workflow["Document workflow"]
  node_runner["Engine runner<br/>[DocFlowEngine.ps1]"]
  node_watch["Folder monitoring<br/>[CopyForward.ps1]"]
  node_detect["New-document detection<br/>[State.ps1]"]
  node_rename["Rule-based renaming<br/>[Rename.ps1]"]
  node_copy["Target copying<br/>[CopyForward.ps1]"]
  node_dryrun["Dry-run mode<br/>[DocFlowEngine.ps1]"]
end

subgraph group_engine["Engine internals"]
  node_common["Shared utilities<br/>[Common.ps1]"]
  node_naming["Naming rules<br/>[Naming.ps1]"]
  node_state["Processing state<br/>[State.ps1]"]
  node_lock["Execution locking<br/>[Lock.ps1]"]
  node_copyback["Copy-back handling<br/>[CopyBack.ps1]"]
  node_forward["Copy-forward handling<br/>[CopyForward.ps1]"]
  node_engine_module["Engine module<br/>[DocFlowEngine.psm1]"]
  node_module_manifest["Module manifest<br/>[DocFlowEngine.psd1]"]
end

subgraph group_configuration["Configuration"]
  node_config["Path and rule config"]
  node_configload["Configuration handling<br/>[Config.ps1]"]
end

node_user(("Operator"))
node_source["Source folders"]
node_target["Target structure"]

node_user -->|"runs"| node_runner
node_runner -->|"uses paths and rules"| node_config
node_source -->|"is monitored"| node_watch
node_watch -->|"finds new documents"| node_detect
node_runner -->|"renames by rules"| node_rename
node_runner -->|"copies documents"| node_copy
node_copy -->|"writes into"| node_target
node_runner -->|"supports preview"| node_dryrun

click node_runner "https://github.com/pkr-lab/docflowengine/blob/main/scripts/DocFlowEngine.ps1"
click node_watch "https://github.com/pkr-lab/docflowengine/blob/main/scripts/DocFlowEngine/CopyForward.ps1"
click node_detect "https://github.com/pkr-lab/docflowengine/blob/main/scripts/DocFlowEngine/State.ps1"
click node_rename "https://github.com/pkr-lab/docflowengine/blob/main/scripts/DocFlowEngine/Rename.ps1"
click node_copy "https://github.com/pkr-lab/docflowengine/blob/main/scripts/DocFlowEngine/CopyForward.ps1"
click node_dryrun "https://github.com/pkr-lab/docflowengine/blob/main/scripts/DocFlowEngine.ps1"
click node_config "https://github.com/pkr-lab/docflowengine/blob/main/config/docflow-config.psd1"
click node_configload "https://github.com/pkr-lab/docflowengine/blob/main/scripts/DocFlowEngine/Config.ps1"
click node_common "https://github.com/pkr-lab/docflowengine/blob/main/scripts/DocFlowEngine/Common.ps1"
click node_naming "https://github.com/pkr-lab/docflowengine/blob/main/scripts/DocFlowEngine/Naming.ps1"
click node_state "https://github.com/pkr-lab/docflowengine/blob/main/scripts/DocFlowEngine/State.ps1"
click node_lock "https://github.com/pkr-lab/docflowengine/blob/main/scripts/DocFlowEngine/Lock.ps1"
click node_copyback "https://github.com/pkr-lab/docflowengine/blob/main/scripts/DocFlowEngine/CopyBack.ps1"
click node_forward "https://github.com/pkr-lab/docflowengine/blob/main/scripts/DocFlowEngine/CopyForward.ps1"
click node_engine_module "https://github.com/pkr-lab/docflowengine/blob/main/scripts/DocFlowEngine.psm1"
click node_module_manifest "https://github.com/pkr-lab/docflowengine/blob/main/scripts/DocFlowEngine.psd1"

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_runner,node_watch,node_detect,node_rename,node_copy,node_dryrun toneBlue
class node_common,node_naming,node_state,node_lock,node_copyback,node_forward,node_engine_module,node_module_manifest toneAmber
class node_config,node_configload toneMint
class node_user,node_source,node_target toneIndigo
```

## Components

### Document workflow

- [Engine runner](https://github.com/pkr-lab/docflowengine/blob/main/scripts/DocFlowEngine.ps1): `scripts/DocFlowEngine.ps1`
- [Folder monitoring](https://github.com/pkr-lab/docflowengine/blob/main/scripts/DocFlowEngine/CopyForward.ps1): `scripts/DocFlowEngine/CopyForward.ps1`
- [New-document detection](https://github.com/pkr-lab/docflowengine/blob/main/scripts/DocFlowEngine/State.ps1): `scripts/DocFlowEngine/State.ps1`
- [Rule-based renaming](https://github.com/pkr-lab/docflowengine/blob/main/scripts/DocFlowEngine/Rename.ps1): `scripts/DocFlowEngine/Rename.ps1`
- [Target copying](https://github.com/pkr-lab/docflowengine/blob/main/scripts/DocFlowEngine/CopyForward.ps1): `scripts/DocFlowEngine/CopyForward.ps1`
- [Dry-run mode](https://github.com/pkr-lab/docflowengine/blob/main/scripts/DocFlowEngine.ps1): `scripts/DocFlowEngine.ps1`

### Engine internals

- [Shared utilities](https://github.com/pkr-lab/docflowengine/blob/main/scripts/DocFlowEngine/Common.ps1): `scripts/DocFlowEngine/Common.ps1`
- [Naming rules](https://github.com/pkr-lab/docflowengine/blob/main/scripts/DocFlowEngine/Naming.ps1): `scripts/DocFlowEngine/Naming.ps1`
- [Processing state](https://github.com/pkr-lab/docflowengine/blob/main/scripts/DocFlowEngine/State.ps1): `scripts/DocFlowEngine/State.ps1`
- [Execution locking](https://github.com/pkr-lab/docflowengine/blob/main/scripts/DocFlowEngine/Lock.ps1): `scripts/DocFlowEngine/Lock.ps1`
- [Copy-back handling](https://github.com/pkr-lab/docflowengine/blob/main/scripts/DocFlowEngine/CopyBack.ps1): `scripts/DocFlowEngine/CopyBack.ps1`
- [Copy-forward handling](https://github.com/pkr-lab/docflowengine/blob/main/scripts/DocFlowEngine/CopyForward.ps1): `scripts/DocFlowEngine/CopyForward.ps1`
- [Engine module](https://github.com/pkr-lab/docflowengine/blob/main/scripts/DocFlowEngine.psm1): `scripts/DocFlowEngine.psm1`
- [Module manifest](https://github.com/pkr-lab/docflowengine/blob/main/scripts/DocFlowEngine.psd1): `scripts/DocFlowEngine.psd1`

### Configuration

- [Path and rule config](https://github.com/pkr-lab/docflowengine/blob/main/config/docflow-config.psd1): `config/docflow-config.psd1`
- [Configuration handling](https://github.com/pkr-lab/docflowengine/blob/main/scripts/DocFlowEngine/Config.ps1): `scripts/DocFlowEngine/Config.ps1`

### Other components

- **Operator**
- **Source folders**
- **Target structure**

## Connections

- Operator → Engine runner: runs (evidence: `README.md`)
- Engine runner → Path and rule config: uses paths and rules (evidence: `README.md`)
- Source folders → Folder monitoring: is monitored (evidence: `README.md`)
- Folder monitoring → New-document detection: finds new documents (evidence: `README.md`)
- Engine runner → Rule-based renaming: renames by rules (evidence: `README.md`)
- Engine runner → Target copying: copies documents (evidence: `README.md`)
- Target copying → Target structure: writes into (evidence: `README.md`)
- Engine runner → Dry-run mode: supports preview (evidence: `README.md`)
