feat: CV Batches system with AI extraction, matching, and slide-in chat
This commit is contained in:
55
database.py
55
database.py
@@ -181,6 +181,61 @@ CREATE INDEX IF NOT EXISTS idx_certifications_candidate ON certifications(candid
|
||||
CREATE INDEX IF NOT EXISTS idx_generated_cvs_candidate ON generated_cvs(candidate_id);
|
||||
CREATE INDEX IF NOT EXISTS idx_generated_cvs_requirement ON generated_cvs(requirement_request_id);
|
||||
CREATE INDEX IF NOT EXISTS idx_chat_messages_conversation ON chat_messages(conversation_id);
|
||||
|
||||
-- ============================================================
|
||||
-- CV BATCHES — group candidates for a specific requirement
|
||||
-- ============================================================
|
||||
|
||||
-- Main batch table (one per requirement document or manual creation)
|
||||
CREATE TABLE IF NOT EXISTS cv_batches (
|
||||
id UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
|
||||
name VARCHAR(255) NOT NULL,
|
||||
description TEXT,
|
||||
-- Raw text of the uploaded requirements document (backend-only, AI use)
|
||||
-- Null for manually created batches
|
||||
requirements_text TEXT,
|
||||
-- JSON array of positions extracted from the document
|
||||
-- [{job_title, num_positions, required_skills, required_years, required_certs, description}]
|
||||
positions JSONB DEFAULT '[]',
|
||||
-- draft = still working, active = matching done, exported = CVs generated
|
||||
status VARCHAR(50) DEFAULT 'draft',
|
||||
created_at TIMESTAMPTZ DEFAULT NOW(),
|
||||
updated_at TIMESTAMPTZ DEFAULT NOW()
|
||||
);
|
||||
|
||||
-- Batch items (candidates linked to a batch)
|
||||
CREATE TABLE IF NOT EXISTS batch_items (
|
||||
id UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
|
||||
batch_id UUID REFERENCES cv_batches(id) ON DELETE CASCADE,
|
||||
candidate_id UUID REFERENCES candidates(id) ON DELETE CASCADE,
|
||||
-- Which position in the batch this candidate is matched to (free text)
|
||||
position_title VARCHAR(255),
|
||||
-- AI match score 0-100
|
||||
match_score INTEGER DEFAULT 0,
|
||||
-- AI reasoning for the match
|
||||
match_reasoning TEXT,
|
||||
-- Realigned CV data (JSON — the reworded CV for this specific post)
|
||||
realigned_cv_data JSONB,
|
||||
-- proposed = AI suggested, approved = user confirmed, removed = user rejected
|
||||
status VARCHAR(50) DEFAULT 'proposed',
|
||||
-- Path to generated PDF after generation
|
||||
generated_cv_path TEXT,
|
||||
created_at TIMESTAMPTZ DEFAULT NOW(),
|
||||
updated_at TIMESTAMPTZ DEFAULT NOW()
|
||||
);
|
||||
|
||||
-- Batch chat (messages per batch's discussion)
|
||||
CREATE TABLE IF NOT EXISTS batch_chat (
|
||||
id UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
|
||||
batch_id UUID REFERENCES cv_batches(id) ON DELETE CASCADE,
|
||||
role VARCHAR(50) NOT NULL, -- 'user' or 'assistant'
|
||||
content TEXT NOT NULL,
|
||||
created_at TIMESTAMPTZ DEFAULT NOW()
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_batch_items_batch ON batch_items(batch_id);
|
||||
CREATE INDEX IF NOT EXISTS idx_batch_items_candidate ON batch_items(candidate_id);
|
||||
CREATE INDEX IF NOT EXISTS idx_batch_chat_batch ON batch_chat(batch_id);
|
||||
"""
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user