# My Garage Track your cars: rego/WoF expiry, service history as a simple timeline (with PNG/PDF attachments and notes), reminders for upcoming maintenance (service, wheel rotation, alignment, or fully custom items like spark plugs), and a per-car knowledgebase for procedures, common problems, and reference info (coolant type, torque specs, etc). Log in via OIDC; each user gets their own private garage. (Internally the repo/Go module is still named `vlog` — that's just the project's internal codename, not shown anywhere in the UI.) ## Stack - **Backend**: Go (stdlib `net/http`, Go 1.22+ pattern routing), `sqlx` over `database/sql` (no ORM), applied at startup with no separate migrate step. - **Frontend**: Svelte 5 + Tailwind v4, built with Vite as a plain SPA (not SvelteKit) and embedded into the Go binary — one process, one container. - **Auth**: OIDC authorization-code flow against your existing OIDC provider → the backend mints its own JWT, stored as an httpOnly session cookie. - **DB**: Postgres (production, bring your own) or SQLite (local dev/testing, zero external dependency) — see `DB_DRIVER` below. - **Files**: AWS S3 (production) or local disk (local dev/testing) — see `STORAGE_DRIVER` below. Uploads/downloads are always proxied through the Go backend, never presigned URLs. - **Reminders**: computed at request time from a single SQL query — no scheduler, no email. - **TLS**: none of this app's business — put it behind whatever reverse proxy you already run (e.g. an existing Caddy instance on the same server). ## Repo layout ``` backend/ Go API + embedded frontend + schema (postgres + sqlite) frontend/ Svelte SPA (source only — build output isn't committed) deploy/ docker-compose.yml, .env.example scripts/ build-frontend.sh — builds the SPA and copies it into backend/cmd/server/web for local (non-Docker) `go build` ``` ## Configuration All configuration is environment variables — see `deploy/.env.example` for the full list and a description of each. The two driver toggles: - **`DB_DRIVER`**: `postgres` (default) or `sqlite`. With `sqlite`, `DATABASE_URL` is a file path (e.g. `./data/vlog.db`) instead of a DSN, and the schema is applied idempotently on startup — no golang-migrate, no external DB needed. Meant for local dev/testing; use Postgres in production. - **`STORAGE_DRIVER`**: `s3` (default) or `local`. With `local`, uploads are written under `LOCAL_STORAGE_PATH` (default `./data/uploads`) instead of S3 — no AWS credentials needed. Meant for local dev/testing; use S3 in production. Everything else (`OIDC_*`, `PUBLIC_BASE_URL`, `JWT_SIGNING_SECRET`) is required regardless — there's no toggle for OIDC, you'll need a real (or locally-run) OIDC provider either way. Register `OIDC_REDIRECT_URL` (`https:///api/auth/callback`) with it before logging in. ## Running locally (no Postgres, no S3) ```sh export DB_DRIVER=sqlite export DATABASE_URL=./data/vlog.db export STORAGE_DRIVER=local export LOCAL_STORAGE_PATH=./data/uploads # ...plus OIDC_*, PUBLIC_BASE_URL, JWT_SIGNING_SECRET (still required) ./scripts/build-frontend.sh # builds the SPA into backend/cmd/server/web cd backend go run ./cmd/server ``` For frontend-only iteration, `cd frontend && npm run dev` runs the Vite dev server on its own port and proxies `/api/*` to `http://localhost:8080` (see `frontend/vite.config.js`), so you can run the Go server and the Vite dev server side by side. ## Deploying ```sh cd deploy cp .env.example .env # fill in real values (DB_DRIVER=postgres, STORAGE_DRIVER=s3) docker compose up -d --build ``` This starts one container: `app` (the Go binary, built via `backend/Dockerfile`, which builds the frontend and embeds it in the same multi-stage build), published on `PORT` (default `8080`). Postgres, the OIDC provider, and TLS termination are all assumed to already exist — nothing else runs in this compose file. Point your existing Caddy config at it: ``` garage.example.com { reverse_proxy localhost:8080 } ``` (Use the app container's name instead of `localhost` if your Caddy also runs in Docker on the same network.) The schema applies automatically on every `app` startup — there's no separate migrate step to remember. ## Verification checklist 1. `docker compose -f deploy/docker-compose.yml up --build` with real env vars pointed at your Postgres, OIDC provider, and S3 bucket (or `DB_DRIVER=sqlite` / `STORAGE_DRIVER=local` for a no-external-deps smoke test); confirm the schema applies cleanly on a fresh DB. 2. Walk the OIDC login → callback → cookie-set → `/api/me` round trip in a browser; confirm logout clears the session. 3. Create a car (rego + info + photo); confirm the photo streams back. 4. Add a service entry with a PNG and a PDF attachment; confirm both show up in the timeline and stream back correctly; confirm a renamed `.exe` is rejected (content-sniffing, not just extension, decides the type). 5. Set a car's WoF/rego expiry in the near future and add a custom reminder (e.g. "Spark plugs", due in 30 days); confirm both appear on the dashboard and in the car's reminders panel. 6. Log in as a second OIDC user; confirm their garage is empty and they get 404s for the first user's car/file IDs. 7. Edit an existing service entry and reminder (both open as modals); confirm changes save and an attached file can be removed from a service entry without deleting the whole entry. 8. Add a knowledgebase entry (e.g. "Coolant type"), edit it, delete it. 9. Add 21+ service entries (or knowledgebase entries) to one car and confirm only the first page (20) loads initially, with a "Load more" button that fetches the next page from the server — not one giant unbounded fetch.