Skip to content

A native macOS / windows / Linux database IDE built with Swift and AppKit. Connect to PostgreSQL, MySQL, SQLite, and Redis from a single app with a fast, keyboard-driven interface.

C++

feat: add Intel build support and fix codesign pipeline

Tobi3f2baf6ec175
diff --git a/README.md b/README.md
index 68d86fe..db857fd 100644
--- a/README.md
+++ b/README.md
@@ -1,97 +1,224 @@
# Gridex
-A native macOS database IDE built with Swift and AppKit. Connect to PostgreSQL, MySQL, SQLite, and Redis from a single app with a fast, keyboard-driven interface.
+A native database IDE for macOS and Windows with built-in AI chat. Connect to PostgreSQL, MySQL, SQLite, Redis, MongoDB, and SQL Server from a single app.
![macOS 14+](https://img.shields.io/badge/macOS-14%2B-blue)
+![Windows 10+](https://img.shields.io/badge/Windows-10%2B-0078D4)
![Swift 5.10](https://img.shields.io/badge/Swift-5.10-orange)
![License](https://img.shields.io/badge/license-Apache%202.0-blue)
## Features
-### Multi-Database Support
-- **PostgreSQL** — full schema inspection, parameterized queries, SSL/TLS
-- **MySQL** — information_schema queries, SSL support
-- **SQLite** — file-based, WAL mode, zero config
-- **Redis** — key browser, pattern filter, Server INFO dashboard, Slow Log viewer
+### Database Support
+
+| Database | Driver | Highlights |
+|----------|--------|------------|
+| **PostgreSQL** | [PostgresNIO](https://github.com/vapor/postgres-nio) | Parameterized queries, SSL/TLS, sequences, full schema inspection |
+| **MySQL** | [MySQLNIO](https://github.com/vapor/mysql-nio) | Character set handling, parameterized queries, SSL |
+| **SQLite** | System `libsqlite3` | File-based, WAL mode, zero config |
+| **Redis** | [RediStack](https://github.com/swift-server/RediStack) | Key browser, SCAN filter, Server INFO dashboard, Slow Log viewer |
+| **MongoDB** | [MongoKitten](https://github.com/orlandos-nl/MongoKitten) | Document editor, NDJSON export/restore, aggregation |
+| **SQL Server** | [CosmoSQLClient](https://github.com/vkuttyp/CosmoSQLClient-Swift) | TDS 7.4 protocol, native BACKUP DATABASE, stored procedures |
+
+### AI Chat
+
+Built-in AI assistant that understands your schema and writes SQL for you.
+
+- **Anthropic Claude** — streaming responses, direct API
+- **OpenAI GPT** — full API support
+- **Google Gemini** — Flash model support
+- **Ollama** — local LLM, no API key needed
+
+All requests go directly from your machine to the provider. Gridex never proxies prompts. API keys are stored in the macOS Keychain.
### Data Grid
+
- Inline cell editing with type-aware parsing
- Sort, filter, and paginate large datasets
-- Add/delete rows with pending changes and commit workflow
-- Copy rows, export to CSV/SQL
+- Add/delete rows with pending change tracking and commit workflow
+- Column resize, multi-column sort
+- Copy rows, export to CSV/JSON/SQL
### Query Editor
-- Syntax highlighting and auto-completion (tables, columns, functions)
-- Execute at cursor, explain plan, format SQL
-- Per-tab query persistence
-- Redis CLI mode with command execution
+
+- Multi-tab with connection-grouped Chrome-style tab bar
+- Syntax highlighting (keywords, strings, numbers, comments, functions)
+- Full query history persisted via SwiftData
+- Execute selection, execute all
+- Redis CLI mode
### Schema Tools
+
- Table structure viewer (columns, indexes, foreign keys, constraints)
-- Create/alter tables with visual editor
- ER Diagram with auto-layout, zoom, pan, and FK relationship lines
-- Function viewer with source code display
+- Function inspector with source code and parameter signatures
+- Stored procedure support (MSSQL)
+
+### SSH Tunnel
+
+- Password and private-key authentication
+- Local port forwarding through bastion hosts
+- Managed by `SSHTunnelService` actor (thread-safe, async/await)
+
+### Import & Export
+
+- **Export**: CSV, JSON, SQL (INSERT statements), SQL (full DDL with sequences/indices), schema DDL
+- **Import**: CSV (with column mapping), SQL dumps
+
+### Backup & Restore
+
+| Database | Backup Method |
+|----------|---------------|
+| PostgreSQL | pg_dump (custom, SQL, tar) / pg_restore |
+| MySQL | mysqldump / mysql CLI |
+| SQLite | File copy |
+| MongoDB | NDJSON (one document per line) |
+| Redis | JSON snapshot via SCAN |
+| SQL Server | Native `BACKUP DATABASE` |
+
+Supports selective table backup, compression options, and progress callbacks.
### Redis Management
+
- Virtual "Keys" table with SCAN-based browsing
- Key Detail View — edit hash fields, list items, set/zset members
- Pattern-based filter bar (glob syntax: `user:*`, `cache:?`)
-- Server INFO dashboard with auto-refresh and key metrics
+- Server INFO dashboard with auto-refresh
- Slow Log viewer, Flush DB, key rename/duplicate, TTL management
+### MongoDB Document Editor
+
+- NDJSON document editing with syntax-aware editor
+- Document insert/update/delete
+- Aggregation pipeline support
+
### Other
-- Multi-window support (Cmd+N) — work with multiple databases simultaneously
-- Backup & Restore wizard (pg_dump, mysqldump, SQLite copy)
-- Query history with favorites (persisted via SwiftData)
-- macOS Keychain integration for credential storage
+
+- Multi-window support (Cmd+N)
+- macOS Keychain for all credential storage
- Dark mode native
+- Connection save/load with SSH tunnel config and SSL/TLS options
## Requirements
+### macOS
+
- macOS 14.0 (Sonoma) or later
-- Swift 5.10+
+- Swift 5.10+ / Xcode 15+
+
+### Windows
+
+- Windows 10 or later (64-bit)
+- Visual Studio 2022+, .NET 8 SDK, vcpkg
## Build & Run
+### macOS
+
```bash
-git clone https://github.com/user/gridex.git
+git clone https://github.com/gridex/gridex.git
cd gridex
+
+# Debug (ad-hoc signed, fast local testing)
swift build
.build/debug/Gridex
+
+# Or build .app bundle
+./scripts/build-app.sh
+open dist/Gridex.app
+```
+
+### Release
+
+```bash
+# Apple Silicon
+./scripts/release.sh
+# → dist/Gridex-<version>-arm64.dmg
+
+# Intel
+ARCH=x86_64 ./scripts/release.sh
+# → dist/Gridex-<version>-x86_64.dmg
+
+# Both architectures
+./scripts/release-all.sh
```
+Release pipeline: `swift build` → `.app` bundle → code sign → notarize → staple → DMG → sign DMG → notarize DMG.
+
+**Environment variables for release:**
+
+| Variable | Description |
+|----------|-------------|
+| `ARCH` | `arm64` or `x86_64` (default: host) |
+| `SIGN_IDENTITY` | Developer ID certificate SHA-1 (or set in `.env`) |
+| `NOTARY_PROFILE` | `notarytool` keychain profile (default: `gridex-notarize`) |
+| `NOTARIZE` | Set to `0` to skip notarization |
+
## Architecture
-Clean Architecture with 5 layers:
+Clean Architecture with 5 layers. Dependencies point inward — Presentation → Services → Data → Domain → Core.
```
-macos/
- Core/ Protocols, Models, Enums, Errors — zero dependencies
- Domain/ Use Cases, Repository protocols
- Data/ Database adapters, SwiftData persistence, Keychain
- Services/ Query Engine, AI, SSH, Import/Export
- Presentation/ AppKit + SwiftUI views, ViewModels
-window/ Windows app (planned)
+gridex/
+├── macos/ macOS app (Swift, AppKit)
+│ ├── App/ Lifecycle, DI container, AppState, constants
+│ ├── Core/ Protocols, models, enums, errors — zero deps
+│ │ ├── Protocols/ DatabaseAdapter, LLMService, SchemaInspectable
+│ │ ├── Models/ RowValue, ConnectionConfig, QueryResult, etc.
+│ │ └── Enums/ DatabaseType, GridexError
+│ ├── Domain/ Use cases, repository protocols
+│ ├── Data/ Adapters, SwiftData persistence, Keychain
+│ │ ├── Adapters/ SQLite, PostgreSQL, MySQL, MongoDB, Redis, MSSQL
+│ │ ├── Persistence/ SwiftData models (connections, query history)
+│ │ └── Keychain/ macOS Keychain service
+│ ├── Services/ Cross-cutting concerns
+│ │ ├── QueryEngine/ QueryEngine actor, ConnectionManager, QueryBuilder
+│ │ ├── AI/ Anthropic, OpenAI, Ollama, Gemini providers
+│ │ ├── SSH/ SSHTunnelService (NIOSSH port forwarding)
+│ │ └── Export/ ExportService, BackupService
+│ └── Presentation/ AppKit views, SwiftUI settings, ViewModels
+│ ├── Views/ 18 view groups (DataGrid, QueryEditor, AIChat, etc.)
+│ └── Windows/ macOS window management
+├── windows/ Windows app (C++, WinUI 3)
+├── scripts/ Build and release automation
+└── Package.swift SPM manifest
```
-### Tech Stack
-- **UI**: AppKit (primary) + SwiftUI (settings, forms, sheets)
-- **Persistence**: SwiftData
-- **DB Drivers**: [PostgresNIO](https://github.com/vapor/postgres-nio), [MySQLNIO](https://github.com/vapor/mysql-nio), SQLite3, [RediStack](https://github.com/swift-server/RediStack)
-- **TLS**: [swift-nio-ssl](https://github.com/apple/swift-nio-ssl)
-- **SSH**: [swift-nio-ssh](https://github.com/apple/swift-nio-ssh)
+### Key Protocols
+
+- **`DatabaseAdapter`** — ~50 methods covering connection, queries, schema, CRUD, transactions, pagination. All 6 database adapters conform to this.
+- **`LLMService`** — Streaming AI responses via `AsyncThrowingStream`. All 4 AI providers conform.
+- **`SchemaInspectable`** — Full schema snapshot (tables, views, indices, constraints).
+
+### Concurrency
-## Roadmap
+- `actor` for thread-safe services: `QueryEngine`, `ConnectionManager`, `SSHTunnelService`, `BackupService`, `SchemaInspectorService`
+- `async/await` throughout — no completion handlers
+- `Sendable` constraints on all data models
-- [ ] SSH tunnel connections
-- [ ] AI chat with schema context (Anthropic/OpenAI/Ollama)
-- [ ] Settings UI (themes, editor preferences, AI config)
-- [ ] Data import (CSV, JSON, SQL dump)
-- [ ] Windows port
+### Dependency Injection
+
+`DependencyContainer` (singleton) manages service creation. SwiftData `ModelContainer` shared across windows. Services injected via SwiftUI environment.
+
+## Dependencies
+
+| Package | Version | Purpose |
+|---------|---------|---------|
+| [postgres-nio](https://github.com/vapor/postgres-nio) | 1.21.0+ | PostgreSQL driver |
+| [mysql-nio](https://github.com/vapor/mysql-nio) | 1.7.0+ | MySQL driver |
+| [swift-nio-ssl](https://github.com/apple/swift-nio-ssl) | 2.27.0+ | TLS for NIO connections |
+| [swift-nio-ssh](https://github.com/apple/swift-nio-ssh) | 0.8.0+ | SSH tunnel support |
+| [RediStack](https://github.com/swift-server/RediStack) | 1.6.0+ | Redis driver |
+| [MongoKitten](https://github.com/orlandos-nl/MongoKitten) | 7.9.0+ | MongoDB driver (pure Swift) |
+| [CosmoSQLClient-Swift](https://github.com/vkuttyp/CosmoSQLClient-Swift) | main | MSSQL via TDS 7.4 (no FreeTDS) |
+
+System library: `libsqlite3` (linked at build time).
## Contributing
-Contributions are welcome! Please open an issue first to discuss what you'd like to change.
+Contributions are welcome. Please open an issue first to discuss what you'd like to change.
+
+See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines and [CODE_OF_CONDUCT.md](CODE_OF_CONDUCT.md) for community standards.
## License
diff --git a/scripts/build-app.sh b/scripts/build-app.sh
index 48e5fd0..09b7ded 100755
--- a/scripts/build-app.sh
+++ b/scripts/build-app.sh
@@ -5,11 +5,13 @@
# ./scripts/build-app.sh # Debug build (ad-hoc sign, quick local run)
# ./scripts/build-app.sh release # Release: build + sign + notarize + staple + verify
# NOTARIZE=0 ./scripts/build-app.sh release # Release, skip notarization
+# ARCH=x86_64 ./scripts/build-app.sh release # Cross-compile for Intel
#
# Env (release mode):
# SIGN_IDENTITY SHA-1 or name of Developer ID cert (default pinned to 16/4/26 cert)
# NOTARY_PROFILE notarytool keychain profile (default: gridex-notarize)
# NOTARIZE 0 to skip notarization (useful while iterating locally)
+# ARCH arm64 | x86_64 (default: host uname -m)
set -euo pipefail
@@ -23,14 +25,16 @@ INFO_PLIST="$RESOURCES_DIR/Info.plist"
ICON="$RESOURCES_DIR/AppIcon.icns"
XCASSETS="$RESOURCES_DIR/Assets.xcassets"
NOTARIZE="${NOTARIZE:-1}"
+ARCH="${ARCH:-$(uname -m)}"
# 1. Build
-echo "→ Building ($MODE)..."
+echo "→ Building ($MODE, $ARCH)..."
+ARCH_FLAGS=(--arch "$ARCH")
if [ "$MODE" = "release" ]; then
- swift build -c release --package-path "$PROJECT_DIR" 2>&1 | tail -3
+ swift build -c release --package-path "$PROJECT_DIR" "${ARCH_FLAGS[@]}" 2>&1 | tail -3
BUILD_DIR="$PROJECT_DIR/.build/release"
else
- swift build --package-path "$PROJECT_DIR" 2>&1 | tail -3
+ swift build --package-path "$PROJECT_DIR" "${ARCH_FLAGS[@]}" 2>&1 | tail -3
BUILD_DIR="$PROJECT_DIR/.build/debug"
fi
@@ -126,24 +130,27 @@ if [ "$MODE" = "release" ]; then
rm -f "$RUNTIME_ENT"
exit 1
fi
- codesign --force --deep --options runtime --timestamp \
+ cs_out=$(codesign --force --deep --options runtime --timestamp \
--sign "$SIGN_IDENTITY" \
--entitlements "$RUNTIME_ENT" \
--generate-entitlement-der \
- "$APP_BUNDLE" 2>&1 | grep -v "unsealed contents" || {
+ "$APP_BUNDLE" 2>&1) || {
echo "✗ Signing failed"
+ echo "$cs_out"
rm -f "$RUNTIME_ENT"
exit 1
}
+ echo "$cs_out" | grep -v "unsealed contents" || true
codesign --verify --deep --strict --verbose=2 "$APP_BUNDLE"
fi
rm -f "$RUNTIME_ENT"
else
echo "→ Ad-hoc signing (debug)..."
- codesign --force --deep --sign - \
+ cs_out=$(codesign --force --deep --sign - \
--entitlements "$RUNTIME_ENT" \
--generate-entitlement-der \
- "$APP_BUNDLE" 2>&1 | grep -v "unsealed contents" || echo "⚠ Signing skipped"
+ "$APP_BUNDLE" 2>&1) || echo "⚠ Signing skipped"
+ echo "$cs_out" | grep -v "unsealed contents" || true
rm -f "$RUNTIME_ENT"
xattr -cr "$APP_BUNDLE" 2>/dev/null || true
fi
diff --git a/scripts/release-all.sh b/scripts/release-all.sh
new file mode 100755
index 0000000..f814dc9
--- /dev/null
+++ b/scripts/release-all.sh
@@ -0,0 +1,36 @@
+#!/bin/bash
+# release-all.sh — Build, sign, and package DMGs for both architectures.
+#
+# Usage:
+# ./scripts/release-all.sh
+#
+# Produces:
+# dist/Gridex-<version>-arm64.dmg (Apple Silicon)
+# dist/Gridex-<version>-x86_64.dmg (Intel)
+
+set -euo pipefail
+
+SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
+
+echo ""
+echo "╔═══════════════════════════════════════════╗"
+echo "║ Gridex — Multi-Arch Release ║"
+echo "╚═══════════════════════════════════════════╝"
+
+echo ""
+echo "━━━ Building for Apple Silicon (arm64) ━━━"
+echo ""
+ARCH=arm64 "$SCRIPT_DIR/release.sh"
+
+echo ""
+echo "━━━ Building for Intel (x86_64) ━━━"
+echo ""
+ARCH=x86_64 "$SCRIPT_DIR/release.sh"
+
+echo ""
+echo "╔═══════════════════════════════════════════╗"
+echo "║ ✓ All builds complete ║"
+echo "╚═══════════════════════════════════════════╝"
+echo ""
+echo "Artifacts:"
+ls -lh "$(cd "$SCRIPT_DIR/.." && pwd)/dist/"*.dmg 2>/dev/null || true
diff --git a/scripts/release.sh b/scripts/release.sh
index 3549fee..3024693 100755
--- a/scripts/release.sh
+++ b/scripts/release.sh
@@ -3,9 +3,11 @@
# build → sign → notarize .app → package DMG → sign → notarize DMG
#
# Usage:
-# ./scripts/release.sh
+# ./scripts/release.sh # Build for host arch
+# ARCH=x86_64 ./scripts/release.sh # Cross-compile for Intel
#
# Env:
+# ARCH arm64 | x86_64 (default: host uname -m)
# SIGN_IDENTITY, NOTARY_PROFILE, NOTARIZE — same as build-app.sh / sign-notarize.sh
#
# Produces: dist/Gridex-<version>-<arch>.dmg (notarized, stapled, ready to ship)
@@ -18,7 +20,7 @@ PROJECT_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"
cd "$PROJECT_DIR"
VERSION=$(/usr/libexec/PlistBuddy -c "Print :CFBundleShortVersionString" macos/Resources/Info.plist)
-ARCH=$(uname -m)
+export ARCH="${ARCH:-$(uname -m)}"
echo "═══════════════════════════════════════════"
echo " Gridex Release Pipeline"
diff --git a/scripts/sign-notarize.sh b/scripts/sign-notarize.sh
index d901791..ba814d8 100755
--- a/scripts/sign-notarize.sh
+++ b/scripts/sign-notarize.sh
@@ -78,14 +78,17 @@ sign_app() {
fi
echo "→ Signing app bundle..."
+ local cs_output
# shellcheck disable=SC2086
- codesign --force --deep --options runtime --timestamp \
+ cs_output=$(codesign --force --deep --options runtime --timestamp \
--sign "$SIGN_IDENTITY" \
$ent_arg \
- "$app" 2>&1 | grep -v "unsealed contents" || {
+ "$app" 2>&1) || {
echo "✗ codesign failed"
+ echo "$cs_output"
exit 1
}
+ echo "$cs_output" | grep -v "unsealed contents" || true
}
verify_app() {