Wellspent (Timer) is available under the
GNU Affero General Public License, version 3 only
(AGPL-3.0-only), except for components with their own license notices.
Commercial use is permitted under the AGPL; paying for a license is not required
when you comply with its terms.
For proprietary use requiring different terms, a paid commercial license is available by separate written agreement. Third-party components retain their existing licenses. See contribution requirements before submitting changes.
A Bun-managed Turborepo.
apps/docs: Fumadocs architecture, package, API, and integration documentationapps/web: Next.js App Router applicationapps/mobile: Expo Router application for iOS, Android, and webapps/macos: native SwiftUI/AppKit menu-bar and floating-sidebar applicationapps/desktop: Tauri 2 desktop shell for the shared timer packageapps/api: NestJS backend exposing oRPC-backed HTTP routes
Run bun run dev:docs and open local documentation.
See documentation app setup and content ownership.
packages/api-contract(@repo/api-contract): runtime-validated oRPC and OpenAPI contracts shared by the API and its clientspackages/api-client(@repo/api-client): typed HTTP, TanStack Query, Google integration, and CLI/MCP work-log clientspackages/database(@repo/database): Drizzle schema and PostgreSQL client; reviewed migrations live undersupabase/migrationspackages/lib(@repo/lib): small reusable React hooks shared by the web and mobile applicationspackages/liquid-ui(@repo/liquid-ui): shared Swift liquid-surface renderer with an Expo iOS bridge and Android/web fallbackpackages/session-domain(@repo/session-domain): platform-neutral Focus session schemas, transition rules, optimistic projection, and recap logicpackages/timer(@repo/timer): shared stopwatch, WebSocket synchronization, and React Native Skia timer-dial primitivespackages/typescript-config(@repo/typescript-config): reusable TypeScript configurations for libraries, Next.js, and NestJS
JavaScript and TypeScript linting and formatting are configured centrally in
biome.json.
The web and mobile apps depend on the client package, the client depends on the contract, and the NestJS app implements the contract. Shared Focus rules live in the session-domain package, while the realtime stopwatch remains in the timer package. Apps never import one another or reach across package boundaries.
- Bun 1.4+
- Node.js 22+
- Docker Desktop or another Docker-compatible container runtime
- Supabase CLI 2.116 (the scripts fetch the pinned CLI through
bunx) - An Expo development build for mobile development
Install dependencies:
bun installStart the local Supabase stack, then create the environment files:
bun run supabase:start
cp apps/api/.env.example apps/api/.env
cp packages/database/.env.example packages/database/.env
cp apps/web/.env.example apps/web/.env.local
cp apps/mobile/.env.example apps/mobile/.envThe API and database-package examples connect to local Postgres at
127.0.0.1:54422. The API file is used at runtime; the database-package file is
used by Drizzle Kit. To use a hosted project instead, replace DATABASE_URL
with its server-only connection string and URL-encode special characters in the
password. Never expose database credentials through NEXT_PUBLIC_* or
EXPO_PUBLIC_* variables.
Then start every app through Turborepo:
bun run devThe default local services are:
- Next.js:
http://localhost:3000 - NestJS API:
http://localhost:3001/api - NestJS WebSocket:
ws://localhost:3001/api/ws - Expo development server: shown by the Expo CLI, normally port 8081
- Supabase API:
http://127.0.0.1:54421 - Supabase database:
postgresql://postgres:[email protected]:54422/postgres - Supabase Mailpit:
http://127.0.0.1:54424
This project reserves ports 54420-54429 for its Supabase stack, keeping it
separate from the other local projects on 54320-54329 and 64320-64329.
On native development builds, the mobile client automatically replaces the
localhost API hostname with Metro's current host. Remote and production API
URLs are left unchanged. Only public, non-secret values belong in
EXPO_PUBLIC_* variables.
apps/macos is Wellspent's native SwiftUI/AppKit app. It provides menu-bar and
floating-sidebar controls for the shared stopwatch, authenticated Focus
sessions, and local recording and review of foreground application and
authorized Codex activity. Detailed observations are stored locally unless the
user explicitly selects them for disclosure.
Start the API, then open apps/macos/TimerMac.xcodeproj in Xcode and run the
TimerMac scheme. The native package also participates in the monorepo build,
lint, and test tasks:
bun run --cwd apps/macos build
bun run --cwd apps/macos lint
bun run --cwd apps/macos testSee the macOS app guide for local profiles, controls, Focus behavior, recording boundaries, and native verification details.
Start with bun run test:fast for focus behavior and CLI capture; use
bun run test:focus or bun run test:capture for narrower checks.
bun run test:focus:db:local runs rollback-only tests against the already
running, migrated Wellspent database on port 54422. Tests have no Turbo build
prerequisite. bun run test also includes macOS Xcode tests, which compile
their native target. Builds remain separate below.
See verification workflows, the visual system design, architecture documentation index, and agent workflows and skill audit.
bun run lint
bun run format:check
bun run typecheck
bun run buildRun bun run format to apply Biome formatting across JavaScript, TypeScript,
JSON, and CSS files.
Manage the PostgreSQL schema with Drizzle-generated SQL and the Supabase CLI:
bun run db:check
bun run db:generate --name=describe_the_change
bun run db:migrate:local
bun run db:studioDrizzle owns the desired application schema and generates timestamped SQL plus
metadata under supabase/migrations. Wellspent-owned tables live in the
unexposed PostgreSQL app schema; Supabase continues to own auth.users.
Review generated SQL before applying it, but do not append functions, triggers,
grants, or other manual SQL to generated structural migrations. Unsupported
PostgreSQL objects live in explicitly named Drizzle custom migrations. The
Supabase CLI is the migration applier and history authority; db:migrate is a
convenience alias for db:migrate:local.
Local Supabase lifecycle commands:
bun run supabase:start
bun run supabase:start:full
bun run supabase:start:lite
bun run supabase:status
bun run supabase:stopUse Docker Desktop with docker context use desktop-linux before these commands.
The project is named timer-desktop; older timer volumes are kept separately.
The default start command runs the full stack, including Realtime, Storage,
Studio (http://127.0.0.1:54423), database metadata, and the Edge Functions
runtime. Local MCP is available at http://127.0.0.1:54421/mcp through Studio.
Use the app schema when inspecting Wellspent tables through MCP or Studio. This
local MCP endpoint is separate from a connector configured for hosted Supabase.
supabase:start:lite runs only Postgres, Auth, REST, the API gateway, and Mailpit;
it does not provide Studio or MCP. Both modes omit optional analytics, Vector
log shipping, and image transformation containers. Use the pinned commands above
because an older global Supabase CLI may reject the local_smtp configuration.
To rebuild the local database from committed migrations and supabase/seed.sql:
bun run db:reset:localdb:reset:local destroys local database data. It does not target a linked or
hosted project.
Run one application with a Turborepo filter:
bunx turbo run dev --filter=@repo/api
bunx turbo run dev --filter=@repo/web
bunx turbo run dev --filter=@repo/mobileThe starter endpoint is GET /api/health. Both frontends call it through
createApiClient, so input and output changes flow from the contract to every
consumer at typecheck time.
The API also exposes a native WebSocket transport probe at /api/ws. Messages
use Nest's { event, data } envelope:
{"event":"realtime.ping","data":{"sentAt":"2026-08-29T12:00:00.000Z"}}The server replies with realtime.pong, echoing sentAt and adding
serverTime. Connected timer clients also send timer.command frames with a
start, pause, or reset action. The API broadcasts the resulting
timer.state snapshot to every connected client so web and mobile controls
converge immediately.
The shared realtime timer stores its snapshot in app.realtime_timer_state.
Start/pause/reset commits the new state before broadcasting. Reconnecting
clients receive that stored revision and timestamp after an API restart;
running timers include downtime, and paused timers stay paused. Apply the
persist_realtime_timer migration before running this API version. The first
rollout cannot reconstruct a timer that existed only in the old process's
memory; a missing stored row initializes once at zero, paused.
This remains one shared timer, separate from authenticated /focus sessions
and their history. It does not yet provide durable native offline commands,
account isolation, or cross-process live fan-out. Live Activity registrations
also remain in memory. Database failures report an error rather than silently
resetting the timer. See realtime persistence verification.
The iOS timer starts ActivityKit activities with per-activity APNs update
tokens. While the mobile app is connected, it registers the current token with
the timer WebSocket. Subsequent start, pause, and running reset
transitions are sent to registered Live Activities through APNs; resetting a
paused timer ends and immediately dismisses them.
Remote updates are disabled by default. To enable them, create an Apple Push
Notifications authentication key and configure the API values documented in
apps/api/.env.example. Use the main app bundle identifier
(com.benschac.timer), not the widget extension identifier, and select the
sandbox APNs environment for development-signed builds.
The registration registry remains in memory: API restarts discard Live Activity tokens, while the timer snapshot survives in Postgres. This path updates activities already created by the iOS app. Remote push-to-start requires a durable device registration so the server can avoid creating duplicate activities and is not part of this slice.
- Add its contract under
packages/api-contract/srcwith Zod input and output schemas plus oRPC OpenAPI routing metadata. - Add a feature module under
apps/api/src; keep controllers, services, DTOs, and persistence for that feature together. - Implement the contract with
@Implementand inject dependencies through the constructor. - Consume the new typed procedure through
@repo/api-clientfrom either app.
The oRPC NestJS integration currently uses the documented 2.0.0-beta.32
packages. Keep all @orpc/* versions aligned when upgrading and consult the
oRPC NestJS integration guide before
changing the adapter. Additional references: Turborepo,
Next.js, Expo, and
NestJS.
Supabase Auth is the canonical identity provider. Authenticated application
data goes through Nest rather than the Supabase Data API. An auth.users
AFTER INSERT trigger creates the matching app.profiles row in the same
transaction. GET /api/profile returns that profile, and PATCH /api/profile
atomically updates its optional application-owned fields.
The API contains an opt-in Google Calendar integration that creates a dedicated
Focus Timer secondary calendar for each connected user. It requests the
narrow calendar.app.created scope instead of access to every calendar. OAuth
refresh tokens are encrypted at rest, webhook channel tokens are stored only as
hashes, and Calendar changes are pulled through incremental sync into a durable
server-only inbox.
To enable it:
- Enable the Google Calendar API and create a Google OAuth web client.
- Register the exact
GOOGLE_OAUTH_REDIRECT_URIfromapps/api/.envas an authorized redirect URI. - Deploy the API at a public HTTPS address and set
GOOGLE_CALENDAR_WEBHOOK_URLto its webhook endpoint. - Set the Supabase URL and publishable key so Nest can validate user access tokens.
- Generate a 32-byte token-encryption key with
openssl rand -base64 32. - Set
GOOGLE_CALENDAR_ENABLED=trueand apply the database migrations.
Endpoints:
GET /api/integrations/google-calendar/connect— authenticated; returns the Google consent URL.GET /api/integrations/google-calendar/callback— Google OAuth callback.GET /api/integrations/google-calendar/status— authenticated connection and watch status.DELETE /api/integrations/google-calendar— authenticated Calendar-only disconnect; shared Google credentials remain available to Sheets.POST /api/integrations/google-calendar/webhook— authenticated through the stored Google channel token rather than a user bearer token.
Push notifications contain no event body. A durable Postgres worker claims jobs
with FOR UPDATE SKIP LOCKED, refreshes the user's Google access token, performs
incremental synchronization, and stores each deduplicated change in
app.google_calendar_inbound_changes. Selected completed Focus sessions already
publish through durable outbound Calendar jobs; see
integration behavior. Interpreting the inbound
inbox as Focus changes remains separate future work. This does not synchronize
a ticking counter every second.
The API can export selected completed focus sessions to a new spreadsheet using Google's official SDK. Sheets and Calendar share encrypted Google credentials, with incremental consent and independent feature disconnects. See Google Sheets setup, endpoints, and verification.