tajniak81andClaude Opus 4.8 ae6ed4ac1e Rebuild API Server on the PilotVault structure
Mirror PilotVault's API Server layout and add the superadmin console,
plugin system, runtime PocketBase settings, and user/organization
management. The car domain (cars, service records, parts, sharing) is
carried over unchanged apart from the auth switch.

Layout: main.go -> cmd/server/main.go; module carcontrol/api ->
drivervault/apiserver. internal/api is split by concern (auth, users,
orgs, settings, plugins, status, health, respond).

Auth: replace the server-minted HS256 JWT and the sessions collection
with a PocketBase token proxy. /api/auth/login relays PocketBase's
{token, record}, and every protected request re-resolves that token
against PocketBase, so a role change or deletion takes effect at once
instead of waiting out a token. AUTH_SECRET is obsolete and internal/auth
is gone. Per-device session listing/revocation goes with it: PocketBase
tokens are stateless. Changing a password rotates the user's token key,
which invalidates every token already issued.

Roles: add superadmin alongside user/admin, plus an organizations
collection and users.organization. Admins are scoped to their own
organization; superadmins span all of them. Guards prevent changing your
own role, deleting your own account, an admin touching a superadmin, and
deleting an organization that still has members.

Plugins: new internal/plugins package with one contract over two kinds --
builtin (compiled in) and external (any HTTP service, registered at
runtime with no rebuild). State persists to plugins.json; secrets are
masked on read and preserved when saved back at the mask.

PocketBase settings: /api/admin/pb-config applies a new connection at
runtime and persists it to .env. It deliberately does not require a
working service account, so a wrong or unreachable connection can still
be fixed from the panel.

Panel: rebuilt as the superadmin console -- login gate, status, users,
organizations, PocketBase, plugins, and the endpoint reference.

Clients: update the Web App and Phone App for the PocketBase token shape,
the move of user management to /api/users ({users}/{user} envelopes, with
password resets folded into PATCH), and the removal of sessions. Both now
mirror the server's real guards rather than the old last-admin rule, and
parse PocketBase's field-level error shape.

Config: modern POCKETBASE_*/API_ADDR names with legacy PB_*/PORT
fallbacks, so existing .env files keep working. Also fixes /api/status
probing the Web App on 8090 instead of DriverVault's 5173.

Run scripts/setup-pocketbase.mjs to add the organizations collection and
grow users.role; every client must log in once more.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-16 22:29:45 +02:00
2026-07-06 08:50:52 +02:00
2026-07-06 08:50:52 +02:00
2026-07-06 08:50:52 +02:00
2026-07-06 08:50:52 +02:00

Car Control Project

A car control & service tracking system. Built incrementally — starting with a car maintenance tracker (modeled on Car Service.xlsx) and growing toward live integration with the car via an ESP32 device.

Architecture

All clients communicate with the database only through the API Server — nothing talks to PocketBase directly.

                       ┌──────────────────┐
   Web App (Vue) ─────▶│                  │
   Phone App (Flutter)▶│   API Server     │────▶  PocketBase
   Home Assistant ────▶│   (Go, stdlib)   │       (10.2.1.10:8027)
   ESP32 device ──────▶│                  │
                       └──────────────────┘
Component Stack Status Docs
API Server Go (stdlib) built, running, verified API Server/README.md
Database PocketBase running, schema + seed done
Web App Vue 3 + Vite + Tailwind v4 full feature set (below) Web App/README.md
Phone App Flutter (Android) web parity + biometric login Phone App/README.md
Home Assistant Plugin later
Car Agent Device ESP32 later

The Web and Phone apps are at feature parity (the phone omits only data export/import).

Features

  • Maintenance tracking — cars, service history (date/odometer + which parts were changed), and a per-car parts catalog, with next-due date/km status.
  • Accounts & sessions — JWT login, per-device active sessions with remote logout, profile + appearance preferences (theme/locale/date/font), email verification, and account deletion.
  • Per-user ownership & sharing — each car has an owner and can be shared with other users as read or write; the UI mirrors the server's access checks.
  • Admin — role-gated user management (create / role / reset password / delete).
  • Phone biometric login & app lock — fingerprint / face sign-in with an app-lock that requires an unlock on relaunch (with a short grace period for quick app-switches). See the Phone App README.

Auth model

All three apps share one auth model: login via POST /api/auth/login returns a JWT issued by the API Server (after verifying against PocketBase users), and every other endpoint requires Authorization: Bearer <token>. Each login also creates a server-side session whose id is embedded in the token, so sessions can be listed and revoked. Access to cars/records/parts is gated by per-user ownership and shares; admin endpoints require the admin role.

Domain (from Car Service.xlsx)

  • Cars — one per vehicle (was: one spreadsheet sheet), with spec fields (engine / transmission / differential oil, brake fluid, coolant, VIN, …) and configurable service intervals.
  • Service records — date + odometer per service, plus which parts were changed (oil & oil filter, engine air filter, cabin air filter).
  • Parts — per-car catalog of part numbers.

Key spreadsheet formulas, reproduced by the API Server on read:

Next Service Date = service date + serviceIntervalDays   (default 365; Excel: =A+365)
Next Service Km   = service km   + serviceIntervalKm      (default 15 000; Excel: =B+15000)

Intervals are configurable per car.

Getting started

Bring up the stack in this order — each app's README has the details:

  1. API Server — configure .env, run setup-pocketbase.mjs, start the server. This must be running for either app.
  2. Web Appnpm install && npm run dev (proxies /api to the server).
  3. Phone Appflutter build apk / flutter run with --dart-define=API_BASE=http://<server-ip>:8080/api.

Layout

Car Control Project/
├── API Server/            # Go gateway to PocketBase (the only DB client)
├── Web App/               # Vue 3 + Vite + Tailwind v4
├── Phone App/             # Flutter (Android)
├── Home Assistant Plugin/ # later phase
└── Car Agent Device/      # ESP32, later phase
S
Description
No description provided
Readme
8.2 MiB
Languages
Go 43.3%
Dart 26.3%
Vue 19.2%
C++ 4.7%
JavaScript 3.8%
Other 2.7%