π¦ Personal macOS screen time & focus tracking with cloud-synced web dashboard
Gecko is a lightweight menu bar app that silently tracks which application and window you're focused on, recording sessions to a local SQLite database. A companion web dashboard provides screen time analytics with cloud sync via Cloudflare D1. Built for personal use β no telemetry, no App Store sandbox.
- Event-driven focus tracking β listens for app activations via
NSWorkspacenotifications, with an adaptive fallback timer for in-app changes (3s β 6s β 12s based on context stability) - State machine architecture β formal
TrackingStateenum (.stopped,.active,.idle,.locked,.asleep) with explicit transitions and co-located side effects - Energy efficient β 80-95% power reduction: idle detection (>60s), screen lock/sleep suspension, Low Power Mode awareness (1.5Γ interval), title change debounce (2s), and timer leeway for macOS wake-up coalescing
- Browser URL extraction β grabs the current URL from Chrome, Safari, Edge, Brave, Arc, and Vivaldi via AppleScript (skipped entirely for non-browser apps)
- Local SQLite storage β all data stays on your machine at
~/Library/Application Support/ai.hexly.gecko/gecko.sqlite - Cloud sync β background sync to Cloudflare D1 with network awareness (skips when offline), batched uploads, and watermark-based pagination
- Menu bar only β runs as
LSUIElement(no Dock icon), always accessible from the menu bar - Permission onboarding β guides you through granting Accessibility and Automation permissions, with exponential backoff polling
- Secure β API key stored in macOS Keychain, sync requires HTTPS
- Launch at login β optional auto-start via
SMAppService
- Screen time analytics β daily usage breakdown with interactive charts (Recharts), timeline view, and top apps table
- Daily Review β per-day deep dive with score cards, Gantt-style session timeline, and AI-powered analysis (Anthropic / OpenAI)
- Cloud sync β automatic background sync from local SQLite to Cloudflare D1, with batched writes respecting D1's 100-param limit
- App Categories β organize apps into categories (4 built-in defaults + custom). Each category has an icon and a stable hash-derived color
- Tags β flexible tagging system with multi-tag support per app
- App Notes β annotate apps with context for AI analysis
- Public API β
/api/v1/snapshotendpoint for external integrations (Bearer token auth) - API key management β create, rename, and revoke API keys for device sync and public API access
- Backy backup β push/pull cloud data to an external Backy backup service
- Timezone settings β configurable IANA timezone for accurate day boundaries
- Google OAuth β secure authentication via NextAuth v5 (email allowlist)
- Dark mode β system-aware theme switching
- Responsive sidebar β collapsible navigation with smooth CSS grid animations
- Monorepo β clean separation between macOS client and web dashboard
- Four-layer testing β L1: Unit Tests (608 web + 194 mac), L2: Strict Lint (ESLint + SwiftLint), L3: API E2E, L4: BDD E2E (Playwright)
- Husky git hooks β pre-commit runs UT, pre-push runs UT + Lint + API E2E; BDD E2E available on-demand
- Atomic commits β Conventional Commits format, one logical change per commit
| Tool | Version | Purpose |
|---|---|---|
| macOS | 14.0+ (Sonoma) | Operating system |
| Xcode | 16.0+ | Mac client build |
| XcodeGen | latest | Xcode project generation |
| SwiftLint | latest | Swift linting |
| Bun | latest | Web dashboard runtime & package manager |
# Clone the repo
git clone https://github.com/nocoo/gecko.git
cd gecko
# Install dependencies & git hooks
bun install
# ββ Mac Client ββ
cd apps/mac-client
xcodegen generate
open Gecko.xcodeproj # Build & run from Xcode
# ββ Web Dashboard ββ
cd apps/web-dashboard
bun install
bun run dev # http://localhost:7018gecko/
βββ π¦ logo.png # App logo (2048Γ2048)
βββ apps/
β βββ mac-client/ # macOS SwiftUI menu bar app
β β βββ project.yml # xcodegen config
β β βββ Gecko/Sources/ # App, Models, Services, Views
β β βββ GeckoTests/ # 194 unit + integration tests
β βββ web-dashboard/ # Web dashboard (vinext + React 19)
β βββ drizzle/ # D1 migration SQL files
β βββ src/
β β βββ app/ # Pages & API routes
β β βββ components/ # UI components (shadcn/ui + custom)
β β βββ lib/ # Utilities, sync queue, D1 client
β βββ src/__tests__/ # 608 unit + 11 E2E + 6 BDD tests
βββ docs/ # Architecture documentation
βββ packages/ # Shared config
βββ scripts/ # Git hooks & tooling
# Mac client β unit tests
xcodebuild test -project apps/mac-client/Gecko.xcodeproj \
-scheme Gecko -destination 'platform=macOS' -quiet
# Mac client β lint (zero tolerance)
cd apps/mac-client && swiftlint lint --strict
# Web dashboard β unit tests (608 tests, 1879 assertions)
cd apps/web-dashboard && bun test
# Web dashboard β lint
cd apps/web-dashboard && bun run lint
# Web dashboard β E2E (requires RUN_E2E=true)
cd apps/web-dashboard && bun run test:e2e
# Web dashboard β BDD E2E (Playwright)
cd apps/web-dashboard && bun run test:bdd| Layer | Technology |
|---|---|
| Mac Client | Swift 5.10, SwiftUI, GRDB, NSWorkspace |
| Web Framework | vinext (Vite 7 + React 19 RSC) |
| Styling | Tailwind CSS v4, shadcn/ui, Radix UI |
| Auth | NextAuth v5 (Google OAuth) |
| Cloud DB | Cloudflare D1 (SQLite-compatible) |
| Local DB | SQLite via GRDB (mac) |
| Charts | Recharts |
| Testing | Bun test, Playwright, XCTest, SwiftLint, ESLint |
| CI/Hooks | Husky (pre-commit + pre-push) |
MIT Β© 2026 Zheng Li
