feat: complete release readiness work

- consolidate API ownership and remove dead vendor code

- add Stripe billing, learning paths, and public CV hardening

- add migration, recovery, security, audit, and browser gates
This commit is contained in:
cesnimda
2026-07-31 16:54:16 +02:00
parent a23c3dfc97
commit ce76046a29
1634 changed files with 6889 additions and 135429 deletions
+17
View File
@@ -0,0 +1,17 @@
namespace JobTrackerApi.Models;
public sealed record AccountEntitlements(bool AdvancedAi, bool PremiumThemes, bool Automation, bool Analytics, long StorageBytes, int MonthlyAiCalls, long MonthlyAiTokens);
public static class AccountPlans
{
public static bool IsPremiumSubscriptionStatus(string? status) =>
status is "active" or "trialing";
public static AccountEntitlements ForRoles(IList<string> roles)
{
var premium = roles.Contains("Premium", StringComparer.OrdinalIgnoreCase) || roles.Contains("Admin", StringComparer.OrdinalIgnoreCase);
return premium
? new AccountEntitlements(true, true, true, true, 5_000_000_000, 250, 1_000_000)
: new AccountEntitlements(false, false, false, false, 250_000_000, 25, 100_000);
}
}
+37
View File
@@ -0,0 +1,37 @@
namespace JobTrackerApi.Models;
// Phase 5 — AI Career Assistant. Append-only history of every AI interaction for a job application.
// Unlike AiWorkspaceNote (one row per (owner, job, type), overwritten on regenerate — a cache), this
// keeps EVERY generation so the user can restore, compare, reuse, or delete past outputs. Suggestion
// only: an interaction never mutates the master profile, a CV variant, or the application itself.
// docs/architecture/ai-career-assistant.md.
public sealed class AiInteraction
{
public int Id { get; set; }
public string OwnerUserId { get; set; } = string.Empty;
public int JobApplicationId { get; set; }
public JobApplication? JobApplication { get; set; }
// job-analysis | career-match | cover-letter | interview | application-review
public string Module { get; set; } = string.Empty;
// Optional mode within a module (e.g. cover-letter: professional|friendly|short|detailed|modern|traditional).
public string? Mode { get; set; }
// Human label for the history list, e.g. "Cover letter · Professional".
public string Title { get; set; } = string.Empty;
// Resolved provider label at generation time (transparency for the history list).
public string Provider { get; set; } = string.Empty;
// The generated suggestion. { text: string, meta?: object } — text is markdown the UI renders;
// meta carries any structured extras (e.g. career-match percent).
public string ResultJson { get; set; } = string.Empty;
// Provider-neutral usage meter. Token count is estimated because the sidecar currently returns text only.
public int InputCharacterCount { get; set; }
public int OutputCharacterCount { get; set; }
public int EstimatedTokenCount { get; set; }
public DateTimeOffset CreatedAtUtc { get; set; } = DateTimeOffset.UtcNow;
}
+19
View File
@@ -0,0 +1,19 @@
namespace JobTrackerApi.Models;
// Generic persistence for per-job AI workspace outputs whose shape is irregular/nested enough
// that per-field columns (as used by InterviewPrepNote) would be unreasonable -- candidate fit
// and focus plan each make several AI calls and return DTOs with 6-13 fields including nested
// objects. One row per (owner, job, note type); ResultJson is the serialized DTO. See
// career-workspace-implementation-roadmap.md Phase F5 -- "persist interview prep / fit outputs".
public sealed class AiWorkspaceNote
{
public int Id { get; set; }
public string OwnerUserId { get; set; } = string.Empty;
public int JobApplicationId { get; set; }
public JobApplication? JobApplication { get; set; }
// "candidate-fit" | "focus-plan"
public string NoteType { get; set; } = string.Empty;
public string AttachmentContextSignature { get; set; } = string.Empty;
public string ResultJson { get; set; } = string.Empty;
public DateTimeOffset GeneratedAtUtc { get; set; } = DateTimeOffset.UtcNow;
}
+36
View File
@@ -0,0 +1,36 @@
using System.Collections.Generic;
namespace JobTrackerApi.Models
{
// Read-only analytics/statistics response DTOs. Extracted from
// JobApplicationsController so the aggregation logic can live in AnalyticsService.
public sealed record JobStats(
int Total,
int Active,
int Deleted,
Dictionary<string, int> ByStatus,
int AppliedLast30Days,
double AverageDaysSinceApplied
);
public sealed record FunnelStagePoint(string Label, int Count);
public sealed record ResponseRatePoint(string Label, int Total, int Responses, double Rate);
public sealed record CompanyActivityPoint(int CompanyId, string Company, int Count, int Responses, double ResponseRate);
public sealed record StageDurationDto(string Stage, double MedianDays, int Count);
public sealed record SalaryInsightDto(string Currency, string Period, int Count, decimal Minimum, decimal Maximum, decimal AverageMidpoint);
public sealed record AnalyticsOverviewDto(
List<FunnelStagePoint> Funnel,
List<ResponseRatePoint> ResponseRateBySource,
List<CompanyActivityPoint> TopCompanies,
double? MedianDaysToFirstResponse,
int TotalResponses,
int TotalActive,
List<StageDurationDto> TimeInStage,
List<SalaryInsightDto> SalaryInsights
);
}
@@ -0,0 +1,80 @@
namespace JobTrackerApi.Models;
// Phase 5 Milestone 2 — the application checklist.
//
// A workflow GUIDANCE layer, not a new store of truth. It duplicates nothing: the CV lives in
// CvVariant, documents in Attachment, history in JobEvent, follow-up in JobApplication.FollowUpAt.
// A checklist item only records "is this step done, and does the user still want it".
//
// System items carry a stable SystemKey and (usually) an AutoSignal: the same readiness signal the
// /readiness endpoint already computes. When the signal is satisfied the item auto-completes, so the
// checklist and readiness can never disagree — readiness became the calculation, this is the surface.
// docs/architecture/application-workspace.md.
public sealed class ApplicationChecklistItem
{
public int Id { get; set; }
public string OwnerUserId { get; set; } = string.Empty;
public int JobApplicationId { get; set; }
public JobApplication? JobApplication { get; set; }
// Stable identifier for system items ("prepare-cv", ...). Null for user-created items, so re-seeding
// is idempotent and a system item can be recognised across renames.
public string? SystemKey { get; set; }
// Which readiness signal completes this item automatically. Null = manual only.
public string? AutoSignal { get; set; }
public string Title { get; set; } = string.Empty;
public string? Description { get; set; }
// preparation | submission | follow-up | interview | custom. Drives grouping and next-action priority.
public string Category { get; set; } = ChecklistCategories.Custom;
// pending | done | dismissed. "dismissed" is the user opting out — not every item fits every role.
public string Status { get; set; } = ChecklistStatuses.Pending;
// Workspace section this step is done in, so the checklist can link straight to the work.
public string? Section { get; set; }
public int SortOrder { get; set; }
public bool IsSystemGenerated { get; set; }
// Set when the auto-signal completed the item, so the sync may reopen it if the signal reverts.
// A manual tick clears this and therefore sticks.
public bool IsAutoCompleted { get; set; }
public DateTimeOffset? CompletedAt { get; set; }
public DateTimeOffset CreatedAtUtc { get; set; } = DateTimeOffset.UtcNow;
public DateTimeOffset UpdatedAtUtc { get; set; } = DateTimeOffset.UtcNow;
}
public static class ChecklistStatuses
{
public const string Pending = "pending";
public const string Done = "done";
public const string Dismissed = "dismissed";
public static bool IsValid(string? value) =>
value is Pending or Done or Dismissed;
}
public static class ChecklistCategories
{
public const string Preparation = "preparation";
public const string Submission = "submission";
public const string FollowUp = "follow-up";
public const string Interview = "interview";
public const string Custom = "custom";
// Next-action priority: critical preparation, then submission, then chasing, then interview prep,
// then whatever the user added themselves.
public static readonly string[] Order = { Preparation, Submission, FollowUp, Interview, Custom };
public static int Rank(string? category)
{
var index = Array.IndexOf(Order, category ?? Custom);
return index < 0 ? Order.Length : index;
}
public static bool IsValid(string? value) => Array.IndexOf(Order, value ?? string.Empty) >= 0;
}
+29
View File
@@ -0,0 +1,29 @@
using Microsoft.AspNetCore.Identity;
namespace JobTrackerApi.Models;
public sealed class ApplicationUser : IdentityUser
{
public string? FirstName { get; set; }
public string? LastName { get; set; }
public string? DisplayName { get; set; }
public string? ProfileCvText { get; set; }
public string? ProfileCvStructureJson { get; set; }
public int? CurrentCvUploadArtifactId { get; set; }
public int? CurrentCvExtractionRunId { get; set; }
public int? CurrentCvProfileVersion { get; set; }
public string? AvatarImageDataUrl { get; set; }
public string? GoogleSubject { get; set; }
public string? GoogleEmail { get; set; }
public DateTimeOffset? GoogleLinkedAt { get; set; }
public string? MicrosoftSubject { get; set; }
public string? MicrosoftEmail { get; set; }
public DateTimeOffset? MicrosoftLinkedAt { get; set; }
public string? TotpSecretEncrypted { get; set; }
public string? TotpPendingSecretEncrypted { get; set; }
public DateTimeOffset? TotpEnabledAtUtc { get; set; }
public string? StripeCustomerId { get; set; }
public string? StripeSubscriptionId { get; set; }
public string? StripeSubscriptionStatus { get; set; }
public DateTime? StripeLastEventCreatedUtc { get; set; }
}
+21
View File
@@ -0,0 +1,21 @@
using System;
using System.Text.Json.Serialization;
namespace JobTrackerApi.Models
{
public class Attachment
{
public int Id { get; set; }
public int JobApplicationId { get; set; }
[JsonIgnore]
public JobApplication JobApplication { get; set; } = null!;
public string FileName { get; set; } = "";
public string FilePath { get; set; } = "";
public DateTime UploadDate { get; set; } = DateTime.Now;
public string FileType { get; set; } = ""; // e.g., PDF, DOCX
public long FileSize { get; set; }
public string? Purpose { get; set; }
public bool UseForAi { get; set; } = true;
}
}
+164
View File
@@ -0,0 +1,164 @@
using System.ComponentModel.DataAnnotations.Schema;
using System.Text.Json;
namespace JobTrackerApi.Models;
// Phase 3: relational children of CareerProfile — the editable master career profile.
// See docs/architecture/career-profile-model.md.
//
// Design notes shared by all child entities:
// - OwnerUserId is denormalized so the tenant global query filter applies directly (same pattern
// as every other owned entity).
// - ItemKey carries the stable item id from the StructuredCvProfile blob, so a row keeps its
// identity across imports/edits and future CV variants can reference "this experience".
// - SortOrder makes ordering explicit (the blob relied on array position).
// - List fields persist as JSON string columns (plain TEXT — reconciler-friendly on both SQLite
// and MySQL) exposed via [NotMapped] accessors. Children are replaced wholesale on save, so
// fine-grained change tracking of the lists is not needed.
/// <summary>Base fields every CareerProfile child shares.</summary>
public abstract class CareerChildEntity
{
public int Id { get; set; }
public int CareerProfileId { get; set; }
public CareerProfile? CareerProfile { get; set; }
public string OwnerUserId { get; set; } = string.Empty;
/// <summary>Stable identity carried from StructuredCvProfile so references survive edits.</summary>
public string ItemKey { get; set; } = string.Empty;
public int SortOrder { get; set; }
}
internal static class CareerJson
{
public static readonly JsonSerializerOptions Options = new(JsonSerializerDefaults.Web);
public static List<string> ReadList(string? json)
{
if (string.IsNullOrWhiteSpace(json)) return new();
try { return JsonSerializer.Deserialize<List<string>>(json, Options) ?? new(); }
catch { return new(); }
}
public static string WriteList(List<string> items) => JsonSerializer.Serialize(items ?? new(), Options);
}
public sealed class CareerExperience : CareerChildEntity
{
public string? Title { get; set; }
public string? Company { get; set; }
public string? Location { get; set; }
// Free-text period kept alongside best-effort "YYYY-MM" normalization; neither replaces the other.
public string? Start { get; set; }
public string? End { get; set; }
public string? StartDate { get; set; }
public string? EndDate { get; set; }
public bool IsCurrent { get; set; }
public string BulletsJson { get; set; } = "[]";
public string SkillsJson { get; set; } = "[]";
[NotMapped]
public List<string> Bullets
{
get => CareerJson.ReadList(BulletsJson);
set => BulletsJson = CareerJson.WriteList(value);
}
[NotMapped]
public List<string> Skills
{
get => CareerJson.ReadList(SkillsJson);
set => SkillsJson = CareerJson.WriteList(value);
}
}
public sealed class CareerEducation : CareerChildEntity
{
public string? Qualification { get; set; }
public string? QualificationLevel { get; set; }
public string? Institution { get; set; }
public string? Location { get; set; }
public string? Start { get; set; }
public string? End { get; set; }
public string? StartDate { get; set; }
public string? EndDate { get; set; }
public string DetailsJson { get; set; } = "[]";
[NotMapped]
public List<string> Details
{
get => CareerJson.ReadList(DetailsJson);
set => DetailsJson = CareerJson.WriteList(value);
}
}
public sealed class CareerSkill : CareerChildEntity
{
public string? Name { get; set; }
public string? Category { get; set; }
public string? Proficiency { get; set; }
}
public sealed class CareerProject : CareerChildEntity
{
public string? Name { get; set; }
public string? Role { get; set; }
public string? Location { get; set; }
public string? Start { get; set; }
public string? End { get; set; }
public string? StartDate { get; set; }
public string? EndDate { get; set; }
public string BulletsJson { get; set; } = "[]";
public string SkillsJson { get; set; } = "[]";
public string LinksJson { get; set; } = "[]";
[NotMapped]
public List<string> Bullets
{
get => CareerJson.ReadList(BulletsJson);
set => BulletsJson = CareerJson.WriteList(value);
}
[NotMapped]
public List<string> Skills
{
get => CareerJson.ReadList(SkillsJson);
set => SkillsJson = CareerJson.WriteList(value);
}
[NotMapped]
public List<string> Links
{
get => CareerJson.ReadList(LinksJson);
set => LinksJson = CareerJson.WriteList(value);
}
}
public sealed class CareerCertification : CareerChildEntity
{
public string? Name { get; set; }
public string? Issuer { get; set; }
public string? Location { get; set; }
public string? Date { get; set; }
public string? DateNormalized { get; set; }
public string DetailsJson { get; set; } = "[]";
[NotMapped]
public List<string> Details
{
get => CareerJson.ReadList(DetailsJson);
set => DetailsJson = CareerJson.WriteList(value);
}
}
public sealed class CareerLanguage : CareerChildEntity
{
public string? Name { get; set; }
public string? Level { get; set; }
public string? Notes { get; set; }
}
+48
View File
@@ -0,0 +1,48 @@
namespace JobTrackerApi.Models;
// The Career Workspace's durable source of truth. Bounded to one row per user for now
// (see career-workspace-implementation-roadmap.md Phase F1) -- ProfileJson mirrors
// ApplicationUser.ProfileCvStructureJson during the dual-write window and will become
// authoritative once every read path is migrated (F5).
public sealed class CareerProfile
{
public int Id { get; set; }
public string OwnerUserId { get; set; } = string.Empty;
// Phase 3: ProfileJson is now a DERIVED projection of the relational children + LongTailJson,
// serialized into the StructuredCvProfile shape and kept in sync on every save so the legacy
// read paths (CV rendering, tailoring, match-score) keep working unchanged. It is no longer an
// independently editable source. See docs/architecture/career-profile-model.md §4.
public string ProfileJson { get; set; } = string.Empty;
// The editable long tail that is not worth a relational table: contact, summary, interests,
// achievements, organisations, publications, courses, custom/other sections, and AI-extraction
// metadata. A JSON object (CareerLongTail). The relational children (Experience/Education/Skill/
// Project/Certification/Language) hold the rest.
public string LongTailJson { get; set; } = string.Empty;
public int Version { get; set; }
public DateTimeOffset CreatedAtUtc { get; set; } = DateTimeOffset.UtcNow;
public DateTimeOffset UpdatedAtUtc { get; set; } = DateTimeOffset.UtcNow;
public List<CareerExperience> Experiences { get; set; } = new();
public List<CareerEducation> Education { get; set; } = new();
public List<CareerSkill> Skills { get; set; } = new();
public List<CareerProject> Projects { get; set; } = new();
public List<CareerCertification> Certifications { get; set; } = new();
public List<CareerLanguage> Languages { get; set; } = new();
}
// Append-only history: one row per save, so profile edits are never silently lost.
public sealed class CareerProfileVersion
{
public int Id { get; set; }
public string OwnerUserId { get; set; } = string.Empty;
public int CareerProfileId { get; set; }
public CareerProfile? CareerProfile { get; set; }
public int Version { get; set; }
public string ProfileJson { get; set; } = string.Empty;
// Where this version came from: "upload" | "rebuild" | "improve" | "reprocess" | "parse" | "manual".
public string Source { get; set; } = string.Empty;
public DateTimeOffset CreatedAtUtc { get; set; } = DateTimeOffset.UtcNow;
}
+25
View File
@@ -0,0 +1,25 @@
using System.Collections.Generic;
using System.Text.Json.Serialization;
namespace JobTrackerApi.Models
{
public class Company
{
public int Id { get; set; }
public string? OwnerUserId { get; set; }
public string Name { get; set; } = "";
public string? Location { get; set; }
public string? Source { get; set; } // e.g., Finn.no, LinkedIn
// Lightweight CRM fields
public string? RecruiterName { get; set; }
public string? RecruiterEmail { get; set; }
public string? RecruiterLinkedIn { get; set; }
public DateTime? LastContactedAt { get; set; }
public DateTime? NextContactAt { get; set; }
public string? PipelineStage { get; set; }
[JsonIgnore]
public List<JobApplication> Jobs { get; set; } = new();
}
}
+50
View File
@@ -0,0 +1,50 @@
using System;
using System.Collections.Generic;
using System.Text.Json.Serialization;
namespace JobTrackerApi.Models
{
public class Correspondence
{
public int Id { get; set; }
public int JobApplicationId { get; set; }
[JsonIgnore]
public JobApplication JobApplication { get; set; } = null!;
public string From { get; set; } = ""; // "Me" or "Company"
public string? Direction { get; set; } // inbound, outbound, internal, unknown
public string? Subject { get; set; }
public string? Channel { get; set; } // e.g. Email, Call, Note
public string? ExternalMessageId { get; set; }
public string? ExternalThreadId { get; set; }
public string? ExternalFrom { get; set; }
public string? ExternalTo { get; set; }
public string? ExternalLabelsJson { get; set; }
public string? AttachmentMetadataJson { get; set; }
// Provider discriminator: "gmail" | "microsoft" | "imap" | "manual". Set at the write
// site (import controller or the manual-entry endpoint), not inferred from other fields,
// so it stays correct even for hand-entered rows that happen to carry external-looking data.
public string? Provider { get; set; }
public string Content { get; set; } = "";
public DateTime Date { get; set; } = DateTime.Now;
[JsonIgnore]
public IReadOnlyList<string> ExternalLabels => string.IsNullOrWhiteSpace(ExternalLabelsJson)
? Array.Empty<string>()
: (System.Text.Json.JsonSerializer.Deserialize<List<string>>(ExternalLabelsJson) ?? new List<string>());
[JsonIgnore]
public IReadOnlyList<CorrespondenceAttachmentMetadata> AttachmentMetadata => string.IsNullOrWhiteSpace(AttachmentMetadataJson)
? Array.Empty<CorrespondenceAttachmentMetadata>()
: (System.Text.Json.JsonSerializer.Deserialize<List<CorrespondenceAttachmentMetadata>>(AttachmentMetadataJson) ?? new List<CorrespondenceAttachmentMetadata>());
}
public sealed class CorrespondenceAttachmentMetadata
{
public string? FileName { get; set; }
public string? MimeType { get; set; }
public long? SizeBytes { get; set; }
public string? GmailAttachmentId { get; set; }
public bool Inline { get; set; }
}
}
@@ -0,0 +1,41 @@
namespace JobTrackerApi.Models;
// Phase 5.4 — Application Assets.
//
// Append-only history for a job application's cover letter. JobApplication.CoverLetterText stays the
// CURRENT text and the existing API contract around it is unchanged; this only records what it used
// to be, so an AI rewrite or a bad edit is never destructive. Mirrors CvVariantVersion: restore
// re-saves an old snapshot as a new version rather than rewinding.
//
// Reconciler-owned (docs/infrastructure/database-ownership.md) — its migration is a no-op.
public sealed class CoverLetterVersion
{
public int Id { get; set; }
public string OwnerUserId { get; set; } = string.Empty;
public int JobApplicationId { get; set; }
public JobApplication? JobApplication { get; set; }
public int Version { get; set; }
public string Text { get; set; } = string.Empty;
// manual | ai | template | restore — how this text came to exist, so the history list can show
// whether the user wrote it or approved it from a suggestion.
public string Source { get; set; } = "manual";
// For an AI-sourced version: which action produced it (generate | improve | shorten | expand |
// tone | tailor). Null for anything the user typed.
public string? AiAction { get; set; }
public DateTimeOffset CreatedAtUtc { get; set; } = DateTimeOffset.UtcNow;
}
public static class CoverLetterSources
{
public const string Manual = "manual";
public const string Ai = "ai";
public const string Template = "template";
public const string Restore = "restore";
public static bool IsValid(string? value) =>
value is Manual or Ai or Template or Restore;
}
+34
View File
@@ -0,0 +1,34 @@
namespace JobTrackerApi.Models;
public sealed class CvUploadArtifact
{
public int Id { get; set; }
public string OwnerUserId { get; set; } = string.Empty;
public string OriginalFileName { get; set; } = string.Empty;
public string StoredFileName { get; set; } = string.Empty;
public string MimeType { get; set; } = string.Empty;
public long ByteSize { get; set; }
public string Sha256 { get; set; } = string.Empty;
public string StoragePath { get; set; } = string.Empty;
public DateTimeOffset UploadedAtUtc { get; set; } = DateTimeOffset.UtcNow;
}
public sealed class CvExtractionRun
{
public int Id { get; set; }
public string OwnerUserId { get; set; } = string.Empty;
public int? ArtifactId { get; set; }
public CvUploadArtifact? Artifact { get; set; }
public string Trigger { get; set; } = string.Empty;
public string ParserVersion { get; set; } = string.Empty;
public string NormalizerVersion { get; set; } = string.Empty;
public string LlmPromptVersion { get; set; } = string.Empty;
public string Status { get; set; } = string.Empty;
public string? RawExtractedText { get; set; }
public string? NormalizedText { get; set; }
public string? StructuredProfileJson { get; set; }
public string? ErrorMessage { get; set; }
public DateTimeOffset StartedAtUtc { get; set; } = DateTimeOffset.UtcNow;
public DateTimeOffset? CompletedAtUtc { get; set; }
public DateTimeOffset? AppliedAtUtc { get; set; }
}
+153
View File
@@ -0,0 +1,153 @@
namespace JobTrackerApi.Models;
// A theme is DATA, not code. The renderer (ThemedCvRenderer) has one render path; every visual
// difference between themes is expressed by the fields below. Adding a theme = adding one CvTheme to
// CvThemeCatalog — no renderer changes. This is the core Phase 4 architectural rule
// ("Do NOT hardcode HTML templates"). docs/architecture/cv-theme-engine.md.
public sealed class CvTheme
{
public string Id { get; init; } = string.Empty;
public string Name { get; init; } = string.Empty;
public string Category { get; init; } = string.Empty;
public string Description { get; init; } = string.Empty;
// single | sidebar-left | sidebar-right | header-band
public string Layout { get; init; } = "single";
public double SidebarWidthMm { get; init; } = 62;
// Palette
public string Accent { get; init; } = "#2563eb";
public string Ink { get; init; } = "#111827";
public string Muted { get; init; } = "#4b5563";
public string Line { get; init; } = "#d1d5db";
public string Paper { get; init; } = "#ffffff";
public string SidebarBg { get; init; } = "#f3f4f6";
public string SidebarInk { get; init; } = "#111827";
public string? HeadingColor { get; init; } // null => accent
// Typography
public string HeadingFont { get; init; } = "Georgia, 'Times New Roman', serif";
public string BodyFont { get; init; } = "Arial, Helvetica, sans-serif";
public double NameSizePt { get; init; } = 24;
public double HeadingSizePt { get; init; } = 12;
public double BodySizePt { get; init; } = 10;
public double LineHeight { get; init; } = 1.42;
// Spacing (mm)
public double PageMarginMm { get; init; } = 16;
public double SectionGapMm { get; init; } = 6;
public double EntryGapMm { get; init; } = 4.5;
// plain | band | centered | kicker
public string HeaderStyle { get; init; } = "plain";
// caps-rule | underline | plain | bar
public string HeadingStyle { get; init; } = "caps-rule";
// none | square | rounded | circle
public string PhotoShape { get; init; } = "rounded";
public bool DefaultIcons { get; init; }
// ATS-friendly = single-column, no sidebar tables/graphics that trip naive resume parsers. Set on
// the single-column themes; surfaced in GET /api/cv/themes so the picker can badge it.
public bool AtsFriendly { get; init; }
public bool Premium { get; init; }
// Which section keys render in the sidebar for two-column layouts (ignored for single/header-band).
public List<string> SidebarSections { get; init; } = new() { "contact", "skills", "languages" };
}
public static class CvThemeCatalog
{
// 8 professional themes, all data. To add one: append here.
public static readonly IReadOnlyList<CvTheme> Themes = new List<CvTheme>
{
new()
{
Id = "modern", Name = "Modern", Category = "Modern Professional",
Description = "Clean SaaS-style layout with a confident accent header.",
Layout = "header-band", HeaderStyle = "band", HeadingStyle = "caps-rule",
Accent = "#2563eb", HeadingFont = "'Segoe UI', Roboto, Arial, sans-serif", BodyFont = "'Segoe UI', Roboto, Arial, sans-serif",
PhotoShape = "rounded", DefaultIcons = true, AtsFriendly = true,
},
new()
{
Id = "minimal", Name = "Minimal", Category = "Minimal",
Description = "Quiet, spacious, typography-first. Nothing competes with the content.",
Layout = "single", HeaderStyle = "plain", HeadingStyle = "plain",
Accent = "#111827", HeadingColor = "#111827", Muted = "#6b7280",
HeadingFont = "'Helvetica Neue', Arial, sans-serif", BodyFont = "'Helvetica Neue', Arial, sans-serif",
SectionGapMm = 7, EntryGapMm = 5, PhotoShape = "none", AtsFriendly = true,
},
new()
{
Premium = true, Id = "executive", Name = "Executive", Category = "Executive",
Description = "High-contrast, serif, leadership-weighted. For senior and client-facing roles.",
Layout = "single", HeaderStyle = "centered", HeadingStyle = "underline",
Accent = "#7c2d12", Ink = "#1c1917", Muted = "#57534e", Line = "#1c1917",
HeadingFont = "Georgia, 'Times New Roman', serif", BodyFont = "Georgia, 'Times New Roman', serif",
NameSizePt = 27, PhotoShape = "square", AtsFriendly = true,
},
new()
{
Premium = true, Id = "technical", Name = "Technical", Category = "Technical",
Description = "Dense two-column layout tuned for engineering CVs — skills and projects up front.",
Layout = "sidebar-left", HeaderStyle = "band", HeadingStyle = "bar",
Accent = "#0f4c5c", Ink = "#102a43", Muted = "#486581", SidebarBg = "#0f4c5c", SidebarInk = "#ffffff",
HeadingFont = "'Roboto', Arial, sans-serif", BodyFont = "'Roboto', Arial, sans-serif",
BodySizePt = 9.5, LineHeight = 1.36, DefaultIcons = true,
SidebarSections = new() { "contact", "skills", "languages", "certifications" },
},
new()
{
Id = "ats-classic", Name = "ATS Classic", Category = "ATS Professional",
Description = "Single column, no graphics, maximum parser compatibility. The safe default.",
Layout = "single", HeaderStyle = "plain", HeadingStyle = "caps-rule",
Accent = "#334155", Ink = "#111827", Muted = "#374151",
HeadingFont = "Arial, Helvetica, sans-serif", BodyFont = "Arial, Helvetica, sans-serif",
PhotoShape = "none", AtsFriendly = true,
},
new()
{
Premium = true, Id = "nordic", Name = "Nordic", Category = "Modern Professional",
Description = "Calm cool-blue sidebar, generous whitespace, Scandinavian restraint.",
Layout = "sidebar-right", HeaderStyle = "plain", HeadingStyle = "caps-rule",
Accent = "#3b6ea5", Ink = "#1f2937", Muted = "#4b5563", SidebarBg = "#eef3f8", SidebarInk = "#1f2937",
HeadingFont = "'Segoe UI', Arial, sans-serif", BodyFont = "'Segoe UI', Arial, sans-serif",
PhotoShape = "circle", DefaultIcons = true,
},
new()
{
Premium = true, Id = "elegant", Name = "Elegant", Category = "Creative",
Description = "Editorial serif headings over sans body, premium spacing and a plum accent.",
Layout = "single", HeaderStyle = "kicker", HeadingStyle = "underline",
Accent = "#7c3aed", Ink = "#1f2937", Muted = "#4b5563",
HeadingFont = "Georgia, 'Times New Roman', serif", BodyFont = "'Segoe UI', Arial, sans-serif",
NameSizePt = 26, SectionGapMm = 7, PhotoShape = "circle", AtsFriendly = true,
},
new()
{
Premium = true, Id = "creative", Name = "Creative", Category = "Creative",
Description = "Bold accent sidebar and photo-forward header for design and product roles.",
Layout = "sidebar-left", HeaderStyle = "band", HeadingStyle = "bar",
Accent = "#db2777", Ink = "#18181b", Muted = "#52525b", SidebarBg = "#be185d", SidebarInk = "#ffffff",
HeadingFont = "'Poppins', 'Segoe UI', Arial, sans-serif", BodyFont = "'Segoe UI', Arial, sans-serif",
PhotoShape = "circle", DefaultIcons = true,
SidebarSections = new() { "contact", "skills", "languages", "interests" },
},
};
public static CvTheme Resolve(string? id)
{
var key = (id ?? string.Empty).Trim().ToLowerInvariant();
return Themes.FirstOrDefault(t => t.Id == key) ?? Themes[0];
}
public static bool CanUse(string? id, bool premiumThemes) =>
Exists(id) && (premiumThemes || !Resolve(id).Premium);
public static bool Exists(string? id)
{
var key = (id ?? string.Empty).Trim().ToLowerInvariant();
return Themes.Any(t => t.Id == key);
}
}
+53
View File
@@ -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; }
}
+91
View File
@@ -0,0 +1,91 @@
using System.Text.Json;
using System.Text.Json.Serialization;
namespace JobTrackerApi.Models;
// The "lens" a CvVariant stores. Deliberately all-optional + defaulted so an empty settings object
// renders a sensible default CV straight from the master profile. Overrides are keyed by the master
// profile's stable ItemKeys so career data is referenced, never copied.
public sealed class CvVariantSettings
{
public string ThemeId { get; set; } = "modern";
// Theme overrides (null => use the theme's own value).
public string? AccentColor { get; set; }
public string? HeadingFont { get; set; }
public string? BodyFont { get; set; }
public string? Density { get; set; } // compact | balanced | roomy
public string? PageSize { get; set; } // a4 | letter
public string? DateFormat { get; set; } // display hint for the frontend; renderer uses source strings
public string? Language { get; set; }
public string? Headline { get; set; } // override the contact headline for this variant
public bool ShowPhoto { get; set; }
public bool ShowPageNumbers { get; set; }
public bool ShowIcons { get; set; } = true;
// Section order + visibility + optional renamed heading. Empty => default order, all visible.
public List<CvSectionSetting> Sections { get; set; } = new();
// Per-item overrides keyed by ItemKey (job/education/project/certification stable id).
public Dictionary<string, CvItemOverride> Overrides { get; set; } = new();
// Extra sections unique to this variant (not in the master profile).
public List<CvCustomSectionSetting> CustomSections { get; set; } = new();
}
public sealed class CvSectionSetting
{
public string Key { get; set; } = string.Empty; // summary|skills|experience|education|projects|certifications|languages|interests|links|custom:<k>
public bool Hidden { get; set; }
public string? Title { get; set; } // renamed heading
// Explicit entry order for this section, as a list of item ItemKeys. Entries not listed keep their
// master order and come last. Null => master profile order. Lets a variant reorder entries without
// touching the master profile.
public List<string>? ItemOrder { get; set; }
}
public sealed class CvItemOverride
{
public bool Hidden { get; set; }
public string? Title { get; set; }
public string? Subtitle { get; set; }
public List<string>? Bullets { get; set; } // null => use master bullets; non-null => replace for this variant only
}
public sealed class CvCustomSectionSetting
{
public string Key { get; set; } = string.Empty;
public string? Title { get; set; }
public List<string> Items { get; set; } = new();
public bool Hidden { get; set; }
}
public static class CvVariantSettingsJson
{
private static readonly JsonSerializerOptions Options = new(JsonSerializerDefaults.Web)
{
PropertyNameCaseInsensitive = true,
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull,
};
public static string Serialize(CvVariantSettings? settings) =>
JsonSerializer.Serialize(Normalize(settings), Options);
public static CvVariantSettings Deserialize(string? json)
{
if (string.IsNullOrWhiteSpace(json)) return new CvVariantSettings();
try { return Normalize(JsonSerializer.Deserialize<CvVariantSettings>(json, Options)); }
catch { return new CvVariantSettings(); }
}
public static CvVariantSettings Normalize(CvVariantSettings? s)
{
s ??= new CvVariantSettings();
s.ThemeId = string.IsNullOrWhiteSpace(s.ThemeId) ? "modern" : s.ThemeId.Trim().ToLowerInvariant();
s.Sections ??= new();
s.Overrides ??= new();
s.CustomSections ??= new();
return s;
}
}
+20
View File
@@ -0,0 +1,20 @@
namespace JobTrackerApi.Models;
public sealed class GmailConnection
{
public int Id { get; set; }
public string OwnerUserId { get; set; } = "";
public string GmailAddress { get; set; } = "";
public string EncryptedRefreshToken { get; set; } = "";
public string? EncryptedAccessToken { get; set; }
public DateTimeOffset? AccessTokenExpiresAt { get; set; }
public string Scope { get; set; } = "";
public DateTimeOffset ConnectedAt { get; set; } = DateTimeOffset.UtcNow;
public DateTimeOffset? LastSyncedAt { get; set; }
public DateTimeOffset? LastSyncAttemptedAt { get; set; }
public DateTimeOffset? LastSyncSucceededAt { get; set; }
public string? LastSyncMode { get; set; }
public string? LastSyncSource { get; set; }
public string? LastSyncStatus { get; set; }
public string? LastSyncError { get; set; }
}
@@ -0,0 +1,12 @@
namespace JobTrackerApi.Models;
public sealed class GmailReviewDecision
{
public int Id { get; set; }
public string OwnerUserId { get; set; } = "";
public string ThreadId { get; set; } = "";
public int? JobApplicationId { get; set; }
public string Decision { get; set; } = "review"; // review, linked, rejected, suggested
public string? Note { get; set; }
public DateTimeOffset UpdatedAt { get; set; } = DateTimeOffset.UtcNow;
}
@@ -0,0 +1,216 @@
using System.Globalization;
using System.Text;
using System.Text.RegularExpressions;
namespace JobTrackerApi.Models;
public static class HumanLanguageCatalog
{
private static readonly Dictionary<string, string> LanguageLookup = BuildLanguageLookup();
private static readonly Regex WordRegex = new(@"\p{L}+", RegexOptions.Compiled);
private static readonly Regex LevelRegex = new(
@"\b(native(?:\s+speaker)?|fluent|advanced|intermediate|beginner|basic|conversational|elementary|professional\s+working\s+proficiency|working\s+proficiency|limited\s+working\s+proficiency|full\s+professional\s+proficiency|a1|a2|b1|b2|c1|c2|a1\s*/\s*a2|a2\s*/\s*b1|b1\s*/\s*b2|b2\s*/\s*c1|c1\s*/\s*c2)\b",
RegexOptions.IgnoreCase | RegexOptions.Compiled);
public static string? NormalizeLanguageName(string? raw)
{
var matches = ExtractLanguageNames(raw);
return matches.Count == 1 ? matches[0] : null;
}
public static IReadOnlyList<string> ExtractLanguageNames(string? raw)
{
if (string.IsNullOrWhiteSpace(raw)) return Array.Empty<string>();
var words = WordRegex.Matches(raw)
.Select(match => match.Value)
.Where(value => !string.IsNullOrWhiteSpace(value))
.ToList();
if (words.Count == 0) return Array.Empty<string>();
var matches = new List<(int Start, int Size, string Canonical)>();
for (var size = Math.Min(4, words.Count); size >= 1; size--)
{
for (var start = 0; start <= words.Count - size; start++)
{
var phrase = string.Join(" ", words.Skip(start).Take(size));
if (!LanguageLookup.TryGetValue(NormalizeKey(phrase), out var canonical)) continue;
if (matches.Any(existing => RangesOverlap(existing.Start, existing.Size, start, size))) continue;
matches.Add((start, size, canonical));
}
}
return matches
.OrderBy(match => match.Start)
.Select(match => match.Canonical)
.Distinct(StringComparer.OrdinalIgnoreCase)
.ToList();
}
public static bool HasRecognizedLevel(string? raw)
{
return ExtractLevel(raw) is not null;
}
public static string? ExtractLevel(string? raw)
{
if (string.IsNullOrWhiteSpace(raw)) return null;
var match = LevelRegex.Match(raw);
if (!match.Success) return null;
var value = match.Groups[1].Value.Trim();
var compact = Regex.Replace(value, @"\s+", " ");
return compact.ToLowerInvariant() switch
{
"native speaker" => "Native",
"native" => "Native",
"fluent" => "Fluent",
"advanced" => "Advanced",
"intermediate" => "Intermediate",
"beginner" => "Beginner",
"basic" => "Basic",
"conversational" => "Conversational",
"elementary" => "Elementary",
"professional working proficiency" => "Professional working proficiency",
"working proficiency" => "Working proficiency",
"limited working proficiency" => "Limited working proficiency",
"full professional proficiency" => "Full professional proficiency",
_ when Regex.IsMatch(compact, @"^[ABC][12](?:\s*/\s*[ABC][12])?$", RegexOptions.IgnoreCase) => compact.ToUpperInvariant().Replace(" ", string.Empty),
_ => compact,
};
}
private static bool RangesOverlap(int startA, int sizeA, int startB, int sizeB)
{
var endA = startA + sizeA;
var endB = startB + sizeB;
return startA < endB && startB < endA;
}
private static Dictionary<string, string> BuildLanguageLookup()
{
var map = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
void Add(string? alias, string? canonical)
{
var normalizedAlias = NormalizeKey(alias);
var normalizedCanonical = NormalizeDisplayName(canonical);
if (string.IsNullOrWhiteSpace(normalizedAlias) || string.IsNullOrWhiteSpace(normalizedCanonical)) return;
map.TryAdd(normalizedAlias, normalizedCanonical);
}
// Force an alias to a canonical, overriding whatever culture enumeration inserted for that
// key. TryAdd is not enough here: on a host whose ICU data carries a "Norwegian Nynorsk"
// culture, the enumeration below claims the key "nynorsk" -> "Norwegian Nynorsk" first, and a
// later TryAdd("nynorsk", "Norwegian") silently loses. That made "nynorsk" resolve to
// "Norwegian Nynorsk" on the CI runner but "Norwegian" locally — the same host-ICU dependence
// this seeding exists to remove. Overrides must win regardless of insertion order.
void Override(string alias, string canonical)
{
var normalizedAlias = NormalizeKey(alias);
var normalizedCanonical = NormalizeDisplayName(canonical);
if (string.IsNullOrWhiteSpace(normalizedAlias) || string.IsNullOrWhiteSpace(normalizedCanonical)) return;
map[normalizedAlias] = normalizedCanonical;
}
// Seeded FIRST, and deliberately not derived from the host.
//
// This table used to come only from CultureInfo.GetCultures, which returns whatever
// culture data the machine happens to carry: 806 entries on a normal Linux or Windows
// box, exactly 1 under globalization-invariant mode, and an English-only subset on a
// container with trimmed ICU data. So whether "Norwegian" was recognised as a human
// language depended on the deployment environment, not on the CV. Under invariant mode
// every language was silently dropped and a CV import lost its Languages section with
// no error at all.
//
// These are the languages a CV realistically lists. Culture enumeration still runs
// below and still adds breadth for free, but nothing here depends on it.
//
// Nothing in this list may collide with a technical skill — "Go", "Java", "Swift",
// "Rust" and "Basic" are deliberately absent. "Basic" is also a proficiency level.
string[] seed =
[
"English", "Norwegian", "Swedish", "Danish", "Finnish", "Icelandic",
"German", "Dutch", "French", "Spanish", "Portuguese", "Italian",
"Polish", "Czech", "Slovak", "Slovenian", "Croatian", "Serbian", "Bosnian",
"Bulgarian", "Romanian", "Hungarian", "Greek", "Albanian", "Macedonian",
"Russian", "Ukrainian", "Belarusian", "Lithuanian", "Latvian", "Estonian",
"Turkish", "Arabic", "Hebrew", "Persian", "Kurdish", "Pashto", "Urdu",
"Hindi", "Bengali", "Punjabi", "Gujarati", "Marathi", "Tamil", "Telugu",
"Malayalam", "Kannada", "Sinhala", "Nepali",
"Chinese", "Japanese", "Korean", "Vietnamese", "Thai", "Lao", "Khmer",
"Burmese", "Malay", "Indonesian", "Filipino", "Tagalog", "Javanese",
"Swahili", "Amharic", "Somali", "Hausa", "Yoruba", "Igbo", "Zulu", "Afrikaans",
"Catalan", "Basque", "Galician", "Welsh", "Irish", "Scottish Gaelic", "Maltese",
"Latin", "Esperanto", "Armenian", "Georgian", "Azerbaijani", "Kazakh", "Uzbek",
];
foreach (var language in seed) Add(language, language);
foreach (var culture in CultureInfo.GetCultures(CultureTypes.NeutralCultures | CultureTypes.SpecificCultures))
{
var english = CleanCultureLanguageName(culture.EnglishName);
var native = CleanCultureLanguageName(culture.NativeName);
Add(english, english);
Add(native, english);
}
// These collapse regional/script variants and common exonyms to the umbrella language a CV
// means. They must beat culture enumeration (see Override), because ICU carries "Norwegian
// Bokmål"/"Norwegian Nynorsk" and "Chinese (Simplified/Traditional)" as their own cultures.
Override("norsk", "Norwegian");
Override("bokmal", "Norwegian");
Override("bokmål", "Norwegian");
Override("nynorsk", "Norwegian");
Override("norwegian bokmal", "Norwegian");
Override("norwegian bokmål", "Norwegian");
Override("norwegian nynorsk", "Norwegian");
Override("mandarin", "Chinese");
Override("cantonese", "Chinese");
Override("farsi", "Persian");
Override("persian", "Persian");
return map;
}
private static string? CleanCultureLanguageName(string? value)
{
if (string.IsNullOrWhiteSpace(value)) return null;
var cleaned = value.Trim();
var parenIndex = cleaned.IndexOf('(');
if (parenIndex > 0) cleaned = cleaned[..parenIndex].Trim();
var commaIndex = cleaned.IndexOf(',');
if (commaIndex > 0) cleaned = cleaned[..commaIndex].Trim();
return NormalizeDisplayName(cleaned);
}
private static string? NormalizeDisplayName(string? value)
{
if (string.IsNullOrWhiteSpace(value)) return null;
var cleaned = Regex.Replace(value.Trim(), @"\s+", " ");
return string.Join(" ", cleaned.Split(' ', StringSplitOptions.RemoveEmptyEntries)
.Select(word => word.Length <= 3 && word.All(char.IsUpper)
? word
: char.ToUpperInvariant(word[0]) + word[1..].ToLowerInvariant()));
}
private static string NormalizeKey(string? value)
{
if (string.IsNullOrWhiteSpace(value)) return string.Empty;
var decomposed = value.Trim().Normalize(NormalizationForm.FormD);
var builder = new StringBuilder(decomposed.Length);
foreach (var ch in decomposed)
{
if (CharUnicodeInfo.GetUnicodeCategory(ch) == UnicodeCategory.NonSpacingMark) continue;
builder.Append(char.ToLowerInvariant(ch));
}
return Regex.Replace(builder.ToString().Normalize(NormalizationForm.FormC), @"[^\p{L}]+", " ").Trim();
}
}
+20
View File
@@ -0,0 +1,20 @@
namespace JobTrackerApi.Models;
public sealed class ImapConnection
{
public int Id { get; set; }
public string OwnerUserId { get; set; } = "";
public string Host { get; set; } = "";
public int Port { get; set; } = 993;
public bool UseSsl { get; set; } = true;
public string Username { get; set; } = "";
public string EncryptedPassword { get; set; } = "";
public DateTimeOffset ConnectedAt { get; set; } = DateTimeOffset.UtcNow;
public DateTimeOffset? LastSyncedAt { get; set; }
public DateTimeOffset? LastSyncAttemptedAt { get; set; }
public DateTimeOffset? LastSyncSucceededAt { get; set; }
public string? LastSyncMode { get; set; }
public string? LastSyncSource { get; set; }
public string? LastSyncStatus { get; set; }
public string? LastSyncError { get; set; }
}
+72
View File
@@ -0,0 +1,72 @@
namespace JobTrackerApi.Models;
// Phase 5.5 — Interview preparation the USER owns.
//
// Distinct from InterviewPrepNote and AiWorkspaceNote, which are AI caches: both are regenerated when
// their context changes, so anything a user typed there would eventually be overwritten. This is the
// durable side — company research, technical notes, behavioural answers, STAR examples and the user's
// own questions — and nothing regenerates it.
//
// One table for every category rather than a table per category: they differ only by label, and a new
// category must not need a migration. Reconciler-owned
// (docs/infrastructure/database-ownership.md); its migration is a no-op.
public sealed class InterviewPrepItem
{
public int Id { get; set; }
public string OwnerUserId { get; set; } = string.Empty;
public int JobApplicationId { get; set; }
public JobApplication? JobApplication { get; set; }
// company-research | technical | behavioural | star | question | note
public string Category { get; set; } = InterviewPrepCategories.Note;
// The prompt side: a question to answer, or the heading of a research note.
public string Title { get; set; } = string.Empty;
// The user's own words. Always theirs to edit — an AI suggestion only lands here once saved.
public string? Content { get; set; }
// user | ai — whether the user wrote this or accepted it from a suggestion. Recorded for honesty
// in the UI, not to restrict editing: an accepted suggestion is fully editable afterwards.
public string Source { get; set; } = InterviewPrepSources.User;
// Practice tracking, so the section doubles as the preparation checklist.
public bool IsPrepared { get; set; }
public int SortOrder { get; set; }
public DateTimeOffset CreatedAtUtc { get; set; } = DateTimeOffset.UtcNow;
public DateTimeOffset UpdatedAtUtc { get; set; } = DateTimeOffset.UtcNow;
}
public static class InterviewPrepCategories
{
public const string CompanyResearch = "company-research";
public const string Technical = "technical";
public const string Behavioural = "behavioural";
public const string Star = "star";
public const string Question = "question";
public const string Note = "note";
// Display order in the workspace: understand the company, then the role, then yourself, then what
// you want to ask them.
public static readonly string[] Order =
{
CompanyResearch, Technical, Behavioural, Star, Question, Note,
};
public static int Rank(string? category)
{
var i = Array.IndexOf(Order, category ?? Note);
return i < 0 ? Order.Length : i;
}
public static bool IsValid(string? value) => Array.IndexOf(Order, value ?? string.Empty) >= 0;
}
public static class InterviewPrepSources
{
public const string User = "user";
public const string Ai = "ai";
public static bool IsValid(string? value) => value is User or Ai;
}
+22
View File
@@ -0,0 +1,22 @@
namespace JobTrackerApi.Models;
// Persists interview prep so it survives tab switches and page reloads instead of being an AI
// call re-run every time the tab opens (career-workspace-implementation-roadmap.md Phase F5 --
// "persist interview prep / fit outputs" -- flagged in the product teardown as work evaporating
// on every re-open). One row per job application; regenerated when the selected attachment
// context changes or the user explicitly requests a refresh.
public sealed class InterviewPrepNote
{
public int Id { get; set; }
public string OwnerUserId { get; set; } = string.Empty;
public int JobApplicationId { get; set; }
public JobApplication? JobApplication { get; set; }
// Fingerprint of the attachment selection this note was generated from, so a different
// attachment selection triggers regeneration without needing an explicit refresh.
public string AttachmentContextSignature { get; set; } = string.Empty;
public string Summary { get; set; } = string.Empty;
public string TalkingPointsJson { get; set; } = "[]";
public string LikelyQuestionsJson { get; set; } = "[]";
public string WeakSpotsJson { get; set; } = "[]";
public DateTimeOffset GeneratedAtUtc { get; set; } = DateTimeOffset.UtcNow;
}
+55
View File
@@ -0,0 +1,55 @@
using System;
namespace JobTrackerApi.Models
{
/// <summary>
/// A job opportunity — the role as the employer posted it, independent of whether the user
/// has applied. Separated from <see cref="JobApplication"/> (the user's pursuit of a job) so
/// that:
/// - a job can be tracked before it is applied to (see JobPipeline's Prospect stages), and
/// - applying twice to the same role does not duplicate the whole job description.
///
/// Introduced in Phase 0 (2026-07-17). New applications dual-write this opportunity row while
/// <see cref="JobApplication"/> remains the read source during the incremental cutover.
///
/// See docs/decisions/ADR-002-job-application-model.md.
/// </summary>
public class Job
{
public int Id { get; set; }
public string? OwnerUserId { get; set; }
public int CompanyId { get; set; }
public Company Company { get; set; } = null!;
public string JobTitle { get; set; } = "";
public string? Location { get; set; }
public string? JobUrl { get; set; }
// Imported job content.
public string? Description { get; set; }
public string? TranslatedDescription { get; set; }
public string? DescriptionLanguage { get; set; } // "en", "no", ...
public string? ShortSummary { get; set; }
public string? Tags { get; set; } // JSON array string, e.g. ["Azure","Docker"]
public DateTime? Deadline { get; set; }
// Structured salary; the free-text Salary field is kept for display/back-compat.
public string? Salary { get; set; }
public decimal? SalaryMin { get; set; }
public decimal? SalaryMax { get; set; }
public string? SalaryCurrency { get; set; } // e.g. "NOK", "GBP", "EUR"
public string? SalaryPeriod { get; set; } // "year" | "month" | "hour"
// Where this job came from. Market is data, not an assumption: Jobjakt is Norway-first
// but must not hardcode Norway, so country travels with the job rather than being
// implied by the importer. Null = unknown/manually entered.
public string? Source { get; set; } // e.g. "finn", "nav", "linkedin", "manual"
public string? CountryCode { get; set; } // ISO 3166-1 alpha-2, e.g. "NO", "GB"
/// <summary>When the user first captured this opportunity.</summary>
public DateTime SavedAt { get; set; } = DateTime.UtcNow;
public List<JobApplication> Applications { get; set; } = new();
}
}
+89
View File
@@ -0,0 +1,89 @@
using System;
namespace JobTrackerApi.Models
{
public class JobApplication
{
public int Id { get; set; }
public string? OwnerUserId { get; set; }
public string JobTitle { get; set; } = "";
public int CompanyId { get; set; }
public Company Company { get; set; } = null!;
// The opportunity this application is for. Nullable for legacy rows; new creates and edits
// keep Job synchronized while JobApplication remains the current read model.
// See JobTrackerApi/Models/Job.cs and docs/decisions/ADR-002-job-application-model.md.
public int? JobId { get; set; }
public Job? Job { get; set; }
public string Status { get; set; } = "Applied";
/// <summary>
/// When the user submitted the application. Null while the job is still in a pre-application
/// (Prospect) stage — Saved/Interested/Preparing — because nothing has been submitted yet.
/// Callers must not synthesise a date for unapplied jobs: a fake DateApplied feeds the
/// follow-up/ghosting rules and the applied-volume analytics.
/// </summary>
public DateTime? DateApplied { get; set; }
/// <summary>When the user first captured this job. Always set.</summary>
public DateTime SavedAt { get; set; } = DateTime.UtcNow;
public string? Location { get; set; }
public string? Salary { get; set; }
// Structured salary; the free-text Salary field is kept for display/back-compat.
public decimal? SalaryMin { get; set; }
public decimal? SalaryMax { get; set; }
public string? SalaryCurrency { get; set; } // e.g. "NOK", "GBP", "EUR"
public string? SalaryPeriod { get; set; } // "year" | "month" | "hour"
public string? NextAction { get; set; }
public DateTime? FollowUpAt { get; set; }
public DateTime? FeedbackRequestedAt { get; set; }
public string? RecruiterMessageDraft { get; set; }
// Attachment checklist. Derived from Attachment rows, not directly settable by API
// consumers -- see AttachmentsController.RecomputeAttachmentFlagsAsync, the single place
// these are written, so they can't drift from what's actually attached.
public bool HasResume { get; set; } = false;
public bool HasCoverLetter { get; set; } = false;
public bool HasPortfolio { get; set; } = false;
public bool HasOtherAttachment { get; set; } = false;
// Soft delete: hide from default queries without losing history.
public bool IsDeleted { get; set; } = false;
public DateTime? DeletedAt { get; set; }
public bool ResponseReceived { get; set; } = false;
public DateTime? ResponseDate { get; set; }
public string? Notes { get; set; }
public string? CoverLetterText { get; set; }
public string? JobUrl { get; set; }
// Imported job content
public string? Description { get; set; }
public string? TranslatedDescription { get; set; }
public string? DescriptionLanguage { get; set; } // "en", "no", ...
public string? Tags { get; set; } // JSON array string, e.g. ["Azure","Docker"]
public DateTime? Deadline { get; set; }
// Short summary generated at creation time and persisted to avoid repeated model calls.
public string? ShortSummary { get; set; }
public string? TailoredCvText { get; set; }
public DateTime? TailoredCvUpdatedAt { get; set; }
public DateTime? LastReminderEmailSentAt { get; set; }
public TailoredCvDraft? TailoredCvDraft { get; set; }
public List<Correspondence> Messages { get; set; } = new();
public List<Attachment> Attachments { get; set; } = new();
public List<JobEvent> Events { get; set; } = new();
/// <summary>
/// Days since the application was submitted. Null for pre-application (Prospect) stages:
/// with no DateApplied there is no elapsed time to report, and 0 would read as
/// "applied today".
/// </summary>
public int? DaysSince => DateApplied is null
? null
: ((ResponseReceived ? (ResponseDate ?? DateTime.UtcNow) : DateTime.UtcNow) - DateApplied.Value.ToUniversalTime()).Days;
}
}
+20
View File
@@ -0,0 +1,20 @@
using System;
using System.Text.Json.Serialization;
namespace JobTrackerApi.Models
{
public class JobEvent
{
public int Id { get; set; }
public int JobApplicationId { get; set; }
[JsonIgnore]
public JobApplication JobApplication { get; set; } = null!;
public string Type { get; set; } = ""; // Created, StatusChanged, FollowUpSet, Deleted, Restored
public string? OldValue { get; set; }
public string? NewValue { get; set; }
public string? Note { get; set; }
public DateTime At { get; set; } = DateTime.Now;
}
}
@@ -0,0 +1,20 @@
namespace JobTrackerApi.Models;
public sealed class MicrosoftGraphConnection
{
public int Id { get; set; }
public string OwnerUserId { get; set; } = "";
public string MailAddress { get; set; } = "";
public string EncryptedRefreshToken { get; set; } = "";
public string? EncryptedAccessToken { get; set; }
public DateTimeOffset? AccessTokenExpiresAt { get; set; }
public string Scope { get; set; } = "";
public DateTimeOffset ConnectedAt { get; set; } = DateTimeOffset.UtcNow;
public DateTimeOffset? LastSyncedAt { get; set; }
public DateTimeOffset? LastSyncAttemptedAt { get; set; }
public DateTimeOffset? LastSyncSucceededAt { get; set; }
public string? LastSyncMode { get; set; }
public string? LastSyncSource { get; set; }
public string? LastSyncStatus { get; set; }
public string? LastSyncError { get; set; }
}
+21
View File
@@ -0,0 +1,21 @@
namespace JobTrackerApi.Models
{
// Single-row table to store workflow automation thresholds.
public class RuleSettings
{
public int Id { get; set; } = 1;
// Applied / no response yet
public int AppliedFollowUpDays { get; set; } = 14;
public int AppliedGhostDays { get; set; } = 30;
// Offer / accepted waiting on next step
public int OfferFollowUpDays { get; set; } = 7;
public int OfferGhostDays { get; set; } = 14;
// Rejected but you requested feedback
public int FeedbackFollowUpDays { get; set; } = 7;
public int FeedbackGhostDays { get; set; } = 14;
}
}
+131
View File
@@ -0,0 +1,131 @@
namespace JobTrackerApi.Models;
public sealed class StructuredCvProfile
{
public string Version { get; set; } = "1";
public StructuredCvMetadata Metadata { get; set; } = new();
public StructuredCvContact Contact { get; set; } = new();
public List<string> Summary { get; set; } = new();
public List<StructuredCvJob> Jobs { get; set; } = new();
public List<StructuredCvEducation> Education { get; set; } = new();
public List<StructuredCvCertification> Certifications { get; set; } = new();
public List<StructuredCvProject> Projects { get; set; } = new();
public List<string> Skills { get; set; } = new();
public List<StructuredCvLanguage> Languages { get; set; } = new();
public List<string> Interests { get; set; } = new();
public List<string> Awards { get; set; } = new();
public List<string> Publications { get; set; } = new();
public List<string> Organisations { get; set; } = new();
public List<string> References { get; set; } = new();
public List<StructuredCvOtherSection> OtherSections { get; set; } = new();
public List<StructuredCvSection> Sections { get; set; } = new();
}
public sealed class StructuredCvMetadata
{
public int? ProfileVersion { get; set; }
public int? AppliedExtractionRunId { get; set; }
public DateTimeOffset? UpdatedAtUtc { get; set; }
public Dictionary<string, StructuredCvFieldMetadata> Fields { get; set; } = new();
}
public sealed class StructuredCvFieldMetadata
{
public double? Confidence { get; set; }
public string? Method { get; set; }
public string? SourceSnippet { get; set; }
public int? SourcePage { get; set; }
public string? SourceBlockId { get; set; }
public string? ReviewState { get; set; }
public DateTimeOffset? LastUpdatedAtUtc { get; set; }
}
public sealed class StructuredCvContact
{
public string? FullName { get; set; }
public string? Headline { get; set; }
public string? Email { get; set; }
public string? Phone { get; set; }
public string? Location { get; set; }
public string? Website { get; set; }
public string? LinkedIn { get; set; }
}
public sealed class StructuredCvJob
{
// Stable item ID (assigned by CareerProfileService on first save). Required for CV variants
// to reference "this job" across profile edits, instead of by array position. Nullable/empty
// on freshly-parsed or legacy data until the first save assigns it.
public string? Id { get; set; }
public string? Title { get; set; }
public string? Company { get; set; }
public string? Location { get; set; }
public string? Start { get; set; }
public string? End { get; set; }
// Best-effort "YYYY-MM" normalization of Start/End, computed alongside Id assignment.
// Null when Start/End can't be parsed; the free-string fields above remain the display source.
public string? StartDate { get; set; }
public string? EndDate { get; set; }
public bool IsCurrent { get; set; }
public List<string> Bullets { get; set; } = new();
public List<string> Skills { get; set; } = new();
}
public sealed class StructuredCvEducation
{
public string? Id { get; set; }
public string? Qualification { get; set; }
public string? QualificationLevel { get; set; }
public string? Institution { get; set; }
public string? Location { get; set; }
public string? Start { get; set; }
public string? End { get; set; }
public string? StartDate { get; set; }
public string? EndDate { get; set; }
public List<string> Details { get; set; } = new();
}
public sealed class StructuredCvCertification
{
public string? Id { get; set; }
public string? Name { get; set; }
public string? Issuer { get; set; }
public string? Location { get; set; }
public string? Date { get; set; }
public string? DateNormalized { get; set; }
public List<string> Details { get; set; } = new();
}
public sealed class StructuredCvProject
{
public string? Id { get; set; }
public string? Name { get; set; }
public string? Role { get; set; }
public string? Location { get; set; }
public string? Start { get; set; }
public string? End { get; set; }
public string? StartDate { get; set; }
public string? EndDate { get; set; }
public List<string> Bullets { get; set; } = new();
public List<string> Skills { get; set; } = new();
}
public sealed class StructuredCvLanguage
{
public string? Name { get; set; }
public string? Level { get; set; }
public string? Notes { get; set; }
}
public sealed class StructuredCvOtherSection
{
public string? Title { get; set; }
public List<string> Items { get; set; } = new();
}
public sealed class StructuredCvSection
{
public string Name { get; set; } = string.Empty;
public string Content { get; set; } = string.Empty;
public int WordCount { get; set; }
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,15 @@
namespace JobTrackerApi.Models;
public sealed class SystemEmailSettings
{
public int Id { get; set; } = 1;
public bool? Enabled { get; set; }
public string? SmtpHost { get; set; }
public int? SmtpPort { get; set; }
public string? SmtpUser { get; set; }
public string? SmtpPassword { get; set; }
public string? From { get; set; }
public string? FromName { get; set; }
public bool? SmtpEnableSsl { get; set; }
public int? SmtpTimeoutMs { get; set; }
}
+71
View File
@@ -0,0 +1,71 @@
namespace JobTrackerApi.Models;
public sealed class TailoredCvDraft
{
public int Id { get; set; }
public string OwnerUserId { get; set; } = string.Empty;
public int JobApplicationId { get; set; }
public JobApplication? JobApplication { get; set; }
public int? CanonicalProfileVersion { get; set; }
public string TemplateId { get; set; } = "ats-minimal";
public string? Headline { get; set; }
public string? SummaryJson { get; set; }
public string? SelectedSkillsJson { get; set; }
public string? ExperienceJson { get; set; }
public string? EducationJson { get; set; }
public string? CustomSectionsJson { get; set; }
public string? RenderOptionsJson { get; set; }
public string? GenerationContextHash { get; set; }
public DateTimeOffset? LastGeneratedAtUtc { get; set; }
public DateTimeOffset? LastEditedAtUtc { get; set; }
public string Status { get; set; } = "generated";
}
public sealed class TailoredCvDocument
{
public string TemplateId { get; set; } = "ats-minimal";
public string? Headline { get; set; }
public List<string> Summary { get; set; } = new();
public List<string> SelectedSkills { get; set; } = new();
public List<TailoredCvExperienceItem> Experience { get; set; } = new();
public List<TailoredCvEducationItem> Education { get; set; } = new();
public List<TailoredCvCustomSection> CustomSections { get; set; } = new();
public TailoredCvRenderOptions RenderOptions { get; set; } = new();
}
public sealed class TailoredCvExperienceItem
{
public string? Title { get; set; }
public string? Company { get; set; }
public string? Location { get; set; }
public string? Start { get; set; }
public string? End { get; set; }
public bool IsCurrent { get; set; }
public List<string> Bullets { get; set; } = new();
}
public sealed class TailoredCvEducationItem
{
public string? Qualification { get; set; }
public string? QualificationLevel { get; set; }
public string? Institution { get; set; }
public string? Location { get; set; }
public string? Start { get; set; }
public string? End { get; set; }
public List<string> Details { get; set; } = new();
}
public sealed class TailoredCvCustomSection
{
public string? Title { get; set; }
public List<string> Items { get; set; } = new();
}
public sealed class TailoredCvRenderOptions
{
public bool ShowPhoto { get; set; }
public string PageMode { get; set; } = "one-page";
public string AccentColor { get; set; } = "slate";
public List<string> SectionOrder { get; set; } = new() { "summary", "skills", "experience", "education", "custom" };
public string BulletDensity { get; set; } = "balanced";
}
+254
View File
@@ -0,0 +1,254 @@
using System.Text.Json;
using System.Text.Json.Serialization;
namespace JobTrackerApi.Models;
public static class TailoredCvDraftJson
{
private static readonly JsonSerializerOptions SerializerOptions = new(JsonSerializerDefaults.Web)
{
PropertyNameCaseInsensitive = true,
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull,
};
public static TailoredCvDocument Empty() => Normalize(new TailoredCvDocument());
public static TailoredCvDocument FromDraft(TailoredCvDraft? draft)
{
if (draft is null) return Empty();
var document = new TailoredCvDocument
{
TemplateId = string.IsNullOrWhiteSpace(draft.TemplateId) ? "base" : draft.TemplateId.Trim(),
Headline = TrimOrNull(draft.Headline),
Summary = DeserializeList(draft.SummaryJson),
SelectedSkills = DeserializeList(draft.SelectedSkillsJson),
Experience = DeserializeList<TailoredCvExperienceItem>(draft.ExperienceJson)
.Select(NormalizeExperience)
.Where(item => !string.IsNullOrWhiteSpace(item.Title) || !string.IsNullOrWhiteSpace(item.Company) || item.Bullets.Count > 0)
.ToList(),
Education = DeserializeList<TailoredCvEducationItem>(draft.EducationJson)
.Select(NormalizeEducation)
.Where(item => !string.IsNullOrWhiteSpace(item.Qualification) || !string.IsNullOrWhiteSpace(item.Institution) || item.Details.Count > 0)
.ToList(),
CustomSections = DeserializeList<TailoredCvCustomSection>(draft.CustomSectionsJson)
.Select(NormalizeCustomSection)
.Where(item => !string.IsNullOrWhiteSpace(item.Title) || item.Items.Count > 0)
.ToList(),
RenderOptions = DeserializeObject<TailoredCvRenderOptions>(draft.RenderOptionsJson) ?? new TailoredCvRenderOptions(),
};
return Normalize(document);
}
public static void ApplyToDraft(TailoredCvDraft draft, TailoredCvDocument? document)
{
var normalized = Normalize(document);
draft.TemplateId = normalized.TemplateId;
draft.Headline = TrimOrNull(normalized.Headline);
draft.SummaryJson = JsonSerializer.Serialize(normalized.Summary, SerializerOptions);
draft.SelectedSkillsJson = JsonSerializer.Serialize(normalized.SelectedSkills, SerializerOptions);
draft.ExperienceJson = JsonSerializer.Serialize(normalized.Experience, SerializerOptions);
draft.EducationJson = JsonSerializer.Serialize(normalized.Education, SerializerOptions);
draft.CustomSectionsJson = JsonSerializer.Serialize(normalized.CustomSections, SerializerOptions);
draft.RenderOptionsJson = JsonSerializer.Serialize(normalized.RenderOptions, SerializerOptions);
}
public static TailoredCvDocument Normalize(TailoredCvDocument? document)
{
document ??= new TailoredCvDocument();
document.TemplateId = string.IsNullOrWhiteSpace(document.TemplateId) ? "ats-minimal" : document.TemplateId.Trim();
document.Headline = TrimOrNull(document.Headline);
document.Summary = CleanList(document.Summary);
document.SelectedSkills = CleanList(document.SelectedSkills);
document.Experience = (document.Experience ?? new List<TailoredCvExperienceItem>())
.Select(NormalizeExperience)
.Where(item => !string.IsNullOrWhiteSpace(item.Title) || !string.IsNullOrWhiteSpace(item.Company) || item.Bullets.Count > 0)
.ToList();
document.Education = (document.Education ?? new List<TailoredCvEducationItem>())
.Select(NormalizeEducation)
.Where(item => !string.IsNullOrWhiteSpace(item.Qualification) || !string.IsNullOrWhiteSpace(item.Institution) || item.Details.Count > 0)
.ToList();
document.CustomSections = (document.CustomSections ?? new List<TailoredCvCustomSection>())
.Select(NormalizeCustomSection)
.Where(item => !string.IsNullOrWhiteSpace(item.Title) || item.Items.Count > 0)
.ToList();
document.RenderOptions ??= new TailoredCvRenderOptions();
document.RenderOptions.PageMode = string.IsNullOrWhiteSpace(document.RenderOptions.PageMode) ? "one-page" : document.RenderOptions.PageMode.Trim();
document.RenderOptions.AccentColor = string.IsNullOrWhiteSpace(document.RenderOptions.AccentColor) ? "slate" : document.RenderOptions.AccentColor.Trim();
document.RenderOptions.BulletDensity = string.IsNullOrWhiteSpace(document.RenderOptions.BulletDensity) ? "balanced" : document.RenderOptions.BulletDensity.Trim();
document.RenderOptions.SectionOrder = CleanList(document.RenderOptions.SectionOrder);
if (document.RenderOptions.SectionOrder.Count == 0)
{
document.RenderOptions.SectionOrder = new List<string> { "summary", "skills", "experience", "education", "custom" };
}
return document;
}
public static string RenderPlainText(TailoredCvDocument? document)
{
var normalized = Normalize(document);
var lines = new List<string>();
AddLine(lines, normalized.Headline);
if (normalized.Summary.Count > 0)
{
AddBlock(lines, "Professional Summary", normalized.Summary.Select(item => $"- {item}"));
}
if (normalized.SelectedSkills.Count > 0)
{
AddBlock(lines, "Core Skills", normalized.SelectedSkills);
}
if (normalized.Experience.Count > 0)
{
var block = new List<string>();
foreach (var item in normalized.Experience)
{
AddLine(block, item.Title);
var meta = string.Join(" | ", new[]
{
item.Company,
item.Location,
FormatDateRange(item.Start, item.End, item.IsCurrent)
}.Where(value => !string.IsNullOrWhiteSpace(value)));
AddLine(block, meta);
foreach (var bullet in item.Bullets)
{
AddLine(block, $"- {bullet}");
}
AddLine(block, string.Empty);
}
AddBlock(lines, "Experience", block);
}
if (normalized.Education.Count > 0)
{
var block = new List<string>();
foreach (var item in normalized.Education)
{
AddLine(block, string.IsNullOrWhiteSpace(item.QualificationLevel) ? item.Qualification : $"{item.Qualification} ({item.QualificationLevel})");
var meta = string.Join(" | ", new[]
{
item.Institution,
item.Location,
FormatDateRange(item.Start, item.End, false)
}.Where(value => !string.IsNullOrWhiteSpace(value)));
AddLine(block, meta);
foreach (var detail in item.Details)
{
AddLine(block, $"- {detail}");
}
AddLine(block, string.Empty);
}
AddBlock(lines, "Education", block);
}
foreach (var section in normalized.CustomSections)
{
AddBlock(lines, section.Title ?? "Additional Information", section.Items);
}
return string.Join("\n\n", lines.Where(line => !string.IsNullOrWhiteSpace(line)).Select(line => line.Trim())).Trim();
}
private static TailoredCvExperienceItem NormalizeExperience(TailoredCvExperienceItem? item)
{
item ??= new TailoredCvExperienceItem();
item.Title = TrimOrNull(item.Title);
item.Company = TrimOrNull(item.Company);
item.Location = TrimOrNull(item.Location);
item.Start = TrimOrNull(item.Start);
item.End = TrimOrNull(item.End);
item.Bullets = CleanList(item.Bullets);
item.IsCurrent = item.IsCurrent || string.Equals(item.End, "present", StringComparison.OrdinalIgnoreCase) || string.Equals(item.End, "current", StringComparison.OrdinalIgnoreCase);
return item;
}
private static TailoredCvEducationItem NormalizeEducation(TailoredCvEducationItem? item)
{
item ??= new TailoredCvEducationItem();
item.Qualification = TrimOrNull(item.Qualification);
item.QualificationLevel = TrimOrNull(item.QualificationLevel);
item.Institution = TrimOrNull(item.Institution);
item.Location = TrimOrNull(item.Location);
item.Start = TrimOrNull(item.Start);
item.End = TrimOrNull(item.End);
item.Details = CleanList(item.Details);
return item;
}
private static TailoredCvCustomSection NormalizeCustomSection(TailoredCvCustomSection? item)
{
item ??= new TailoredCvCustomSection();
item.Title = TrimOrNull(item.Title);
item.Items = CleanList(item.Items);
return item;
}
private static List<string> DeserializeList(string? json)
{
return DeserializeList<string>(json)
.Select(value => value?.Trim() ?? string.Empty)
.Where(value => !string.IsNullOrWhiteSpace(value))
.Distinct(StringComparer.OrdinalIgnoreCase)
.ToList();
}
private static List<T> DeserializeList<T>(string? json)
{
try
{
return string.IsNullOrWhiteSpace(json)
? new List<T>()
: JsonSerializer.Deserialize<List<T>>(json, SerializerOptions) ?? new List<T>();
}
catch
{
return new List<T>();
}
}
private static T? DeserializeObject<T>(string? json) where T : class
{
try
{
return string.IsNullOrWhiteSpace(json) ? null : JsonSerializer.Deserialize<T>(json, SerializerOptions);
}
catch
{
return null;
}
}
private static List<string> CleanList(IEnumerable<string>? values)
{
return (values ?? Array.Empty<string>())
.Select(value => value?.Trim() ?? string.Empty)
.Where(value => !string.IsNullOrWhiteSpace(value))
.Distinct(StringComparer.OrdinalIgnoreCase)
.ToList();
}
private static string? TrimOrNull(string? value) => string.IsNullOrWhiteSpace(value) ? null : value.Trim();
private static string? FormatDateRange(string? start, string? end, bool isCurrent)
{
if (string.IsNullOrWhiteSpace(start) && string.IsNullOrWhiteSpace(end)) return null;
if (string.IsNullOrWhiteSpace(start)) return end;
return $"{start} - {(isCurrent ? "Present" : end ?? "Present")}";
}
private static void AddBlock(List<string> lines, string title, IEnumerable<string> body)
{
var content = string.Join("\n", body.Where(line => !string.IsNullOrWhiteSpace(line)).Select(line => line.Trim())).Trim();
if (string.IsNullOrWhiteSpace(content)) return;
lines.Add($"{title}\n{content}");
}
private static void AddLine(List<string> lines, string? value)
{
if (!string.IsNullOrWhiteSpace(value)) lines.Add(value.Trim());
}
}
+16
View File
@@ -0,0 +1,16 @@
namespace JobTrackerApi.Models;
// "Trust this device for 30 days" -- lets a browser skip the 2FA code step after one successful
// challenge. Never store the plaintext token, only its SHA-256 hash, same rationale as
// TwoFactorRecoveryCode.CodeHash: a DB read (backup, replica, leaked snapshot) can't be turned
// into a working cookie.
public sealed class TrustedDevice
{
public int Id { get; set; }
public string UserId { get; set; } = "";
public string TokenHash { get; set; } = "";
public string? DeviceLabel { get; set; }
public DateTimeOffset CreatedAtUtc { get; set; }
public DateTimeOffset LastSeenAtUtc { get; set; }
public DateTimeOffset ExpiresAtUtc { get; set; }
}
@@ -0,0 +1,12 @@
namespace JobTrackerApi.Models;
// One-time-use 2FA recovery codes. Plaintext is shown once at generation time and never
// persisted -- only the SHA-256 hash is stored so a DB read can't recover usable codes.
public sealed class TwoFactorRecoveryCode
{
public int Id { get; set; }
public string UserId { get; set; } = "";
public string CodeHash { get; set; } = "";
public DateTimeOffset CreatedAtUtc { get; set; }
public DateTimeOffset? UsedAtUtc { get; set; }
}
+19
View File
@@ -0,0 +1,19 @@
namespace JobTrackerApi.Models;
public sealed class UserRuleSettings
{
public string OwnerUserId { get; set; } = "";
// Applied / no response yet
public int AppliedFollowUpDays { get; set; } = 14;
public int AppliedGhostDays { get; set; } = 30;
// Offer / accepted waiting on next step
public int OfferFollowUpDays { get; set; } = 7;
public int OfferGhostDays { get; set; } = 14;
// Rejected but you requested feedback
public int FeedbackFollowUpDays { get; set; } = 7;
public int FeedbackGhostDays { get; set; } = 14;
}
+17
View File
@@ -0,0 +1,17 @@
namespace JobTrackerApi.Models;
// Server-side record of a JWT issued via AppSessionIssuer. The JWT carries this row's Id as its
// "sid" claim; Program.cs's "local" JwtBearer OnTokenValidated looks the row up on every request
// so a session can actually be revoked before its JWT naturally expires (previously the JWT alone
// was the credential -- see AppSessionIssuer). Same shape/rationale as TrustedDevice, but this
// tracks the *session* itself rather than a "skip 2FA" cookie.
public sealed class UserSession
{
public string Id { get; set; } = "";
public string UserId { get; set; } = "";
public string? DeviceLabel { get; set; }
public DateTimeOffset CreatedAtUtc { get; set; }
public DateTimeOffset LastSeenAtUtc { get; set; }
public DateTimeOffset ExpiresAtUtc { get; set; }
public DateTimeOffset? RevokedAtUtc { get; set; }
}