adamfandClaude Opus 5.5 33ea8a9b99
Test and publish / test (push) Successful in 40s
Test and publish / publish (push) Failing after 38s
Correct the registry setup notes: the token realm is on the apex
Gitea advertises its token endpoint at https://<domain>/v2/token, not
under /gitea/, so the /v2/ route belongs in the apex server block (added in
web_server da2ab9f) rather than nginx_routes.conf.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-14 16:39:43 +01:00

Job tracker

A private tracker for job applications, served at /jobs/ on adam-french.co.uk. It has four parts:

  • Applications (/jobs/): the list, the pipeline view and the Quick Reference snippets.
  • Leads inbox (/jobs/leads): postings the server finds on Greenhouse, Lever and Ashby boards and in Adzuna and Reed searches, scored by Claude against a search profile.
  • Email pipeline: reads the mailbox (Microsoft Graph or IMAP), has Claude classify recruitment mail, and creates or advances applications.
  • Capture userscript (web/public/job-capture.user.js): adds the posting open in the browser.

It was split out of the web_server repo, where it lived inside the site's Go backend, Python service and Vue app. It is now one Go binary that serves its own Vue SPA. It runs as one container behind the site's nginx and borrows the site's login.

Layout

cmd/jobtracker/      main: reads the environment, wires everything, registers routes
internal/auth/       is this request the admin? (asks the site backend)
internal/claude/     the three Claude calls: read a posting, score a lead, classify an email
internal/graph/      gqlgen GraphQL: schema/*.graphql is the source of truth
internal/handlers/   REST: capture routes, capture token, email controls, SPA file server
internal/models/     GORM models (six tables)
internal/services/   lead pipeline, job sources, email sync (Graph + IMAP), upsert, status vocabulary
web/                 Vue 3 + Vite SPA, built for base /jobs/

Routes

Everything is served under BASE_PATH (/jobs). nginx proxies the prefix through unchanged.

Path Auth What
/jobs/, /jobs/leads, /jobs/settings none (the data behind them is admin-only) SPA
POST /jobs/api/graphql @admin on every field everything the pages show and edit
/jobs/api/capture, /capture/status, /capture/extract bearer capture token the userscript
/jobs/api/admin/capture-token (GET/POST/DELETE) admin the token, from the Settings page
GET /jobs/api/email/status, POST /jobs/api/email/sync admin email controls on the Settings page
GET /jobs/api/email/callback open (Microsoft redirects here) Graph OAuth
GET /jobs/api/health open healthcheck: process up and database reachable

Auth

There are no accounts here. internal/auth forwards the browser's Cookie header to the site backend's GET /auth/validate-admin, which is the same check nginx uses for /radio/admin and /sb, and treats a 2xx as "admin".

  • Expired access token: validate-admin falls back to the refresh token and answers with new cookies. Those Set-Cookie headers are relayed to the browser.
  • Caching: a "yes" is cached for 30 seconds per cookie, so logging out takes up to 30 seconds to reach the tracker.
  • Lapsed session: the SPA sends the browser to the site's /admin/login?redirect=/jobs/... (web/src/session.js).

AUTH_MODE=dev admits everyone, for the standalone compose. It is refused unless DEV_MODE=true.

Development

make check          # go vet + go test, and a vite build
make generate       # after editing internal/graph/schema/*.graphql
make dev            # docker compose up --build: tracker + Postgres, seeded, no login

Then open http://localhost:8080/jobs/. Set CLAUDE_API_KEY in your shell or a .env to try the Claude features.

For SPA hot reload, run make dev (or the Go binary) and then cd web && npm run dev. Vite proxies /jobs/api to localhost:8080; see web/vite.config.js.

Every variable is listed and explained in .env.example.

Running inside web_server

The site's docker-compose.yml runs the published image as service jobs, with an explicit environment: list rather than env_file, so the site's other secrets stay out of the container. The site's nginx routes /jobs/ to it. The site's Postgres container holds the data, in its own jobs database and role. ./jobs-data is mounted at /data; the container runs as uid 1000, so chown 1000 jobs-data on the host.

Deploying

A push to main here runs .gitea/workflows/ci.yaml. It tests, then builds and pushes adam-french.co.uk/adamf/job-tracker:<sha> and :latest.

To roll the site onto a new image:

cd ~/deploy/web_server && docker compose pull jobs && docker compose up -d jobs

To pin a version instead of latest, set JOBS_IMAGE_TAG=<sha> in the site's .env.

One-off: registry setup

The image lives in this Gitea's container registry. Two things make that less simple than it sounds:

  • Docker always talks to /v2/ at the root of the host, whatever Gitea's ROOT_URL says (/gitea/).
  • Gitea advertises its token endpoint at https://adam-french.co.uk/v2/token, on the apex domain. The site redirects the apex to www.

So the apex server block in web_server's nginx/nginx.conf.template proxies /v2/ to Gitea and redirects everything else. That was added in web_server commit da2ab9f.

  1. Check Gitea's registry is on. On the Pi, bypassing nginx:

    curl -si http://localhost:3000/v2/ | head -5
    

    You want a 401 with Www-Authenticate: Bearer realm="https://adam-french.co.uk/v2/token". A 404 means packages are off: add [packages] with ENABLED = true to Gitea's app.ini.template and recreate Gitea.

  2. Check nginx routes it. curl -si https://adam-french.co.uk/v2/ should give the same 401, not a 301 to www. If you are setting up a fresh site, the route to copy is location /v2/ in the apex server block of nginx/nginx.conf.template.

  3. Make a token. In Gitea, go to Settings → Applications and create a token with package: read and write.

  4. Round trip a throwaway image on the Pi:

    docker login adam-french.co.uk -u adamf          # the token is the password
    docker pull alpine:3.22
    docker tag alpine:3.22 adam-french.co.uk/adamf/registry-test:1
    docker push adam-french.co.uk/adamf/registry-test:1
    docker rmi adam-french.co.uk/adamf/registry-test:1
    docker pull adam-french.co.uk/adamf/registry-test:1
    

    Delete the test package afterwards, from your profile → Packages → registry-test → Settings. If the push fails, the error says where:

    • unauthorized: the token's scope is wrong, or https://adam-french.co.uk/v2/token isn't reaching Gitea (it should answer 401 or JSON, not a 301).
    • 413: the client_max_body_size 0 line isn't in effect.
    • HTML, a redirect, or "invalid character '<'": /v2/ is not reaching Gitea.
  5. Give CI the credentials. In this repo's Settings → Actions → Secrets, add REGISTRY_USER (adamf) and REGISTRY_TOKEN (the token). The next push to main publishes the image.

The Pi also has to be logged in to pull the image. The docker login in step 4 covers that; it is stored in that user's ~/.docker/config.json.

One-off cutover from the old in-backend tracker

Do the registry setup above first: step 6 needs the image.

Run these on the Pi, in this order:

  1. Stop the old schedulers. On the old backend, set EMAIL_SYNC_ENABLED=false and JOB_LEADS_ENABLED=false, so mail and boards are never processed twice.
  2. Create the database and role. Use the values you put in the site's .env as POSTGRES_JOBS_USER, POSTGRES_JOBS_PASSWORD and POSTGRES_JOBS_DB:
    docker exec db psql -U "$POSTGRES_USER" -d "$POSTGRES_DB" \
      -c "CREATE ROLE jobs LOGIN PASSWORD '…'" -c "CREATE DATABASE jobs OWNER jobs"
    
  3. Copy the six tables, with their schema and sequences. AutoMigrate then finds nothing to do:
    docker exec db pg_dump -U "$POSTGRES_USER" -d "$POSTGRES_DB" --no-owner --no-privileges \
      -t job_applications -t job_app_references -t processed_emails \
      -t job_sources -t job_leads -t job_search_profiles \
    | docker exec -i db psql -U jobs -d jobs -v ON_ERROR_STOP=1
    
    Then compare SELECT count(*) on each table in the two databases.
  4. Move the token files:
    mkdir -p jobs-data
    cp backend/token/msgraph_token.json backend/token/job_capture_token.json jobs-data/
    sudo chown -R 1000:1000 jobs-data
    
  5. Point Microsoft at the new callback. In the Entra app registration, add the redirect URI https://adam-french.co.uk/jobs/api/email/callback, and set MSGRAPH_REDIRECT_URI to the same value.
  6. Deploy and check. Deploy web_server with the jobs service and routes, then re-enable the two schedulers, now read by jobs. Check:
    • the tracker loads
    • "Check now" on Leads works
    • "Sync now" on Settings works
    • a capture from a real posting appears in the tracker

The old tables stay in the site database until they are dropped by hand. GORM never drops anything, so this is safe until you are sure.

Things that are easy to get wrong

  • The status vocabulary has copies. enum JobStatus (GraphQL) and services.statusOrder are tied by a test, and so are claude.EmailStatuses and the classifier prompt. Two copies are not checked and must be edited by hand: web/src/views/jobStatus.js and STATUS_LABELS in the userscript.
  • Bump the userscript's @version on every edit, or installed copies never update.
  • The Graph OAuth state is a fixed string (carried over unchanged from the old backend), and /email/callback is open. A forged callback can only link a mailbox the attacker controls, but a per-request nonce, like the site's Spotify flow uses, would close that.
  • BASE_PATH and Vite's base must agree. The SPA's asset URLs and router base are fixed at build time.
S
Description
No description provided
Readme
676 KiB
Languages
Go 56.5%
Vue 29.2%
JavaScript 10.3%
CSS 3.1%
Dockerfile 0.5%
Other 0.3%