# processing/processing4 architecture

> Architecture diagram of the GitHub repository processing/processing4, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-08). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/processing/processing4
- Repository: https://github.com/processing/processing4

## Overview

##### Major Components
- Core Engine (found under the “core” directory)
– Contains fundamental classes (such as PApplet, PGraphics, PImage, etc.) that form the rendering engine, input event loop, data structures, and overall sketch lifecycle.
- Application / IDE Layer (primarily in the “app” directory and parts of the “java” folder)
– Implements the Processing Development Environment (PDE) with UI components (editors, menus, toolbars, consoles) and user interaction management.
- Mode and Preprocessor Modules (located under “java/mode” and “java/preprocessor”)
– Provide code analysis, lexical parsing, preprocessing (e.g., transforming sketches into valid Java code), syntax highlighting, error detection, and code completion.
- Library Modules and Extensions (scattered in “java/libraries”, “core/library”, etc.)
– Include additional functionality (for example, handling PDFs, SVGs, networking, serial communication, IO, and other multimedia extensions) that enhance or extend the core engine.
- Build and Deployment Tools (directories such as “build”, “gradle”, “build.gradle.kts”, “ant”, etc.)
– These include scripts and configurations to compile and package the software for multiple platforms (macOS, Windows, Linux) as well as tools for signing, code formatting, and integration with continuous integration services.
- Testing and Examples (found in “app/test”, “core/test”, “java/test”)
– Provide unit, integration, and example sketches demonstrating usage and ensuring quality across the various modules.

##### Relationships and Data Flow
- The Application/IDE layer interacts with the Core Engine by calling its API functions (rendering, event-handling, etc.).
- The Mode and Preprocessor modules transform user sketches (source code) before these are compiled and run on top of the Core Engine.
- The Build and Deployment tools coordinate the compilation and packaging of the entire system across various platforms. Represent these as a “toolchain” that feeds into all modules.

##### Architectural Patterns and Technologies
- The project is modular and multi-layered. The separation between UI (IDE), business logic (core engine), and auxiliary components (modes, libraries, build scripts) is critical.
- Gradle is used for build automation and dependency management.
- The system leverages Java (and Kotlin for some build scripts) with object‐oriented design, along with some native interfaces (e.g., for platform-specific builds).
- Mention that preprocessor modules implement a transformation pipeline (similar to a compiler front-end) before compiling sketches.

## Diagram (Mermaid)

```mermaid
graph TD
    %% Infrastructure Layer
    subgraph "Infrastructure Layer"
        BuildDep("Build & Deployment\n(Gradle, build scripts, platform configs)"):::infrastructure
        TestEx("Testing & Examples\n(Unit/Integration Tests & Example Sketches)"):::testing
    end

    %% Development Layer
    subgraph "Development Layer"
        AppIDE("Application/IDE\n(UI Components: Editor, Console, etc.)"):::development
        ModePre("Mode & Preprocessor\n(Code analysis, preprocessing, transformation)"):::development
    end

    %% Runtime Layer
    subgraph "Runtime Layer"
        CoreEngine("Core Engine\n(Rendering, Event Handling, Data Management)"):::runtime
        LibExt("Library Extensions\n(PDF, SVG, Networking, IO, etc.)"):::runtime
    end

    %% Relationships between layers
    AppIDE -->|"callsAPI"| CoreEngine
    ModePre -->|"transforms"| CoreEngine
    ModePre -->|"transforms"| AppIDE
    LibExt -->|"extends"| CoreEngine
    LibExt -->|"addsUtility"| AppIDE
    BuildDep -->|"orchestrates"| CoreEngine
    BuildDep -->|"orchestrates"| AppIDE
    BuildDep -->|"orchestrates"| ModePre
    BuildDep -->|"orchestrates"| LibExt
    TestEx -->|"validates"| CoreEngine
    TestEx -->|"validates"| AppIDE
    TestEx -->|"validates"| ModePre
    TestEx -->|"validates"| LibExt

    %% Click Events for Component Mappings
    click CoreEngine "https://github.com/processing/processing4/tree/main/core/src/processing/core"
    click AppIDE "https://github.com/processing/processing4/tree/main/app/src/processing/app"
    click ModePre "https://github.com/processing/processing4/tree/main/java/mode"
    click ModePre "https://github.com/processing/processing4/tree/main/java/preprocessor"
    click LibExt "https://github.com/processing/processing4/tree/main/java/libraries"
    click BuildDep "https://github.com/processing/processing4/tree/main/build"
    click BuildDep "https://github.com/processing/processing4/tree/main/gradle"
    click BuildDep "https://github.com/processing/processing4/blob/main/build.gradle.kts"
    click TestEx "https://github.com/processing/processing4/tree/main/app/test"
    click TestEx "https://github.com/processing/processing4/tree/main/core/test"
    click TestEx "https://github.com/processing/processing4/tree/main/java/test"

    %% Styles
    classDef runtime fill:#B3E5FC,stroke:#0277BD,stroke-width:2px;
    classDef development fill:#FFCDD2,stroke:#C62828,stroke-width:2px;
    classDef infrastructure fill:#DCEDC8,stroke:#388E3C,stroke-width:2px;
    classDef testing fill:#F8BBD0,stroke:#AD1457,stroke-width:2px;
```
