Architecture
TablePro is built with:- SwiftUI for the UI
- AppKit for low-level macOS integration
- Swift Concurrency (async/await, actors) for concurrent operations
- Native C libraries for database connectivity
Dependencies
SPM dependencies:| Package | Version | Purpose |
|---|---|---|
| CodeEditSourceEditor | 0.15.2+ | Tree-sitter-powered code editor for the SQL editor |
| Sparkle | 2.x | Auto-update framework with EdDSA signing |
CodeEditSourceEditor bundles a SwiftLint plugin that requires
-skipPackagePluginValidation for CLI builds. See Building.Directory Structure
TablePro
Core
Views
Models
ViewModels
Extensions
Theme
Resources
Plugins
TableProPluginKit
MySQLDriverPlugin
PostgreSQLDriverPlugin
...
Libs
TableProTests
scripts
Design Patterns
MVVM Architecture
Models: Pure data structures (structs, enums)Protocol-Oriented Design
All database drivers conform to a single protocol:.tableplugin bundles loaded at runtime. Each plugin implements DriverPlugin and PluginDatabaseDriver from the shared TableProPluginKit framework. PluginDriverAdapter bridges PluginDatabaseDriver to the core DatabaseDriver protocol.
Actor Isolation
Concurrent operations use Swift actors:Plugin System
Driver creation uses a plugin-based factory.PluginManager discovers and loads .tableplugin bundles at runtime. DatabaseDriverFactory looks up plugins via DatabaseType.pluginTypeId and wraps them with PluginDriverAdapter to conform to the core DatabaseDriver protocol. No switch statement or hardcoded driver list is needed.
Key Components
DatabaseManager
Central manager for all database operations:- Manages active sessions
- Coordinates connections/disconnections
- Handles SSH tunnel lifecycle
- Publishes state changes to UI
Database Driver Plugins
Each driver is a.tableplugin bundle under Plugins/. MySQL, PostgreSQL, and SQLite are built into the app bundle; the rest are distributed via the plugin registry and downloaded on demand.
| Plugin | Database Types | C Bridge | Distribution |
|---|---|---|---|
| MySQLDriverPlugin | MySQL, MariaDB | CMariaDB (libmariadb) | Built-in |
| PostgreSQLDriverPlugin | PostgreSQL, Redshift | CLibPQ (libpq) | Built-in |
| SQLiteDriverPlugin | SQLite | Foundation sqlite3 | Built-in |
| ClickHouseDriverPlugin | ClickHouse | URLSession HTTP | Registry |
| MSSQLDriverPlugin | SQL Server | CFreeTDS | Registry |
| MongoDBDriverPlugin | MongoDB | CLibMongoc | Registry |
| RedisDriverPlugin | Redis | CRedis | Registry |
| DuckDBDriverPlugin | DuckDB | CDuckDB | Registry |
| OracleDriverPlugin | Oracle | OracleNIO (SPM) | Registry |
Autocomplete Engine
- CompletionEngine: Main entry point
- SQLContextAnalyzer: Parses query context
- SQLSchemaProvider: Provides schema information
- SQLKeywords: SQL keyword definitions
SSH Tunnel Manager
Actor-based SSH tunnel management:- Port forwarding via system
ssh - Password and key authentication
- Health monitoring
- Automatic cleanup
Data Flow
Connection Flow
Query Execution Flow
State Management
Published Properties
UI state uses@Published:
App Storage
Settings persist via@AppStorage:
Environment
Shared state via SwiftUI environment:Error Handling
Driver Errors
Each driver defines specific errors:Error Propagation
Errors propagate through async/await:Testing
Unit Tests
Tests live inTableProTests/:
