Building and Deploying an AI-Powered Cover Letter Generator

App Live : https://ai-coverletter.netlify.app/
GitHub: https://github.com/kwagle7/AI-Personalized-Cover-Letter

AI-Powered Cover Letter Generator

Author: Kshitij Wagle (@kwagle)

๐Ÿ“Œ Introduction

This project is a complete AI-powered cover letter generator built with real-time personalization, PDF export, and secure API integrationโ€”all deployable in minutes. But it didnโ€™t start that way.

๐Ÿ” Project Origin: From Gemini App to Production

The idea began as a prototype using Gemini App, where I experimented with generative AI prompts to write cover letters based on a resume and job description.

What I did was: after building the initial app inside Gemini, I exported the app and completely revamped it using Windsurf and version control. This gave me flexibility to:

  • โœ… Rebuild the UI using Next.js and Tailwind CSS
  • ๐Ÿ” Move Gemini logic to a secure Netlify Function
  • ๐Ÿ“„ Add PDF downloads with jsPDF
  • ๐Ÿš€ Deploy the final version on Netlify
๐Ÿงช I used Windsurf for debugging, testing Gemini prompts, switching between models like SWE-1-lite and O3, and tracking logs. It made versioned deployment and prompt refinement much easier.

This guide will walk you through exactly how I went from a Gemini prototype to a secure, production-ready web app with built-in AI and PDF export.

๐ŸŽฏ Key Features

  • ๐Ÿ”ฎ Personalized cover letter via Google Gemini API
  • ๐Ÿงพ Downloadable PDF output using jsPDF
  • ๐Ÿ” API key hidden via Netlify Functions
  • ๐Ÿ’จ Deployed using Netlify (with optional Vercel)
  • ๐Ÿ›  Debugging and testing with Windsurf

๐Ÿงฐ Tech Stack

  • Frontend: Next.js, Tailwind CSS
  • Backend: Netlify Functions (Node.js)
  • AI: Google Gemini API
  • PDF: jsPDF
  • Automation & Debug: Windsurf
  • Deployment: Netlify (primary), Vercel (optional)

โš™๏ธ Step 1: Setup Project

Terminal Commands:
# Create a Next.js project
npx create-next-app AI-Personalized-Cover-Letter
cd AI-Personalized-Cover-Letter

# Install packages
npm install tailwindcss @google/generative-ai jsPDF
npx tailwindcss init -p
โœจ Tip: Import Tailwind in globals.css and configure it in tailwind.config.js

๐Ÿ–ผ Step 2: Design the UI

  • ๐ŸŽจ Clean card layout for input + preview
  • โœ… Real-time form validation
  • ๐Ÿ“ฑ Mobile responsive using Tailwind
  • ๐Ÿ”„ Tab navigation for switching views
Challenge: Pixel-perfect matching
Solution: Reusable components and Tailwind iterations

๐Ÿ” Step 3: Secure Gemini API

Created a serverless function /netlify/functions/generate-cover-letter.js that:

  • Receives prompt from frontend
  • Calls Google Gemini API
  • Returns generated cover letter
๐Ÿ›ก๏ธ All API calls are server-side โ†’ no key exposure โ†’ no CORS issues

๐Ÿ“„ Step 4: Generate PDF with jsPDF

  • Formatted AI response into styled single-page PDF
  • Parsed basic markdown (headings, bold, bullets)
  • Ensured fit on standard A4
Challenge: Markdown rendering
Solution: Wrote custom markdown-to-PDF parser

๐Ÿงช Step 5: Local Testing

Terminal Commands:
# Install all dependencies
npm install

# Create .env.local
echo "GEMINI_API_KEY=your-google-gemini-key" > .env.local

# Run local server
npm run dev

Visit: http://localhost:3000

โ˜๏ธ Step 6: Deploy to Netlify

Terminal Commands:
# One-time CLI setup
npm install -g netlify-cli
netlify login

# Init new project
netlify init

# Set environment variable
netlify env:set GEMINI_API_KEY your-google-gemini-key

# Build and deploy
npm run build
netlify deploy --build

# Deploy to production
netlify deploy --prod

๐ŸŒ Step 7: Optional Vercel Deployment

  • Push your repo to GitHub
  • Go to vercel.com and import
  • Set GEMINI_API_KEY in environment settings
  • Vercel auto-detects and deploys

๐Ÿงญ Windsurf Integration

Used Windsurf for:

  • ๐Ÿ“œ Real-time Gemini prompt debugging
  • ๐Ÿ“Š Viewing logs in /logs/YYYYMMDD*
  • โš™๏ธ Enhancing prompts with models like SWE-1-lite and O3
๐Ÿ” Windsurf helped in identifying token drift, formatting issues, and debugging edge cases in AI output.

๐Ÿšง Common Challenges & Fixes

Challenge Solution
API key exposureUsed serverless Netlify function
CORS errorsMoved Gemini API logic to backend
Markdown โ†’ PDFCustom parser & layout manager
Deployment failUsed Netlify CLI logs & env setup
Prompt debuggingUsed Windsurf models & logs

โœ… Terminal Command Summary

# Local dev
npm install
npm run dev

# Netlify CLI setup
npm install -g netlify-cli
netlify login

# Project init
netlify init
netlify env:set GEMINI_API_KEY your-google-gemini-key

# Deploy
npm run build
netlify deploy --build
netlify deploy --prod

๐Ÿ Conclusion

This project combined AI, automation, and full-stack skills to create a smart, deployable cover letter tool. Starting from Gemini, then revamped with Windsurf and deployed on Netlifyโ€”itโ€™s fast, scalable, and ready for real-world use.


โœจ Quick Note: What This App Delivers

This AI-powered app generates professionally structured, visually appealing, and job-tailored cover lettersโ€”instantly.

  • โœ… Starts directly with a subject line or greeting
  • โœ… Clearly states the position being applied for
  • โœ… Highlights the applicantโ€™s strengths in a dynamic, non-generic tone
  • โœ… Uses markdown structure (headers, bullets, bold) for readability
  • โœ… Includes sections like ## Key Strengths and optional breaks like ---***---
  • โœ… Ends with a clean, professional closing
  • โœ… Exports as a styled one-page PDFโ€”no extra text, no fluff

The result? A concise, impactful cover letter tailored for every job, every time.


Discover more from Data Engineer Journey

Subscribe to get the latest posts sent to your email.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top

Discover more from Data Engineer Journey

Subscribe now to keep reading and get access to the full archive.

Continue reading