How tableproapp/tablepro works
1. Repository shape
- This is a multi-target Apple-native database client, not a single app. The top-level product is the macOS app TablePro, with a companion iOS app TableProMobile and a TableProWidget.
- Shared functionality is split across local Swift packages and plugin bundles, with Packages/TableProCore acting as the main reusable domain layer.
2. Primary runtime boundary
- The macOS app is the richest client: it owns the main windowing, sidebar, query tabs, data grid, settings, AI chat, MCP server, plugin management, SSH/tunnel orchestration, and sync.
- TableProMobile reimplements a smaller mobile-first browsing/query flow with its own drivers, storage, and iOS platform services.
- The widget is a lightweight extension that exposes quick-connect and live activity views.
3. Core data model and persistence
- The app stores connections, groups, tags, query history, favorites, settings, SSH profiles, licenses, and tab/session state in local storage abstractions under TablePro/Core/Storage.
- Sensitive data is isolated through keychain helpers and secure-store abstractions; connection records carry only the metadata needed to reconstruct sessions.
- CloudKit sync exists for selected user data such as connections, groups, tags, and settings, with conflict resolution and record mapping in TablePro/Core/Sync.
4. Connection and transport pipeline
- User-entered connection settings flow through parsers, validators, and platform-specific helpers before reaching DatabaseManager.
- DatabaseManager coordinates the active connection state, health monitoring, metadata loading, query execution, schema discovery, and tunnel setup.
- The transport chain can include direct DB sockets, SSH tunnels, Cloudflare tunnels, and per-database auth flows such as AWS credentials, token stores, or SSL/TLS negotiation.
5. Database execution layer
- Query execution is centralized in services/coordinators under TablePro/Core/Services/Query and TablePro/Core/Coordinators.
- Those components build SQL, route multi-statement requests, fetch schema and metadata, page through rows, and convert results into app models.
- Row editing and schema mutations are treated separately from read-only query flows so the UI can gate destructive operations and generate the correct SQL per dialect.
6. Built-in drivers vs plugin drivers
- Some database support ships in the app, while heavier or less common engines are delivered as plugins from Plugins/.
- Built-in support covers engines like PostgreSQL, MySQL/MariaDB, SQLite, ClickHouse, Redis, and related variants through native Swift code plus C bridges.
- Plugin drivers extend the same core plugin protocol through TableProPluginKit, letting the app discover capabilities, validate signatures, install/update plugins, and adapt them into the shared query/metadata model.
7. Native C library boundary
- Many drivers wrap native C clients rather than JDBC or JS runtimes: libpq, MariaDB, FreeTDS, libssh2, hiredis, mongoc, and DuckDB are all present as bridged dependencies.
- This means the app’s driver architecture is close to the metal: Swift orchestrates native network/database libraries, while the C layer handles protocol specifics and performance-sensitive I/O.
8. Editor and results UI
- The main editing surface is split between a SQL editor and a data grid.
- The SQL editor is backed by dedicated editor packages (CodeEditTextView, CodeEditSourceEditor, and CodeEditLanguages) for text layout, syntax highlighting, completions, and tree-sitter language support.
- The results side uses a custom data grid with inline editing, selection, filtering, sorting, undo/redo, row overlays, and specialized viewers for JSON, PHP serialized data, hex, and text.
9. UI composition and windowing
- The app follows a coordinator-heavy UI structure: view models and coordinators mediate between services and SwiftUI/AppKit views.
- Main app areas include the sidebar tree, query tabs, results tabs, structure editor, server dashboard, quick switcher, and right-side inspector/panel flows.
- Window management, tab persistence, split views, and restoration are first-class infrastructure rather than incidental UI details.
10. Import/export and foreign app migration
- TablePro includes import/export as a core capability, not an add-on.
- Data can move through CSV, JSON, SQL, XLSX, and connection-export/import flows, with dedicated services and plugin-based import/export adapters.
- There is also support for importing connection metadata from other database tools such as DBeaver, DataGrip, Navicat, TablePlus, Sequel Ace, and Beekeeper Studio.
11. AI subsystem
- AI is treated as an integrated feature set with its own provider registry, prompt templates, tool framework, and streaming transport handling.
- Providers include local and remote backends such as Ollama, OpenAI-compatible APIs, Anthropic, Gemini, Cursor, and ChatGPT Codex integrations.
- The AI layer can read schema context, trigger tools like list tables or execute query, and render inline suggestions or chat-based assistance inside the app.
12. MCP and external automation
- The app exposes an MCP server stack under TablePro/Core/MCP so external clients can interact with connections, schemas, queries, and tabs.
- The MCP layer includes its own wire protocol, transports, JSON-RPC/SSE codecs, auth, session management, rate limiting, and tool registry.
- This is a distinct boundary from the normal UI: it lets tools like Cursor, Claude Desktop, and Raycast control TablePro through a controlled protocol rather than direct UI automation.
13. Mobile-specific architecture
- TableProMobile mirrors the product in a constrained form: connection management, browsing, query editing, row detail, import/export, and sync.
- The mobile app uses its own platform abstractions for biometrics, app lock state, local network permissions, file bookmarks, and keychain-backed secure storage.
- It also includes a widget/live-activity surface for quick connection access, sharing data with the main app through shared storage models.
14. Operational concerns and tooling
- The repository is built and tested as a large Swift/Xcode workspace with Swift Package Manager modules, CI workflows, and per-platform test suites.
- Release engineering includes plugin builds, artifact packaging, appcast generation, and native library build scripts.
- Documentation is part of the architecture: the repo contains docs for features, database support, plugin registry, external APIs, and development workflows, which is important because the product surface is spread across app, plugins, AI, and automation integrations.
Main entry points: DatabaseManager.swift Database Core · QueryExecutor.swift Query Services · ConnectionStorage.swift Storage · TableProApp.swift TablePro
Components 22
Desktop App
macOS client and app-level orchestration
- TablePro · Main desktop client with windowing, query workbench, settings, AI, MCP, plugins, sync, and database operations
TablePro/TableProApp.swift - Main UI · Sidebar, tabs, inspector, split views, and major app navigation flows
TablePro/Views/Main/MainContentView.swift - SQL Editor · Query editor composition, completion adapter, and editor coordination
TablePro/Views/Editor/SQLEditorView.swift - Results Grid · Query results table, inline editing, selection, filtering, sorting, and viewers
TablePro/Views/Results/DataGridView.swift - Settings · App settings, licenses, AI providers, plugins, MCP, sync, and appearance
TablePro/Views/Settings/SettingsView.swift
Mobile Suite
iOS app and widget surfaces
- TableProMobile · Mobile-first client with browsing, querying, row detail, import/export, and sync
TableProMobile/TableProMobile/TableProMobileApp.swift - Widget · Quick-connect and live activity widget surface for shared connections
TableProMobile/TableProWidget/QuickConnectWidget.swift
Shared Core
Reusable domain, storage, sync, and service layers
- AI Layer · Providers, chat tools, prompts, streaming, and inline suggestion features
TablePro/Core/AI/AIProvider.swift - MCP Server · External protocol boundary for tools, transports, auth, sessions, and rate limiting
TablePro/Core/MCP/MCPServerManager.swift - Database Core · Connection parsing, manager, health, metadata, schema, queries, SSH, and tunnels
TablePro/Core/Database/DatabaseManager.swift - Query Services · Query execution, pagination, row parsing, schema services, and result routing
TablePro/Core/Services/Query/QueryExecutor.swift - Storage · Connections, groups, tags, favorites, history, settings, keychain, and session state
TablePro/Core/Storage/ConnectionStorage.swift - Sync · CloudKit sync, record mapping, metadata, and conflict handling
TablePro/Core/Sync/CloudKitSyncEngine.swift - Import/Export · CSV, JSON, SQL, XLSX, connection transfer, and foreign app migration
TablePro/Core/Services/Export/ImportService.swift - SSH/Tunnels · SSH auth, tunnels, host verification, config resolution, and relay I/O
TablePro/Core/SSH/SSHTunnelManager.swift - Plugin Manager · Discovery, installation, verification, registry integration, and driver adaptation
TablePro/Core/Plugins/PluginManager.swift
Plugin Layer
Driver plugins and plugin protocol kit
- PluginKit · Shared plugin contracts, capabilities, dialect metadata, and import/export abstractions
Plugins/TableProPluginKit/TableProPlugin.swift - Built-in Drivers · Native Swift plus C-bridged database support shipped inside the app
TablePro/Core/Database/DatabaseDriver.swift - Driver Plugins · Out-of-process or separately packaged drivers and import/export plugins
Plugins/PostgreSQLDriverPlugin/PostgreSQLPlugin.swift
Editor Packages
Shared SQL editing and syntax infrastructure
- CodeEditTextView · Low-level text layout, selection, syntax rendering, and editor behavior
LocalPackages/CodeEditTextView/Sources/CodeEditTextView/CodeEditTextView.swift - CodeEditSourceEditor · Coordinator-backed source editor with highlighting, folding, find, and tree-sitter integration
LocalPackages/CodeEditSourceEditor/Sources/CodeEditSourceEditor/SourceEditor/SourceEditor.swift - CodeEditLanguages · Tree-sitter language definitions and highlight resources for SQL and other syntaxes
LocalPackages/CodeEditLanguages/Sources/CodeEditLanguages/CodeLanguage.swift
Connections 28
- TablePro → Main UI: hosts · Desktop app presents the primary coordinator-heavy interface
- TablePro → SQL Editor: uses · Main app embeds the SQL editor surface
- TablePro → Results Grid: renders · Desktop app shows query results and row editing
- TablePro → Settings: configures · Settings hub exposes product and integration controls
- Main UI → Database Core: drives · UI actions flow into connection and transport orchestration
- SQL Editor → CodeEditSourceEditor: built on · Desktop SQL editor uses the shared source editor package
- SQL Editor → CodeEditTextView: built on · Editor behavior depends on the lower-level text view package
- SQL Editor → CodeEditLanguages: highlights with · Language definitions provide syntax highlighting and parsing support
- Results Grid → Query Services: reads from · Results grid is fed by query execution and paging services
- Results Grid → Database Core: writes through · Row edits and schema changes are committed through the connection layer
- Database Core → SSH/Tunnels: tunnels via · Connection setup can route through SSH and related transports
- Database Core → Built-in Drivers: executes on · Built-in engines are invoked directly by the database manager
- Database Core → Driver Plugins: adapts · Plugin-backed engines are loaded and normalized through the plugin layer
- Plugin Manager → PluginKit: implements · App-side plugin management conforms to the shared plugin protocol
- Driver Plugins → PluginKit: conforms to · Driver bundles implement the common plugin contracts
- Query Services → Built-in Drivers: queries · Query services dispatch SQL and metadata work to native drivers
- Query Services → Storage: persists · Query history, favorites, and tab state are stored locally
- Storage → Sync: syncs · Selected local records are mirrored through CloudKit sync
- AI Layer → Query Services: calls · AI tools can inspect schema and execute queries
- AI Layer → Storage: stores · Chat state, prompts, and AI credentials are persisted locally
- MCP Server → Query Services: exposes · External clients can list, inspect, and execute against connections
- MCP Server → Database Core: bridges · MCP tools operate through the active database/session layer
- Import/Export → Storage: imports into · Connection and app data imports land in local persistence
- Import/Export → Driver Plugins: extends · Import/export formats can be supplied by plugins
- TableProMobile → Storage: shares · Mobile app reuses shared persistence models and storage concepts
- TableProMobile → Sync: syncs with · Mobile client uses sync coordinator for shared data
- TableProMobile → SSH/Tunnels: connects via · iOS client includes its own SSH/tunnel implementation
- TableProMobile → Widget: extends · Widget and live activity provide quick access from the mobile suite