aksdb 8898d976e6 🐛 Keep tombstones when replacing data in the legacy import
Clients only pull changed rows and never learn about hard deletes, so
a row they already pulled survived as a ghost: it kept winning against
imported rows with the same effective_from. Existing rows now become
tombstones. Closed days and weeks are overwritten in place when an
imported row has the same key, so their unique index holds.
2026-12-01 16:37:26 +01:00
2026-11-29 20:28:25 +00:00
2026-11-29 20:28:25 +00:00
2026-11-29 17:06:46 +00:00
2026-11-30 17:43:13 +00:00
2026-11-29 17:06:46 +00:00

Wotra — Working Time Tracker

A self-hosted working time tracker with a single Go binary that embeds PocketBase and serves a Svelte PWA frontend. Offline-first, single-binary deploy.

Features

  • Start / Stop time tracking with an optional note.
  • Close days: merges all entries (worked_ms = sum of durations, breaks excluded).
  • Mark days as holiday, vacation, or sick (auto-credits expected daily hours).
  • Close weeks: computes overtime/undertime against a frozen snapshot of your expected hours.
  • Settings history: change hours/week, workdays and timezone with an effective_from date; past closed weeks are unaffected.
  • Accounts: email + password sign-up on the login page, optional OAuth2 providers.
  • PocketBase admin UI at /_/: manage users, collections and OAuth2.
  • Offline-first PWA: SignalDB collections persist in IndexedDB (one database per user) and sync with the server, so the app keeps working without a network connection.
  • CSV export: entries, days, weeks.
  • Midnight guard: stale running entries are automatically stopped at the end of their day (by the client and a server cron).

Quick Start

Tool versions are declared in mise.toml. Install mise and run mise install once to get the correct Go and Node versions.

Note: Dependencies are automatically installed when needed. If you want to manually trigger dependency installation, run mise deps.

Development

# Start PocketBase API and Vite dev server
mise run dev
# PocketBase API: http://localhost:8080 (admin UI: /_/)
# Vite UI: http://localhost:5173 (with /api proxy)

Open http://localhost:5173 for the UI and http://localhost:8080 for the API. The PocketBase admin UI is at http://localhost:8080/_/. Create an account on the sign-in page.

Production (single binary)

The frontend build must run before go build, because the binary embeds web/build/.

mise run build    # builds web/ (npm run build) then the Go binary

./wotra serve --http=0.0.0.0:8080 --dir=./pb_data
# open http://localhost:8080

On first run, create the first superuser via the admin UI at http://localhost:8080/_/, or with:

./wotra superuser create <email> <password>

Container

podman build -t wotra .
podman run -p 8080:8080 -v wotra-data:/pb_data wotra

All tasks

Task Description
mise run build Build production binary (web + Go, sequential)
mise run build:web Build Svelte frontend only
mise run build:go Build Go binary only
mise run dev Start PocketBase API + Vite dev servers concurrently
mise run dev:api Start PocketBase dev server only
mise run dev:ui Start Vite dev server only
mise run test Run all Go tests
mise run test:web Run frontend Vitest unit tests
mise run test:all Run Go tests and frontend tests
mise run check Lint and typecheck (go vet, gofmt, svelte-check)
mise deps Install/update project dependencies
mise run clean Remove build artifacts (recreates web/build/.gitkeep)

PocketBase Admin UI and OAuth2

The PocketBase admin UI lives at /_/ on the server host. There you manage collections and users. Accounts live in the users collection (email + password); sign-up happens on the login page. OAuth2 providers are optional and configured in the admin UI (users collection, Options, OAuth2), with the redirect URL https://<host>/api/oauth2-redirect.

Hours per week, workdays and timezone are per-user settings inside the app; the timezone setting is what day keys are computed with. New users get one default settings row (40 h, Monday to Friday, UTC, effective 2000-01-01).

API Reference

All routes require an authenticated session except /healthz and /api/health (PocketBase health endpoint).

Entries, settings and balance adjustments are written by clients through the sync push (POST /api/sync/push), not through REST endpoints.

Days

Method Path Description
POST /api/days/{day}/close Close a day (merge entries)
POST /api/days/{day}/mark Mark as holiday/vacation/sick
DELETE /api/days/{day}/close Reopen a closed day

Weeks

Method Path Description
POST /api/weeks/{week}/close Close a week (compute overtime)
DELETE /api/weeks/{week}/close Reopen a closed week

Export

Method Path Description
GET /api/export/entries.csv Export entries as CSV
GET /api/export/days.csv Export days as CSV
GET /api/export/weeks.csv Export weeks as CSV

Sync

Method Path Description
POST /api/sync/push Batch push of client changes (entries, settings, balance adjustments)

Pulls use the PocketBase updated cursor; pushes are batched. Entries, settings and balance adjustments are written exclusively through this endpoint.

Health

Method Path Description
GET /healthz Unauthenticated wotra health endpoint
GET /api/health PocketBase health endpoint

Migrating from the legacy version

If you ran a pre-PocketBase version of wotra, import your old SQLite database:

  1. Back up the legacy database: cp wotra.db wotra.db.bak.
  2. Build and start the new version, then create your account in the app (sign-up on the login page). The account must already exist before importing.
  3. Stop the server.
  4. Run the import with the same --dir as the server:
./wotra import-legacy --db wotra.db --email <your account email> [--tz <IANA zone>] [--dry-run]

The import replaces all data of that user. --tz overrides the timezone stored in the imported settings rows; day keys are imported unchanged. Use --dry-run to preview first.

Architecture

┌────────────────────────────┐           ┌───────────────────────────────────┐
│   Svelte PWA (client)      │           │   Single Go binary (server)       │
│  - SignalDB collections    │   HTTPS   │  - Embedded PocketBase            │
│    persisted in IndexedDB  │   JSON +  │    - Records API                  │
│  - Service Worker          │   SSE     │    - Auth (users + OAuth2)        │
│  - One database per user   │ ◄───────► │    - Realtime (SSE)               │
│                            │           │  - Close day/week business logic  │
│                            │           │  - SQLite storage                 │
└────────────────────────────┘           └───────────────────────────────────┘

Collections: entries, closed_days, closed_weeks, settings_history, balance_adjustments (all owner scoped).

See PLAN.md for the full design document.

Development Notes

  • Day boundary: entries must not cross midnight (in the user's timezone setting); stale running entries are stopped at the end of their day by the client and by a server cron.
  • Settings history: effective_from lets you change hours/week, workdays and timezone without rewriting past closed weeks.
  • Overtime: stored as a signed delta_ms on each closed_weeks row. Frozen at close time.
  • Sync model: SignalDB collections sync with the server; ids are client-generated 15 character PocketBase ids, conflicts resolve last-write-wins by client_updated_at, deletes are soft. Pulls walk the PocketBase updated cursor; pushes go through POST /api/sync/push.
S
Description
Working Time Tracker
Readme
745 KiB
Languages
Go 49.5%
TypeScript 31.2%
Svelte 18.4%
JavaScript 0.4%
Dockerfile 0.3%
Other 0.2%