Skip to content

nocoo/gecko

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

399 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Gecko

Gecko

🦎 Personal macOS screen time & focus tracking with cloud-synced web dashboard

macOS 14.0+ Swift React 19 Bun MIT License


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.

✨ Features

πŸ–₯️ Mac Client

  • Event-driven focus tracking β€” listens for app activations via NSWorkspace notifications, with an adaptive fallback timer for in-app changes (3s β†’ 6s β†’ 12s based on context stability)
  • State machine architecture β€” formal TrackingState enum (.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

🌐 Web Dashboard

  • 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/snapshot endpoint 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

πŸ› οΈ Developer Experience

  • 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

πŸ“‹ Requirements

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

πŸš€ Getting Started

# 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:7018

πŸ“ Project Structure

gecko/
β”œβ”€β”€ 🦎 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

πŸ§ͺ Testing

# 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

πŸ—οΈ Tech Stack

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)

πŸ“„ License

MIT Β© 2026 Zheng Li

About

🦎 macOS menu bar screen time tracker with cloud-synced web dashboard and app categorization

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors