feat(career): CV builder backend — data-driven theme engine + variant model
Phase 4 foundation. A CvVariant is a lens over the master CareerProfile
(section order/visibility, per-item overrides keyed by ItemKey, theme +
builder settings) — it references career data, never duplicates it. One
renderer (ThemedCvRenderer) draws every theme; a theme is pure data
(CvThemeCatalog, 8 professional themes), so adding a theme needs no renderer
change. Autosave version history + non-destructive restore, public CV via
/api/public-cv/{slug} (anonymous, noindex, filter-bypassing owner load), and
an AI-assist endpoint reusing the existing provider abstraction (suggestions
only, never auto-applied).
- Models: CvVariant/CvVariantVersion, CvVariantSettings, CvTheme + catalog
- Services: CvVariantResolver (profile+lens -> render model), ThemedCvRenderer,
CvVariantService, CareerProfileService.LoadStructuredForOwnerAsync (public)
- API: CvVariantController (/api/cv), PublicCvController (/api/public-cv)
- Migration AddCvVariants (2 self-contained tables; verified applied on the
running container), 16 tests (resolver/renderer/service), 296 backend green
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
namespace JobTrackerApi.Models;
|
||||
|
||||
// Phase 4 — Career Workspace Builder.
|
||||
//
|
||||
// A CvVariant is NOT another career profile. It is a *lens* over the master CareerProfile: which
|
||||
// sections show, in what order, with what per-item overrides, rendered through a chosen theme with
|
||||
// layout/colour/font settings. The career data is never duplicated here — the variant stores only
|
||||
// selections + overrides keyed by the master profile's stable ItemKeys, plus builder preferences.
|
||||
// docs/architecture/cv-builder.md.
|
||||
public sealed class CvVariant
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string OwnerUserId { get; set; } = string.Empty;
|
||||
|
||||
// Public share slug for /cv/{slug}. Assigned at creation, stable, unguessable.
|
||||
public string PublicSlug { get; set; } = string.Empty;
|
||||
|
||||
public string Name { get; set; } = "Untitled CV";
|
||||
|
||||
// Optional link to the job application this variant was tailored for. Reference only — deleting
|
||||
// the application must not delete the variant (SetNull), and the variant never owns job data.
|
||||
public int? JobApplicationId { get; set; }
|
||||
public JobApplication? JobApplication { get; set; }
|
||||
|
||||
// Serialized CvVariantSettings — the whole lens (theme, layout, section order/visibility,
|
||||
// per-item overrides, builder prefs). One blob because it is edited and saved as a unit and
|
||||
// never queried field-by-field, exactly like a version snapshot.
|
||||
public string SettingsJson { get; set; } = string.Empty;
|
||||
|
||||
// Public visibility. Off by default; a public variant is served read-only at /cv/{PublicSlug}
|
||||
// and is marked noindex.
|
||||
public bool IsPublic { get; set; }
|
||||
|
||||
// Autosave version counter (mirrors CareerProfile.Version). Incremented on each saved snapshot.
|
||||
public int Version { get; set; }
|
||||
|
||||
public DateTimeOffset CreatedAtUtc { get; set; }
|
||||
public DateTimeOffset UpdatedAtUtc { get; set; }
|
||||
}
|
||||
|
||||
// Append-only autosave history for a variant, so builder edits are reversible. Mirrors
|
||||
// CareerProfileVersion. Restore re-saves an old snapshot as a new version (non-destructive).
|
||||
public sealed class CvVariantVersion
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string OwnerUserId { get; set; } = string.Empty;
|
||||
public int CvVariantId { get; set; }
|
||||
public CvVariant? CvVariant { get; set; }
|
||||
public int Version { get; set; }
|
||||
public string SettingsJson { get; set; } = string.Empty;
|
||||
public string Source { get; set; } = "autosave"; // autosave | manual | restore | create
|
||||
public DateTimeOffset CreatedAtUtc { get; set; }
|
||||
}
|
||||
Reference in New Issue
Block a user