Core Files in Palmier Pro: App Architecture, Entry Points, and Rendering Pipeline Explained
The core files in Palmier Pro bootstrap the macOS application, manage global project state via the AppState singleton, define media and timeline models, and drive the AVFoundation-based compositing engine that renders final video output.
Palmier Pro is an AI-native video editor for macOS built with Swift 6.2, SwiftUI, and AVFoundation. Understanding the purpose of the core files in Palmier Pro is essential for extending its functionality, debugging rendering issues, or integrating new AI-driven features. These source files are organized into distinct modules that handle everything from app launch to final video export, with clear separation between the bootstrap layer, global state, media models, and the rendering pipeline.
App Bootstrap: main.swift and AppDelegate.swift
The application lifecycle begins in Sources/PalmierPro/App/main.swift, which runs first when the binary starts. This file initializes the structured logging system via Log.bootstrap(), registers bundled fonts through BundledFonts.register(), configures the AccountService and ModelCatalog singletons, and finally instantiates NSApplication with AppDelegate as its delegate.
Sources/PalmierPro/App/AppDelegate.swift conforms to NSApplicationDelegate and handles activation-time responsibilities. It launches Sparkle’s updater, presents the home window, and registers URL-handling callbacks for authentication flows. Together, these two files form the entry point for any app-wide configuration changes or global observer registration.
import AppKit
Log.bootstrap() // init structured logger
Telemetry.start() // begin anonymous usage collection
BundledFonts.register() // make custom fonts available
AccountService.shared.configure()
ModelCatalog.shared.configure()
let app = NSApplication.shared
app.delegate = AppDelegate() // hook the delegate defined in AppDelegate.swift
app.mainMenu = MainMenuBuilder.buildMenu()
app.run() // start the Cocoa run-loop
Global State Management with AppState.swift
Sources/PalmierPro/App/AppState.swift defines the AppState singleton (AppState.shared), which serves as the central coordinator for the entire application lifecycle. Marked with @Observable and @MainActor, this class ensures UI components can safely bind to its properties while guaranteeing updates occur on the main thread.
The singleton tracks the currently active VideoProject, starts and stops the MCP (Media-Control-Protocol) service for remote editing sessions, and exposes methods for creating, opening, and registering projects. It also handles unsaved changes and manages transitions back to the home screen.
let url = URL(fileURLWithPath: "/Users/me/Projects/MyFilm.palmierproj")
AppState.shared.openProject(at: url) // async handling, UI updates, registration
Media Assets and Timeline Models
The Sources/PalmierPro/Models/ directory contains value-type structures that define how Palmier Pro represents editable content. These structs are Codable, enabling straightforward persistence of .palmierproj files.
MediaAsset.swiftdefines theMediaAssetstruct, representing video, audio, or image files with properties for URL, duration, and generated identifiers.Timeline.swiftstores an ordered list of clips, transitions, and effects with precise timing information.VideoLayout.swiftdescribes canvas dimensions, resolution, and aspect ratio used during rendering.
Because these models use value types and conform to Codable, project files serialize efficiently and support version-stable storage of complex editing timelines.
The Compositing Engine
Video rendering in Palmier Pro relies on a custom compositor implementing AVFoundation’s AVVideoCompositing protocol. The core implementation resides in Sources/PalmierPro/Compositing/CustomVideoCompositor.swift, which receives CompositorInstruction objects encoding which clips and effects appear at each frame.
The compositor queries the EffectRegistry defined in Sources/PalmierPro/Compositing/EffectRegistry.swift to look up registered effects, then executes Metal kernels located in Sources/PalmierPro/Compositing/Kernels/*.swift (such as LUTTetraKernel and GrainKernel) to apply color grading, grain, vignettes, and other transformations.
// Register a new effect at app start
EffectRegistry.shared.register(
name: "MyCoolEffect",
factory: { MyCoolEffectKernel() }
)
// Use it in a timeline instruction
let instruction = CompositorInstruction(
effectName: "MyCoolEffect",
// other clip parameters
)
Editor ViewModel Architecture
The Sources/PalmierPro/Editor/ViewModel/ directory contains extensions to EditorViewModel that bridge the underlying models with SwiftUI views. Files like EditorViewModel+GeneratedClips.swift manage selected media, panel visibility, and focus state, while coordinating AI-generated clips and cost estimation.
Because the view-model lives on the main actor, UI code can read and write its properties without explicit dispatch to the main queue. This architecture separates presentation logic from the data models, allowing the compositor and timeline to remain purely functional while the view-model handles user interaction state.
UI Theme and Design Tokens
Visual consistency across Palmier Pro is enforced through Sources/PalmierPro/AppTheme.swift, which centralizes all design tokens including spacing values, font sizes, color palettes, corner radii, and shadow definitions. View components import AppTheme to guarantee a consistent design language, making it trivial to adjust the entire application's appearance from a single source file.
Text("Edit video")
.font(.system(size: AppTheme.FontSize.lg))
.padding(AppTheme.Spacing.m)
.foregroundColor(AppTheme.Text.primary)
Audio Processing and Transcription
The Sources/PalmierPro/Audio/ and Sources/PalmierPro/Transcription/ directories handle media analysis. WaveformExtractor.swift reads audio tracks and generates visual waveform data for display in the timeline, while Transcription.swift runs speech-to-text pipelines, caches results, and exposes searchable transcript data. These modules enable audio-driven editing features such as "jump to spoken word" navigation.
Utility Layer
Cross-cutting concerns live in Sources/PalmierPro/Utilities/. Log.swift provides structured logging with severity levels and telemetry metadata. AsyncSemaphore.swift offers concurrency control primitives used to limit concurrent AI requests. Additional helpers like FileIO, DiskCache, and KeychainStore handle configuration persistence, large asset caching, and secure credential storage respectively.
Summary
- Bootstrap files (
main.swift,AppDelegate.swift) initialize services and start the Cocoa run-loop. AppState.swiftprovides the singleton source of truth for project lifecycle and MCP service management.- Model files (
MediaAsset.swift,Timeline.swift) define value-type project data that serializes to.palmierprojfiles. - Compositing files (
CustomVideoCompositor.swift,EffectRegistry.swift) implement the Metal-based rendering pipeline. - ViewModel extensions bind model data to SwiftUI while managing AI-generated content state.
- Theme and utility files ensure consistent UI design and provide logging, caching, and async primitives.
Frequently Asked Questions
What is the entry point of Palmier Pro?
The entry point is Sources/PalmierPro/App/main.swift, which executes before any UI appears. It bootstraps logging, telemetry, fonts, and account services before creating the NSApplication instance and assigning AppDelegate.swift as its delegate to handle lifecycle callbacks.
How does Palmier Pro manage global application state?
Global state is centralized in the AppState singleton defined in Sources/PalmierPro/App/AppState.swift. This @Observable, @MainActor-bound class tracks the active project, manages the MCP service for remote editing, and provides methods for opening and creating projects that safely update the UI on the main thread.
Where are video effects registered in Palmier Pro?
Video effects are registered in Sources/PalmierPro/Compositing/EffectRegistry.swift, which maintains a mapping of effect names to factory closures. The CustomVideoCompositor queries this registry during rendering to instantiate Metal kernels (such as those in Sources/PalmierPro/Compositing/Kernels/) that apply LUTs, grain, and color corrections.
How does Palmier Pro handle project persistence?
Project persistence relies on the Codable conformance of model structs defined in Sources/PalmierPro/Models/MediaAsset.swift and Sources/PalmierPro/Models/Timeline.swift. These value types serialize to .palmierproj files, storing ordered clip data, effects timing, and canvas layout metadata for restoration across app launches.
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:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →