# orklann/pep architecture

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

- Interactive diagram: https://gitdiagram.com/orklann/pep
- Repository: https://github.com/orklann/pep

## Overview

PEP is a macOS PDF editor; its documented user workflow is to open an external PDF, edit it, and save a new PDF. The tree shows Gene’s PDF parsing/object model, page and graphics types, and text-editing components alongside the Cocoa window and tool UI. The sampled headers expose few runtime calls, so the main workflow and links to unsampled subsystems are shown as unverified rather than asserted; this map does not imply a fully inspected implementation.

Main entry points: [`PEP/Gene/GInterpreter.h`](https://github.com/orklann/pep/blob/master/PEP/Gene/GInterpreter.h) (Content interpreter), [`PEP/Gene/GDocument.h`](https://github.com/orklann/pep/blob/master/PEP/Gene/GDocument.h) (PDF document), [`PEP/UI/PEPWindow.h`](https://github.com/orklann/pep/blob/master/PEP/UI/PEPWindow.h) (Document window), [`PEP/Gene/GPage.h`](https://github.com/orklann/pep/blob/master/PEP/Gene/GPage.h) (PDF pages)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Mac app UI"]
  node_app_delegate["App delegate<br/>[AppDelegate.h]"]
  node_window["Document window<br/>[PEPWindow.h]"]
  node_side_view["Editing sidebar<br/>[PEPSideView.h]"]
  node_tool["Editing tools<br/>[PEPTool.h]"]
end

subgraph group_pdf["PDF engine"]
  node_lexer["PDF lexer<br/>[GLexer.h]"]
  node_parser["PDF parser<br/>[GParser.h]"]
  node_objects["PDF objects<br/>[GObjects.h]"]
  node_document["PDF document<br/>[GDocument.h]"]
end

subgraph group_render["Page graphics"]
  node_page["PDF pages<br/>[GPage.h]"]
  node_operators["Content operators<br/>[GOperators.h]"]
  node_graphics_state["Graphics state<br/>[GGraphicsState.h]"]
  node_color_spaces["Color spaces"]
  node_functions["PDF functions"]
  node_interpreter["Content interpreter<br/>[GInterpreter.h]"]
end

subgraph group_text["Text editing"]
  node_text_parser["Text parser<br/>[GTextParser.h]"]
  node_text_editor["Text editor<br/>[GTextEditor.h]"]
  node_glyph["Glyph model<br/>[GGlyph.h]"]
  node_text_state["Text state<br/>[GTextState.h]"]
end

node_user(("PDF editor user"))

node_user -.->|"opens PDF"| node_app_delegate
node_app_delegate -->|"uses window"| node_window
node_window -->|"holds document"| node_document
node_window -->|"includes sidebar"| node_side_view
node_parser -->|"uses lexer"| node_lexer
node_parser -->|"parses objects"| node_objects
node_document -.->|"loads PDF"| node_parser
node_document -.->|"provides pages"| node_page
node_page -.->|"interprets content"| node_interpreter
node_interpreter -.->|"processes operators"| node_operators
node_interpreter -.->|"uses state"| node_graphics_state
node_interpreter -.->|"maps colors"| node_color_spaces
node_interpreter -.->|"evaluates functions"| node_functions
node_page -.->|"extracts text"| node_text_parser
node_text_parser -->|"organizes glyphs"| node_glyph
node_side_view -->|"delegates editing"| node_text_editor
node_text_editor -.->|"uses text state"| node_text_state
node_user -.->|"edits PDF"| node_tool
node_user -.->|"saves new PDF"| node_document

click node_app_delegate "https://github.com/orklann/pep/blob/master/PEP/AppDelegate.h"
click node_window "https://github.com/orklann/pep/blob/master/PEP/UI/PEPWindow.h"
click node_side_view "https://github.com/orklann/pep/blob/master/PEP/UI/PEPSideView.h"
click node_tool "https://github.com/orklann/pep/blob/master/PEP/UI/PEPTool.h"
click node_lexer "https://github.com/orklann/pep/blob/master/PEP/Gene/GLexer.h"
click node_parser "https://github.com/orklann/pep/blob/master/PEP/Gene/GParser.h"
click node_objects "https://github.com/orklann/pep/blob/master/PEP/Gene/GObjects.h"
click node_document "https://github.com/orklann/pep/blob/master/PEP/Gene/GDocument.h"
click node_page "https://github.com/orklann/pep/blob/master/PEP/Gene/GPage.h"
click node_operators "https://github.com/orklann/pep/blob/master/PEP/Gene/GOperators.h"
click node_graphics_state "https://github.com/orklann/pep/blob/master/PEP/Gene/GGraphicsState.h"
click node_color_spaces "https://github.com/orklann/pep/tree/master/PEP/Gene/Color%20Spaces"
click node_functions "https://github.com/orklann/pep/tree/master/PEP/Gene/Functions"
click node_interpreter "https://github.com/orklann/pep/blob/master/PEP/Gene/GInterpreter.h"
click node_text_parser "https://github.com/orklann/pep/blob/master/PEP/Gene/GTextParser.h"
click node_text_editor "https://github.com/orklann/pep/blob/master/PEP/Gene/GTextEditor.h"
click node_glyph "https://github.com/orklann/pep/blob/master/PEP/Gene/GGlyph.h"
click node_text_state "https://github.com/orklann/pep/blob/master/PEP/Gene/GTextState.h"

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_app_delegate,node_window,node_side_view,node_tool,node_user toneBlue
class node_lexer,node_parser,node_objects,node_document toneAmber
class node_page,node_operators,node_graphics_state,node_color_spaces,node_functions,node_interpreter toneMint
class node_text_parser,node_text_editor,node_glyph,node_text_state toneRose
```

## Components

### Mac app UI

- [App delegate](https://github.com/orklann/pep/blob/master/PEP/AppDelegate.h): `PEP/AppDelegate.h`
- [Document window](https://github.com/orklann/pep/blob/master/PEP/UI/PEPWindow.h): `PEP/UI/PEPWindow.h`
- [Editing sidebar](https://github.com/orklann/pep/blob/master/PEP/UI/PEPSideView.h): `PEP/UI/PEPSideView.h`
- [Editing tools](https://github.com/orklann/pep/blob/master/PEP/UI/PEPTool.h): `PEP/UI/PEPTool.h`

### PDF engine

- [PDF lexer](https://github.com/orklann/pep/blob/master/PEP/Gene/GLexer.h): `PEP/Gene/GLexer.h`
- [PDF parser](https://github.com/orklann/pep/blob/master/PEP/Gene/GParser.h): `PEP/Gene/GParser.h`
- [PDF objects](https://github.com/orklann/pep/blob/master/PEP/Gene/GObjects.h): `PEP/Gene/GObjects.h`
- [PDF document](https://github.com/orklann/pep/blob/master/PEP/Gene/GDocument.h): `PEP/Gene/GDocument.h`

### Page graphics

- [PDF pages](https://github.com/orklann/pep/blob/master/PEP/Gene/GPage.h): `PEP/Gene/GPage.h`
- [Content operators](https://github.com/orklann/pep/blob/master/PEP/Gene/GOperators.h): `PEP/Gene/GOperators.h`
- [Graphics state](https://github.com/orklann/pep/blob/master/PEP/Gene/GGraphicsState.h): `PEP/Gene/GGraphicsState.h`
- [Color spaces](https://github.com/orklann/pep/tree/master/PEP/Gene/Color%20Spaces): `PEP/Gene/Color Spaces`
- [PDF functions](https://github.com/orklann/pep/tree/master/PEP/Gene/Functions): `PEP/Gene/Functions`
- [Content interpreter](https://github.com/orklann/pep/blob/master/PEP/Gene/GInterpreter.h): `PEP/Gene/GInterpreter.h`

### Text editing

- [Text parser](https://github.com/orklann/pep/blob/master/PEP/Gene/GTextParser.h): `PEP/Gene/GTextParser.h`
- [Text editor](https://github.com/orklann/pep/blob/master/PEP/Gene/GTextEditor.h): `PEP/Gene/GTextEditor.h`
- [Glyph model](https://github.com/orklann/pep/blob/master/PEP/Gene/GGlyph.h): `PEP/Gene/GGlyph.h`
- [Text state](https://github.com/orklann/pep/blob/master/PEP/Gene/GTextState.h): `PEP/Gene/GTextState.h`

### Other components

- **PDF editor user**

## Connections

- PDF editor user → App delegate: opens PDF (evidence: `README.md`)
- App delegate → Document window: uses window (evidence: `PEP/AppDelegate.h`)
- Document window → PDF document: holds document (evidence: `PEP/UI/PEPWindow.h`)
- Document window → Editing sidebar: includes sidebar (evidence: `PEP/UI/PEPWindow.h`)
- PDF parser → PDF lexer: uses lexer (evidence: `PEP/Gene/GParser.h`)
- PDF parser → PDF objects: parses objects (evidence: `PEP/Gene/GParser.h`)
- PDF document → PDF parser: loads PDF
- PDF document → PDF pages: provides pages
- PDF pages → Content interpreter: interprets content
- Content interpreter → Content operators: processes operators
- Content interpreter → Graphics state: uses state
- Content interpreter → Color spaces: maps colors
- Content interpreter → PDF functions: evaluates functions
- PDF pages → Text parser: extracts text
- Text parser → Glyph model: organizes glyphs (evidence: `PEP/Gene/GTextParser.h`)
- Editing sidebar → Text editor: delegates editing (evidence: `PEP/UI/PEPSideView.h`)
- Text editor → Text state: uses text state
- PDF editor user → Editing tools: edits PDF (evidence: `README.md`)
- PDF editor user → PDF document: saves new PDF (evidence: `README.md`)
