Auto-deploy: 2026-06-02 16:37:46

This commit is contained in:
Hamza-Ayed
2026-06-02 16:37:46 +03:00
parent dad9cba7db
commit e153327bba
6 changed files with 433 additions and 12 deletions

View File

@@ -57,8 +57,29 @@ $geminiUrl = "https://generativelanguage.googleapis.com/v1beta/models/{$model}:g
// ==========================================
if ($action === 'generatePdf') {
$jobDescription = $data['jobDescription'] ?? '';
$prompt = "You are an expert ATS CV tailor. Read the following job description and generate tailored content for my CV to maximize my chances of getting an interview.
$template = $data['template'] ?? 'default'; // 'amman' or 'default'
// --- Amman Market Prompt (Senior Backend Engineer & Technical Lead) ---
if ($template === 'amman') {
$prompt = "You are an expert ATS CV tailor for the Jordan/Amman local tech market. Read the following job description and generate tailored content.
STRICT INTEGRITY RULES:
1. NEVER invent skills I do not have. My TRUE technical stack is: PHP (Workerman), Node.js, NestJS, Python (FastAPI/Flask), PostgreSQL/PostGIS, Docker, Flutter, GetX, BLoC, WebSockets, OpenStreetMap.
2. Do NOT add data science skills like TensorFlow, PyTorch, Scikit-learn, Hadoop, or MLOps.
3. My title MUST be aligned with 'Senior Backend Engineer', 'Technical Lead', or 'Lead Backend Engineer'. NEVER use 'Solutions Architect', 'AI Developer', or 'CTO'.
Return ONLY a valid JSON object with EXACTLY three keys: 'headline', 'summary', and 'skills'.
The 'headline' should be a clean, confident title based on my TRUE skills — matching Amman market expectations (Senior/Lead Backend Engineer).
The 'summary' should open with a hook about building and scaling production systems in the MENA region, emphasizing delivery, cost optimization, and hands-on engineering. Connect my real achievements to the job requirements. Keep it professional and direct — NO academic fluff, NO 'I leverage my expertise' phrases.
The 'skills' should be a comma-separated list of 10 highly relevant ATS keywords from MY ACTUAL SKILLS that match the job. Prioritize backend, API, database, and infrastructure skills over GIS.
Do NOT use markdown blocks like ```json, just return raw JSON text.
Job Description:
" . substr($jobDescription, 0, 4000);
}
// --- Default Prompt (Current — Enterprise/GCC) ---
else {
$prompt = "You are an expert ATS CV tailor. Read the following job description and generate tailored content for my CV to maximize my chances of getting an interview.
STRICT INTEGRITY RULES:
1. NEVER invent skills I do not have. My TRUE technical stack is: PHP (Workerman), Node.js, NestJS, Python (FastAPI/Flask), PostgreSQL/PostGIS, Docker, Flutter, GetX, BLoC, WebSockets, OpenStreetMap.
@@ -73,6 +94,7 @@ Do NOT use markdown blocks like ```json, just return raw JSON text.
Job Description:
" . substr($jobDescription, 0, 4000);
}
$payload = json_encode([
"contents" => [["parts" => [["text" => $prompt]]]],
@@ -99,12 +121,17 @@ Job Description:
$aiText = str_replace(['```json', '```'], '', $aiText);
$parsedJson = json_decode(trim($aiText), true);
$headline = $parsedJson['headline'] ?? "Solutions Architect & Technical Leader";
$defaultHeadline = ($template === 'amman')
? "Senior Backend Engineer & Technical Lead"
: "Solutions Architect & Technical Leader";
$headline = $parsedJson['headline'] ?? $defaultHeadline;
$summary = $parsedJson['summary'] ?? "Experienced professional with a strong background in software engineering.";
$skills = $parsedJson['skills'] ?? "Architecture, APIs, Cloud, Backend Systems, System Design";
$templatePath = __DIR__ . '/cv_template.html';
$html = file_get_contents($templatePath);
$templateFile = ($template === 'amman')
? __DIR__ . '/cv_template_amman.html'
: __DIR__ . '/cv_template.html';
$html = file_get_contents($templateFile);
$html = str_replace('{{JOB_HEADLINE}}', htmlspecialchars($headline), $html);
$html = str_replace('{{TAILORED_SUMMARY}}', htmlspecialchars($summary), $html);
$html = str_replace('{{DYNAMIC_SKILLS}}', htmlspecialchars($skills), $html);