The tracker (applications, leads, email pipeline, capture userscript) now lives in the adamf/job-tracker repo and runs here from its published image. - docker-compose.yml: a `jobs` service with an explicit environment list (its own database role; none of the site's other secrets), ./jobs-data mounted at /data, and nginx waiting for it. The dev override seeds it. - nginx: /jobs/ proxied to it with the prefix kept, and 301s from /cv/jobs, /cv/leads and the old userscript URL. - env_registry.json and .env.example: the email and job-lead variables now belong to the jobs service; CLAUDE_* to python and jobs; new POSTGRES_JOBS_* and JOBS_IMAGE_TAG. The compose environment test now checks the jobs service's list as well as python's. - backend: no longer starts the email and job-lead schedulers or serves the capture and email routes, since the tracker reads the same settings and would otherwise process everything twice. The old job code stays until the tracker has run for a while. - vue: the CV page's Jobs button goes to /jobs/; the old routes are gone. Co-Authored-By: Claude Opus 5.5 <[email protected]>
13 KiB
CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Build & Run Commands
Check everything
make check
Runs go vet + go test (backend), pytest in a venv built from python/requirements-dev.txt (kept in /.venv/), a Vite build, and docker compose config for both compose files. Each part is also its own target (check-backend, check-python, check-vue, check-compose); make help lists them. The Gitea deploy workflow runs the backend and Python checks in containers on every push, and main only deploys if they pass — so run make check before pushing.
Full stack (dev mode, HTTP only)
docker compose -f docker-compose.yml -f docker-compose.dev.yml up --build
Dev mode seeds the database with test data (SEED_DB=true) and disables certbot/SSL. Visit http://localhost.
Full stack (production, HTTPS)
docker compose up --build
Frontend only (hot reload)
cd vue && npm run dev
Vite dev server proxies /api, /gitea, /py and /radio; the targets default to localhost:8080, :3000, :8000 and :8000 and are overridden with VITE_PROXY_API, VITE_PROXY_GITEA, VITE_PROXY_PY and VITE_PROXY_RADIO (shell or vue/.env.local). Compose publishes none of the backend, Python or Icecast ports to the host, and /py and /radio share a default, so set these to wherever the services really are — see the comment in vue/vite.config.js.
Frontend build
cd vue && npm run build
npm run build compiles the Rust crate first and needs wasm-pack. npm run build:js (plain vite build) is the check to use when only the JS changed and src/wasm/ already exists.
Regenerate GraphQL (after editing schema files)
cd backend && go run github.com/99designs/gqlgen generate
This regenerates graph/generated.go and graph/model/models_gen.go. Resolver implementations in *.resolvers.go files are preserved.
Architecture
Dockerized multi-service personal website self-hosted on a Raspberry Pi.
Backend (backend/): Go with Gin router. GraphQL API via gqlgen at POST /api/graphql. REST endpoints for auth, file uploads, Spotify OAuth, and WebSockets. GORM for PostgreSQL with auto-migrations (no separate migration files). JWT auth stored in HTTP-only cookies.
Frontend (vue/): Vue 3 SPA with Vite, Tailwind CSS v4, Pinia stores, Vue Router. Built in a separate container; assets served through Nginx (production) or proxied to Vite dev server (dev mode).
Python API (python/): FastAPI app served by uvicorn on port 8000. Nginx proxies /py/ to it and strips the prefix, so routes in python/app/main.py are written relative to /. Swagger UI at /py/docs. Dev mode mounts python/app and runs uvicorn with --reload. Every Claude call in the stack lives here, behind four internal routes: /internal/rowing/read (behind POST /api/rowing), /internal/jobs/extract (behind POST /api/jobs/capture/extract), /internal/jobs/score (behind the job-lead pipeline) and /internal/email/classify (behind the email sync). The Go backend calls them directly over the Docker network through services.CallPython, and nginx 404s /py/internal/. The model is one setting for all four, CLAUDE_MODEL (default claude-sonnet-5-5), chosen on the admin panel's Environment tab; python/app/claude.py shapes the request per model. Adding another route is a short recipe in python/README.md ("Internal routes").
Job tracker (jobs service, /jobs/): the job application tracker, leads inbox, email pipeline and capture userscript now live in their own repo (adamf/job-tracker on Gitea) and run here as a published image, with their own Postgres database and role. It has no login: it asks the backend's /auth/validate-admin with the visitor's cookies. Transitional: the old job code is still in backend/, python/ and vue/ but unused (the backend no longer starts its schedulers or serves the capture and email routes, and /cv/jobs and /cv/leads redirect). Delete it once the tracker has run for a while; until then, sections below that describe job features in this repo are out of date.
Nginx (nginx/): Reverse proxy + SPA server. Config is templated (nginx.conf.template) and selected at runtime by entrypoint.sh based on DEV_MODE and certificate presence. Rate limiting on login (5/min), API (30/sec), uploads (5/min). Proxied routes are written once, in nginx/nginx_routes.conf.template, which both the production and dev configs include — add a new route there. Production-only pieces (TLS, static asset caching, the GraphQL rate-limit zone, security headers) stay in nginx.conf.template; a new rate-limit zone must be declared in both http blocks.
Backend Structure
main.go— entry point: wires up DB, services, routerhandlers/store.go—Storestruct holds DB, SpotifyAuth, Auth, EmailSync, etc. Passed to all handlershandlers/handle_*.go— REST handlers grouped by domaingraph/schema/*.graphql— GraphQL schema files (source of truth)graph/*.resolvers.go— resolver implementations (one per schema file,follow-schemalayout)graph/generated.go— auto-generated by gqlgen, do not editgraph/model/models_gen.go— auto-generated GraphQL models, do not editmodels/models.go— GORM database models (User, Post, Message, Activity, Favorite, Rowing, JobApplication, JobSource, JobLead, …)graph/directives.go— the@admin/@signedInschema directives (see Key Patterns)services/— database init, JWT auth, WebSocket server, Spotify OAuth, Gitea feed, the Python-service call helper (python_call.go), job status vocabulary (job_status.go), the job-lead pipeline (job_leads.go,job_sources.go), the tracker upsert (job_upsert.go), DB seeding. There is no Claude client in Go any more
Frontend Structure
src/graphql.js— thin axios-based GraphQL client (POST /api/graphql)src/api.js— thin REST client for the/apiJSON endpoints; failures become anApiErrorcarrying the backend'serrormessage and the statussrc/stores/— Pinia stores for auth, posts, favorites, activities, songs, messages, homeData, places, jobApplications, jobAppReferences, jobSources, jobLeads, jobSearchProfile.createCrudStore.jsis the factory behind places, jobApplications, jobAppReferences and jobSources;createMirrorStore.jsis the one behind the home-page slicessrc/views/— page components (Home, Admin, CV, Notes, Bookmarks, shrines)src/components/— reusable UI componentssrc/assets/styles.css— design tokens (Tailwind@theme), base element styles, shared classes and transitions.layouts/CVLayout.vuere-points the colour tokens for the light CV theme. See "Styling" invue/README.md.
Key Patterns
- GraphQL models vs GORM models:
gqlgen.ymlmaps GraphQL types directly to GORM models inbackend/models. Thegraph/model/package has only generated input/payload types. - Auth flow: Login sets
access_token(7 days) andrefresh_token(365 days) as HTTP-only cookies (backend/main.go:96).AuthMiddlewarevalidates tokens and injects user into Gin context.AuthContextMiddlewarepasses Gin context into GraphQL resolver context. Revocation is byUser.TokenVersion: every token carries the version it was minted with, and logout or a password change bumps it, invalidating all of that user's tokens. On the frontend the router guard awaitsauth.ensureLoaded()(a standalonemequery), not the home query;homeDataexposessettled(finished either way) as well asloaded(succeeded). - GraphQL auth is declared in the schema. The
/api/graphqlendpoint has no guarding middleware;AuthContextMiddlewareonly makes the user available. A field is protected by annotating it@adminor@signedIningraph/schema/*.graphql(implemented ingraph/directives.go).graph/directives_test.gofails if a mutation has neither directive and is not on its short public allow-list (login,logout,refreshToken), so a new mutation cannot ship unguarded by accident; a new query is public unless you annotate it. Finer rules (post ownership, hiding private messages) stay in the resolver. Seebackend/graph/doc.go. - Adding a GraphQL entity: model in
models/models.go(and the AutoMigrate list), schema file with directives, mapping ingqlgen.yml,make generate, fill in the resolvers; on the frontend a store built withcreateCrudStore. ModelID uintbinds directly viagraphql.UintID— there are no hand-written ID resolvers. Full recipe inbackend/README.md. - Job status is one vocabulary.
enum JobStatusingraph/schema/job_application.graphqlis what GraphQL accepts, and a test ties it toservices.statusOrder. Three copies are not checked and must be edited by hand with it: the classifier prompt inpython/app/email_classify.py,vue/src/views/CV/jobStatus.js, andSTATUS_LABELSin the userscript. - Spotify tokens: Persisted to
/backend/token/spotify_token.jsoninside the container, surviving restarts. - Job capture:
vue/public/job-capture.user.jsis a Violentmonkey userscript, served by the site and installed from/cv/jobs, that adds the posting open in the browser to the tracker. It calls the three/api/jobs/captureREST routes with a bearer token because cookies do not travel from other origins. The token is generated on the admin panel and stored hashed inbackend/token/job_capture_token.json; there is no env var for it. Bump its@versionon every edit or installed copies will not update. See "Job capture" inbackend/README.md. - Job leads:
/cv/leadsis an inbox of postings the backend finds itself.services/job_leads.gopolls eachJobSource(Greenhouse, Lever and Ashby boards; Adzuna and Reed searches), files new postings asJobLeadrows, keyword-filters them and has Claude score the survivors against the singleJobSearchProfilerow. A lead reaches the tracker only by promotion, throughservices.UpsertJobApplication— the same upsert the capture endpoint uses.JobLeadis not soft deleted: a dismissed lead has to stay a row or the next poll re-adds it. The timer is off unlessJOB_LEADS_ENABLED=true; "Check now" works either way. See "Job leads" inbackend/README.md. - Environment tab:
/admin→ Environment edits.envon the Pi. The backend never touches the file: it validates the edit and writesenv-apply/run/request.json;env-apply/apply.py, run on the host by a systemd path unit (env-apply/install.sh), rewrites.envand recreates only the services that read the change.backend/services/env_registry.jsonis the single list of variables — add new variables there as well as.env.example(a test enforces it); a variable the Python service reads must also be added to thepythonservice's explicitenvironment:list indocker-compose.yml, which a second test checks against the registry, witheditable: falsefor anything that renames a container, moves a port or is only read at first init. Secrets are write-only: no endpoint returns one. See "Environment tab" inbackend/README.md. - Gitea feed: Backend proxies and caches (1 min TTL) the Gitea activity feed API.
- All GORM models use soft delete (
gorm.DeletedAtfield) — exceptProcessedEmailandJobLead, whose dedup must see history, and the single-rowJobSearchProfile. Note that auniqueIndexstill collides with soft-deleted rows.
Further documentation
Each area has its own README with the detail that doesn't belong here:
backend/README.md— request lifecycle, auth model, GraphQL-vs-REST split and why each REST endpoint isn't GraphQL, service rundown, gotchas.vue/README.md— app structure, routing, store/GraphQL data flow, the design-token styling system, and a live-vs-legacy map of the views.python/README.md— endpoints, the NDJSON streaming contract, the hotel pricing method, and the scraper's fragility points.DEPLOYMENT.md— service topology and ports, dev vs prod boot paths, TLS first-run and renewal, what persists, env vars, and an ops runbook..env.example— every environment variable the stack reads, documented, with blank values.
Conventions
- Comments explain why, not what. The codebase is deliberately heavily commented at the points where behaviour is non-obvious (concurrency, caching, auth, scraping, nginx templating). Preserve these when editing; if you change the behaviour they describe, update them.
- Resolver commentary lives inside function bodies, because gqlgen relocates or strips anything above the signature when regenerating.
- Schema files use
#comments, not triple-quoted description blocks — descriptions would change GraphQL introspection output. - Legacy views are kept, not deleted.
vue/src/views/unused/,Intro.vue,Gym.vue, the unlisted CV templates and similar carry aSTATUS:header comment saying whether they are live. They are tree-shaken out of the build. Check the header before assuming a file is dead — e.g.views/unused/CoverLetters.vueis actually live on/cv.