Skip to content

TD-0010: Jobs service and web app

Status: Implemented · Python 3.13 · 12 November 2026

Related: PRD-007, Jobs stories, deploy runbook.

Service and storage

loryth-jobs follows API → transactional services → aggregates/repositories → PostgreSQL. Job, Company and SearchProfile carry user_id; child queries are reached through a Job selected for that user. Assessment and Application use selectin relationships with delete-orphan cascade. Events are queried separately. Mutations lock the parent Job. Per-user advisory locks serialize company/profile creation and canonical posting URL checks.

Six tables use internal BIGSERIAL IDs, public UUIDs and audit timestamps: company, job, job_assessment, application, job_event, search_profile. Migrations v00–v04 create an empty schema. v05 renames job.track to nullable TEXT role and adds nullable job_level and job_work_mode enums. There are no source keys, batch upload endpoints or research-skip states.

Priority is nullable P0/P1/P2/P3/watch. Role is free text. Level is junior/mid/senior/staff/principal/lead; work mode is remote/hybrid/onsite. v05 backfills the first staff/principal/lead/senior/junior word in the title, case-insensitively (Senior/Staff becomes senior). Location containing remote becomes remote, otherwise hybrid becomes hybrid; other values remain null. The rename and added types/columns tolerate repeating the migration. Backfills only fill nulls. Existing role text is preserved. Apply the migration before starting the new API; the old API expects the renamed column and cannot run against v05. The migration briefly locks the job table; there are 14 rows today.

Location fit is eligible/likely/uncertain/not_eligible plus a note. Assessment stores a nullable 0–10 score and 1–5 criterion values, with the assessment author and time. Company research and application materials use markdown fields.

Posting URLs retain significant query parameters. Canonicalization lowercases scheme/host, strips fragments, trailing slashes and tracking parameters, and sorts the remaining parameters. It keeps gh_jid unless the ID is in the path. Shallow URLs are not canonicalized. A partial unique (user_id, canonical_url) index prevents repeated postings within one search.

Workflow and dates

No application means New. Pure stage rules allow forward moves and direct backfill into later stages. Dismiss records a close event with reason dismissed. Reopening a dismissed New role removes its application while retaining events.

Actions accept a date and IANA timezone. Backdated events use local midnight; current/future dates use the current timestamp. Applied sets applied_on and Follow up after seven days. Screening and Interviewing schedule a thank-you note after one day. Offer schedules a response after three days. Done and Snooze use pure follow-up rules. A time means an appointment; it cannot be snoozed. Live applications beyond Shortlisted require a next-action due date.

Restorable events snapshot previous stage, close reason, application existence, next action/date/time, applied date and stage timestamp. Undo selects by insertion order, refuses stale targets and refuses to delete an application edited since its creation event. An undo event points at the original event. Week queries exclude referenced events. Manual logs remain chronological entries.

Lists and status

jobs/status.py::status_of classifies the retained application stage. No stage or Shortlisted is Pending while open and Passed while closed. Applied, Screening, Interviewing and Offer remain Applied even after closing. Applying from Passed snapshots the closed state, clears it and moves to Applied in one transaction; one Undo restores the previous passed state.

GET /jobs accepts status (pending/applied/passed), repeated level, work_mode, role, company UUIDs and q. It also accepts the existing hidden Show flags, date, timezone, page/size and canonical-URL lookup. Values within one facet are alternatives; different facets must all match. The old view, track, priority, location_fit, sort and ghosted list parameters are removed. The response contains page, counts by status, facets, hidden counts and seen_cutoff. Each facet count ignores its own selection and applies search and all other filters. All enum options and distinct saved roles are returned, including zero counts. Company facets contain UUID, name and count.

A user-scoped root query supplies these in-memory projections. Pending hiding retains the existing location → deadline → age rules for jobs without an application. Existing Shortlisted applications remain visible. Hidden counts apply the active filters; hidden groups are reported only for Pending. Ordering is priority, descending fit, deadline, then descending ID. Lists paginate in the shared Page/PageModel format.

GET /companies accepts q and repeated status/work_mode/role plus page/size. Its response contains page and facets. A company matches when one of its jobs matches every selected section. Each facet uses the same rule while ignoring its own section. Card counts, best assessed score/assessor and distinct stored locations cover all jobs at the company. Empty companies remain visible without job filters. Companies sort alphabetically.

The Today API and domain remain because MCP get_jobs_today calls them. They cap each block at five and return remaining counts, due actions, appointments later in the current Mon–Sun week and week activity. Quiet means more than 21 local days in Applied, Screening or Interviewing. There is no web Today route.

Web and chat

The shell lists Jobs, Companies (with pending and company counts in the sidebar) and Profile as the app's sections; list pages have an Add a role button. The Jobs route is /jobs; old list routes are deleted. Page-local components use tokens, vanilla-extract, Lucide at 1.75 stroke and a Radix Dialog drawer. The drawer is left-aligned and fills screens below 768px. Cards share the fit pill and styles. On phones the sections sit in the shared section strip under the header.

TanStack Query keys include the user. Jobs uses 50-row infinite queries; both lists keep previous results while URL filters update. Repeated parameters are serialized as repeated keys. Each list section retains its own params while role links preserve history Back and scroll. Debounced autosave flushes on blur and serializes writes; the profile saves both fields together. Actions invalidate Jobs queries and show an Undo toast that pauses while focused or hovered.

MCP forwards the current bearer token through AppClient and LORYTH_JOBS_URL. The seven tools are get_jobs_today, update_search_profile, list_jobs, read_job, save_job, assess_job and update_job_application. List accepts status and repeated level/work_mode/role/company filters. Save accepts role, level and work_mode. Create start_as defaults to pending, with shortlisted/applied also supported. update_search_profile reads the profile and replaces only supplied fields. Save checks the URL first and re-reads after a 409 race. Assessment content comes from the active chat model; Jobs makes no model calls. Tool descriptions require reading the profile and role before assessing.

Deployment and checks

Compose adds the Jobs database password to postgres and migrations. The migration runner ensures missing Watch/Jobs databases before applying SQL. Jobs has no worker or RabbitMQ dependency. The nginx regex route resolves a variable upstream at request time and the gateway does not depend on Jobs. Deploy health checks include /api/v1/jobs/health; AI storage reports include the Jobs database.

Server CI and the aggregate Makefile include Jobs. Tests cover migrations, missing-upstream routing, private UUID routes, workflow/undo, Today, hidden counts, chat calls, browser states, Back/scroll and desktop/375px rendering.