SPB Git

Repository Public License

ARCHITECTURE.md 5.7 KB

# Architecture

# Principles

  • Native. SwiftUI, with AppKit on the Mac and UIKit on iOS where needed. Web content is rendered by WKWebView. No Electron, no HTML main interface, no private API.
  • One core, platform adapters. Shared logic and shared SwiftUI live in the package; platform differences sit behind #if os(...) adapters, not in divergent copies.
  • One-way dependencies. A module only imports modules below it. Engines never import WebKit or SwiftUI: everything that touches a page or the screen goes through a protocol implemented higher up.
  • Concurrency. Swift 6 strict concurrency. Storage and orchestration are actors or private serial queues; UI types are @MainActor. No disk or network work on the main actor.
  • No third-party dependency (ADR 0002). SQLite, cryptography, networking and embeddings come from the system.

# Modules (Packages/NavigatorKit)

text
                         Apps/Mac        Apps/iOS
                              \            /
                               NavigatorUI                     shared SwiftUI, app model, glue
        ┌──────────┬───────────┬─────┴─────┬───────────┬──────────┬──────────┬─────────┐
   WebRuntime  OrbitEngine PrivacyEngine DownloadEngine MemoryEngine AgentRuntime FlowEngine CanvasEngine SyncEngine
        │          └───────────┴─────┬─────┴───────────┘           │
        │                       Persistence                    ProviderKit
        └──────────────┬─────────────┴──────────────────────────────┘
                 NavigatorCore        Diagnostics        LunarDesign (imports nothing of ours)
Module Role
NavigatorCore Value models with typed identifiers (BrowserWindow, Tab, OrbitSpace, Profile, NavigationEntry, Bookmark, Download, PermissionDecision, Archive, Note, CanvasDocument, AgentRun, Workflow, SyncRecord), the omnibox URL/search classifier, search engines, and the service protocols the web layer calls (PermissionProvider, HistoryRecorder, DownloadSink, SecretStore)
Diagnostics Local logging (os.Logger, private by default), signposts, credential redaction. No telemetry
LunarDesign Lunar Glass: tokens, 12 themes × light/dark, materials (Liquid Glass with fallback), components, 20 module glyphs, the mark
Persistence System SQLite (WAL), versioned migrations, one store per model, crash-safe session journal, FTS5 history search with frecency suggestions, bookmark HTML import/export, data lifecycle and export, Keychain secret store
WebRuntime WebEngine (one per tab) around WKWebView: navigation policy, TLS and authentication challenges, downloads hand-off, isolated script worlds with validated messages, per-profile data stores, content rule lists, orix:// internal pages, suspend/resume
OrbitEngine Spaces and profiles service, orbital layout maths, the five tab layouts, Split geometry, Blink suspension policy, Focus sessions, session batching and restoration model
PrivacyEngine Shield rule generation (WKContentRuleList JSON), per-site permissions with expiry, Ghost sessions, data controls, tracking-parameter stripping, homograph detection
DownloadEngine Download manager (destination, safe file names, risk classification, progress, pause/resume/cancel, recovery)
ProviderKit AI providers behind one protocol: Anthropic, OpenAI, OpenRouter, any compatible endpoint, local on-device. Streaming, tools, bounded retries, usage and cost estimates
AgentRuntime Browsing agent: typed tools, budgets, confirmations, citations, prompt-injection and exfiltration defences
FlowEngine Declarative workflow language: parser, validator, interpreter, dry run, logs, resume
CanvasEngine Canvas document editing model with undo, geometry, attachments, export
SyncEngine Capsule export format, encrypted local transfer, merge logic; CloudKit adapter off by default
MemoryEngine Opt-in local index: full text and on-device sentence embeddings
TestSupport Local HTTP fixture server (redirects, forms, downloads, auth, adversarial pages), test helpers
NavigatorUI App environment, browser store, windows, omnibox, panels, native pages and error states, onboarding

# Data

  • One SQLite database per installation under Application Support; identifiers are UUID strings; schema version is recorded and a database newer than the code is refused, never downgraded. A corrupt file is moved aside, not deleted.
  • Each profile owns a WebKit data store (WKWebsiteDataStore(forIdentifier:)); a Ghost session uses a fresh non-persistent store and is rejected by every write API of the database.
  • Secrets (AI provider keys) live only in the Keychain.
  • Window and tab state is journalled incrementally; a clean-shutdown flag tells a crash from a normal quit.

# Compatibility matrix

Minimum Notes
macOS 15.0 Sandboxed, hardened runtime, Developer ID distribution
iOS / iPadOS 18.0 iPhone and iPad, multiple scenes
Liquid Glass OS 26+ Material fallback below
Profiles all supported systems WKWebsiteDataStore(forIdentifier:) (iOS 17 / macOS 14)
Default browser not available Needs the com.apple.developer.web-browser entitlement granted by Apple

Limits of WebKit as an embedded engine (extensions, DRM, passkeys, Web Push…) are listed in docs/WEBKIT_LIMITATIONS.md with the fallback chosen for each.

Files main
Menu

Theme