# Architecture of Palmier Pro: Modular Swift Native macOS Video Editing

> Explore the modular Swift native macOS video editing architecture of Palmier Pro. Discover its layered design, SwiftUI UI, AppKit integration, and key functional modules like Preview, Export, and Generation.

- Repository: [Palmier/palmier-pro](https://github.com/palmier-io/palmier-pro)
- Tags: architecture
- Published: 2026-06-22

---

**Palmier Pro is a native macOS video editing application built with Swift 6.2 that uses a layered, feature-modular architecture combining SwiftUI for the interface and AppKit for low-level interactions, organized into distinct modules including App, UI, Models, Preview, Generation, Export, Agent, MediaPanel, Settings, and Utilities.**

The palmier-io/palmier-pro repository implements a sophisticated native architecture designed specifically for professional video editing on macOS. This Swift 6.2 codebase demonstrates clean separation of concerns through its modular design, enabling real-time preview rendering, AI-assisted generation, and seamless export capabilities while maintaining declarative UI patterns.

## Modular Architecture Overview

### Core Module Responsibilities

The **architecture of Palmier Pro** organizes functionality into ten distinct modules, each owning specific responsibilities:

- **App**: Handles application bootstrap, menu management, update handling, and global state via [`App/main.swift`](https://github.com/palmier-io/palmier-pro/blob/main/App/main.swift), [`App/AppState.swift`](https://github.com/palmier-io/palmier-pro/blob/main/App/AppState.swift), and [`App/AppDelegate.swift`](https://github.com/palmier-io/palmier-pro/blob/main/App/AppDelegate.swift)
- **UI**: Contains design-system constants and reusable components in [`UI/AppTheme.swift`](https://github.com/palmier-io/palmier-pro/blob/main/UI/AppTheme.swift), [`UI/SidebarRowButton.swift`](https://github.com/palmier-io/palmier-pro/blob/main/UI/SidebarRowButton.swift), and [`UI/GeneratingOverlay.swift`](https://github.com/palmier-io/palmier-pro/blob/main/UI/GeneratingOverlay.swift)
- **Models**: Defines core data structures including timelines, media assets, keyframes, and text layout in [`Models/Timeline.swift`](https://github.com/palmier-io/palmier-pro/blob/main/Models/Timeline.swift), [`Models/MediaAsset.swift`](https://github.com/palmier-io/palmier-pro/blob/main/Models/MediaAsset.swift), and [`Models/ClipType.swift`](https://github.com/palmier-io/palmier-pro/blob/main/Models/ClipType.swift)
- **Preview**: Manages real-time video rendering and composition building through [`Preview/VideoEngine.swift`](https://github.com/palmier-io/palmier-pro/blob/main/Preview/VideoEngine.swift), [`Preview/TimelineRenderer.swift`](https://github.com/palmier-io/palmier-pro/blob/main/Preview/TimelineRenderer.swift), and [`Preview/CompositionBuilder.swift`](https://github.com/palmier-io/palmier-pro/blob/main/Preview/CompositionBuilder.swift)
- **Generation**: Implements AI-assisted editing and video compression in [`Generation/GenerationBackend.swift`](https://github.com/palmier-io/palmier-pro/blob/main/Generation/GenerationBackend.swift), [`Generation/Edit/EditAction.swift`](https://github.com/palmier-io/palmier-pro/blob/main/Generation/Edit/EditAction.swift), and [`Generation/VideoCompressor.swift`](https://github.com/palmier-io/palmier-pro/blob/main/Generation/VideoCompressor.swift)
- **Export**: Handles project serialization via [`Export/PalmierProjectExporter.swift`](https://github.com/palmier-io/palmier-pro/blob/main/Export/PalmierProjectExporter.swift) and [`Export/XMLExporter.swift`](https://github.com/palmier-io/palmier-pro/blob/main/Export/XMLExporter.swift)
- **Agent**: Runs the built-in AI assistant (MCP) through [`Agent/AgentService.swift`](https://github.com/palmier-io/palmier-pro/blob/main/Agent/AgentService.swift), [`Agent/ChatSessionStore.swift`](https://github.com/palmier-io/palmier-pro/blob/main/Agent/ChatSessionStore.swift), and [`Agent/MCP/MCPHTTPServer.swift`](https://github.com/palmier-io/palmier-pro/blob/main/Agent/MCP/MCPHTTPServer.swift)
- **MediaPanel**: Provides media browsing and import UI in [`MediaPanel/MediaPanelView.swift`](https://github.com/palmier-io/palmier-pro/blob/main/MediaPanel/MediaPanelView.swift) and [`MediaPanel/CaptionsTab/CaptionBuilder.swift`](https://github.com/palmier-io/palmier-pro/blob/main/MediaPanel/CaptionsTab/CaptionBuilder.swift)
- **Settings**: Manages preference panes through [`Settings/SettingsView.swift`](https://github.com/palmier-io/palmier-pro/blob/main/Settings/SettingsView.swift) and [`Settings/AccountPane.swift`](https://github.com/palmier-io/palmier-pro/blob/main/Settings/AccountPane.swift)
- **Utilities**: Offers shared helpers for logging, caching, and formatting in [`Utilities/Log.swift`](https://github.com/palmier-io/palmier-pro/blob/main/Utilities/Log.swift), [`Utilities/DiskCache.swift`](https://github.com/palmier-io/palmier-pro/blob/main/Utilities/DiskCache.swift), and [`Utilities/TimeFormatting.swift`](https://github.com/palmier-io/palmier-pro/blob/main/Utilities/TimeFormatting.swift)

### Layered Design Principles

The architecture follows a **layered, feature-modular design** where UI components depend on the model layer, the preview engine consumes models to generate frames, and generation/export pipelines operate on the same model objects. This separation ensures SwiftUI views remain declarative while heavy-weight processing stays isolated in pure Swift modules.

## Data Flow Through the System

The architecture implements a five-stage data pipeline:

1. **Project Load**: [`Project/VideoProject.swift`](https://github.com/palmier-io/palmier-pro/blob/main/Project/VideoProject.swift) reads palmier-project files via `Export/PalmierProjectExporter` into a `VideoProject` containing a `Timeline` ([`Models/Timeline.swift`](https://github.com/palmier-io/palmier-pro/blob/main/Models/Timeline.swift)) and `MediaAsset` collections.
2. **Editing**: UI actions mutate models through command objects in the `Editor/` folder, emitting change notifications consumed by both the UI and preview renderer.
3. **Preview Rendering**: [`Preview/VideoEngine.swift`](https://github.com/palmier-io/palmier-pro/blob/main/Preview/VideoEngine.swift) drives an AVFoundation pipeline, pulling frames from the current `Timeline` and compositing overlays through `Preview/Overlay*` views, feeding the live preview window ([`Preview/PreviewView.swift`](https://github.com/palmier-io/palmier-pro/blob/main/Preview/PreviewView.swift)).
4. **AI Agent Interaction**: The built-in agent ([`Agent/AgentService.swift`](https://github.com/palmier-io/palmier-pro/blob/main/Agent/AgentService.swift)) queries models, requests edits, or invokes generation steps via the `Generation` subsystem.
5. **Export**: [`Export/ExportService.swift`](https://github.com/palmier-io/palmier-pro/blob/main/Export/ExportService.swift) assembles projects into `.palmier` bundles or other formats like XML via [`Export/XMLExporter.swift`](https://github.com/palmier-io/palmier-pro/blob/main/Export/XMLExporter.swift).

## SwiftUI and AppKit Integration

While **SwiftUI** handles the majority of the interface—including settings panes, timeline views, and generation UI—the architecture strategically incorporates **AppKit** where SwiftUI limitations exist. Specifically, parent-level drag-and-drop operations that must shadow child drop targets utilize AppKit implementations in `MediaPanel/DropArea`. This hybrid approach is documented in [`AGENTS.md`](https://github.com/palmier-io/palmier-pro/blob/main/AGENTS.md) and implemented in [`MediaPanel/MediaPanelView.swift`](https://github.com/palmier-io/palmier-pro/blob/main/MediaPanel/MediaPanelView.swift).

## Design System and Theme Management

All visual styling centralizes in [`UI/AppTheme.swift`](https://github.com/palmier-io/palmier-pro/blob/main/UI/AppTheme.swift), which defines colors, spacing, typography, shadows, and animation durations. UI components import `AppTheme` rather than hard-coding values, ensuring consistency across the application.

```swift
// Example: using a theme color in a SwiftUI view
Text("Hello")
    .font(.system(size: AppTheme.FontSize.md, weight: AppTheme.FontWeight.medium))
    .foregroundColor(AppTheme.Text.primaryColor)

```

*Source:* [[`UI/AppTheme.swift`](https://github.com/palmier-io/palmier-pro/blob/main/UI/AppTheme.swift)](https://github.com/palmier-io/palmier-pro/blob/main/Sources/PalmierPro/UI/AppTheme.swift)

## Key Components and Code Examples

### Real-Time Preview Engine

The `VideoEngine` class in [`Preview/VideoEngine.swift`](https://github.com/palmier-io/palmier-pro/blob/main/Preview/VideoEngine.swift) drives AVFoundation pipelines for live preview rendering:

```swift
import PalmierPro

let engine = VideoEngine(
    timeline: myTimeline,               // Models/Timeline
    renderSize: CGSize(width: 1280, height: 720),
    onFrame: { image in
        // display the rendered CGImage in the UI
    })
engine.start()

```

*Relevant files:* [`Preview/VideoEngine.swift`](https://github.com/palmier-io/palmier-pro/blob/main/Preview/VideoEngine.swift), [`Preview/TimelineRenderer.swift`](https://github.com/palmier-io/palmier-pro/blob/main/Preview/TimelineRenderer.swift).

### Timeline Manipulation

Timeline modifications occur through the model layer in [`Models/Timeline.swift`](https://github.com/palmier-io/palmier-pro/blob/main/Models/Timeline.swift):

```swift
var mutableTimeline = videoProject.timeline
let newClip = Clip(
    id: UUID(),
    type: .video,
    mediaID: selectedMediaAsset.id,
    range: .init(start: 0, end: 10))
mutableTimeline.append(clip: newClip)
videoProject.timeline = mutableTimeline

```

*Relevant files:* [`Models/Timeline.swift`](https://github.com/palmier-io/palmier-pro/blob/main/Models/Timeline.swift), [`Models/ClipType.swift`](https://github.com/palmier-io/palmier-pro/blob/main/Models/ClipType.swift).

### AI Agent Integration

The built-in MCP (Model Context Protocol) agent enables chat-based editing through [`Agent/AgentService.swift`](https://github.com/palmier-io/palmier-pro/blob/main/Agent/AgentService.swift):

```swift
let agent = AgentService.shared
agent.send(message: "Generate a caption for this segment", context: myTimeline) { response in
    // response contains generated text
}

```

*Relevant files:* [`Agent/AgentService.swift`](https://github.com/palmier-io/palmier-pro/blob/main/Agent/AgentService.swift), [`Agent/MCP/MCPHTTPServer.swift`](https://github.com/palmier-io/palmier-pro/blob/main/Agent/MCP/MCPHTTPServer.swift).

## Summary

- **Palmier Pro** implements a **layered, feature-modular architecture** using Swift 6.2, separating concerns into ten distinct modules from Models to Agent.
- The **data flow** progresses from Project Load through Editing, Preview Rendering, AI Agent Interaction, and Export, maintaining clean separation between UI and processing layers.
- **SwiftUI** dominates the interface while **AppKit** handles specific low-level interactions like drag-and-drop shadowing.
- **AppTheme.swift** centralizes design system constants, ensuring visual consistency without hard-coded values.
- Real-time video rendering relies on [`VideoEngine.swift`](https://github.com/palmier-io/palmier-pro/blob/main/VideoEngine.swift) driving AVFoundation pipelines based on `Timeline` model data.
- The **Agent module** runs a local HTTP server providing AI-assisted editing capabilities through the MCP protocol.

## Frequently Asked Questions

### What programming language and frameworks does Palmier Pro use?

Palmier Pro is built with **Swift 6.2** and uses a hybrid approach of **SwiftUI** for the majority of the user interface and **AppKit** for specific low-level functionality like drag-and-drop operations. The architecture leverages AVFoundation for video processing and implements a local HTTP server for AI agent communication.

### How does Palmier Pro handle real-time video preview rendering?

The application uses [`Preview/VideoEngine.swift`](https://github.com/palmier-io/palmier-pro/blob/main/Preview/VideoEngine.swift) to drive an AVFoundation pipeline that pulls frames from the current `Timeline` model and composites overlays in real-time. This engine feeds the live preview window defined in [`Preview/PreviewView.swift`](https://github.com/palmier-io/palmier-pro/blob/main/Preview/PreviewView.swift), consuming model change notifications to update the display.

### What is the role of the Agent module in Palmier Pro?

The **Agent module** implements a built-in AI assistant using the Model Context Protocol (MCP), running a local HTTP server via [`Agent/MCP/MCPHTTPServer.swift`](https://github.com/palmier-io/palmier-pro/blob/main/Agent/MCP/MCPHTTPServer.swift). It provides chat-based tooling that can query models, request edits, and invoke generation steps through [`Agent/AgentService.swift`](https://github.com/palmier-io/palmier-pro/blob/main/Agent/AgentService.swift), integrating AI capabilities directly into the editing workflow.

### How is the design system managed across the application?

All visual styling centralizes in [`UI/AppTheme.swift`](https://github.com/palmier-io/palmier-pro/blob/main/UI/AppTheme.swift), which defines colors, spacing, typography, shadows, and animation durations. UI components reference these theme constants rather than hard-coding values, ensuring consistent appearance across settings panes, timeline views, and media panels.