Architecture of Palmier Pro: Modular Swift Native macOS Video Editing

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:

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 reads palmier-project files via Export/PalmierProjectExporter into a VideoProject containing a Timeline (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 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).
  4. AI Agent Interaction: The built-in agent (Agent/AgentService.swift) queries models, requests edits, or invokes generation steps via the Generation subsystem.
  5. Export: Export/ExportService.swift assembles projects into .palmier bundles or other formats like XML via 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 and implemented in MediaPanel/MediaPanelView.swift.

Design System and Theme Management

All visual styling centralizes in 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.

// 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/Sources/PalmierPro/UI/AppTheme.swift)

Key Components and Code Examples

Real-Time Preview Engine

The VideoEngine class in Preview/VideoEngine.swift drives AVFoundation pipelines for live preview rendering:

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, Preview/TimelineRenderer.swift.

Timeline Manipulation

Timeline modifications occur through the model layer in Models/Timeline.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, Models/ClipType.swift.

AI Agent Integration

The built-in MCP (Model Context Protocol) agent enables chat-based editing through Agent/AgentService.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, 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 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 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, 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. It provides chat-based tooling that can query models, request edits, and invoke generation steps through 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, 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.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →