Automating Resume Screening with Streamlit and Gemini AI

Posted byreaderavskh Posted onMarch 21, 2025 Comments0

In the modern hiring landscape, Applicant Tracking Systems (ATS) play a crucial role in automating resume screening and shortlisting candidates efficiently. Traditional ATS solutions often rely on keyword matching, but with advancements in AI, we can now leverage powerful language models like Google Gemini to enhance the screening process.

In this tutorial, we’ll walk through building an AI-powered ATS using Streamlit and Gemini, allowing recruiters to upload resumes, extract key insights, and match candidates based on job requirements. The application will provide intelligent analysis, ranking resumes based on relevance while offering an intuitive and interactive UI.

By the end of this guide, you’ll have a functional ATS system that can:
✅ Parse and extract information from resumes
✅ Evaluate candidate suitability using Gemini AI
✅ Provide a user-friendly Streamlit interface

Now, let’s dive into the code and explore how to build this system step by step. 🚀

Setting Up the Environment

Before building the AI-powered ATS system, we need to set up our environment by installing the necessary libraries and importing them into our project.

1. Importing Required Libraries

import streamlit as st
import google.generativeai as genai
import os
import json
from dotenv import load_dotenv
import PyPDF2 as pdf
import docx2txt

Here’s a breakdown of what each import does:

  • streamlit – Used for building the web interface of our ATS system.
  • google.generativeai – The official library for interacting with Google’s Gemini AI to process resumes.
  • os and json – Standard Python modules for handling file operations and JSON data.
  • dotenv.load_dotenv – Loads environment variables (such as API keys) from a .env file.
  • PyPDF2 – Used for extracting text from PDF resumes.
  • docx2txt – Helps extract text from Word documents (.docx resumes).

2. Installing Dependencies

Before running the code, make sure you install the required dependencies using:

pip install streamlit google-generativeai python-dotenv pypdf2 docx2txt

With our environment set up, let’s move on to configuring the Gemini API and handling resume uploads! 🚀

Configuring the Gemini AI Model

Now that we have imported the necessary libraries, the next step is to configure Google Gemini AI to process and analyze resumes.

1. Loading API Keys Securely

# Load environment variable from .env file
load_dotenv()

# Configure Gemini AI model with API key
genai.configure(api_key=os.getenv("GOOGLE_API_KEY"))

To keep our API keys secure, we store them in a .env file and load them using dotenv. This ensures our credentials are not exposed in the source code.

💡 Make sure you create a .env file in your project directory and add your Gemini API key:

GOOGLE_API_KEY=your_api_key_here

2. Setting Up the Model Configuration

generation_config = {
    "temperature": 0.4,
    "top_p": 1,
    "top_k": 32,
    "max_output_tokens": 4096,
}

These parameters control how Gemini generates responses:

  • temperature: 0.4 – Controls randomness; lower values make responses more predictable.
  • top_p: 1 – Nucleus sampling; 1 means the model considers all probabilities.
  • top_k: 32 – The model selects from the top 32 most likely tokens.
  • max_output_tokens: 4096 – Limits the maximum number of tokens in the response.

3. Implementing Safety Filters

safety_settings = [
    {"category": f"HARM_CATEGORY_{category}", "threshold": "BLOCK_MEDIUM_AND_ABOVE"}
    for category in ["HARASSMENT", "HATE_SPEECH", "SEXUALLY_EXPLICIT", "DANGEROUS_CONTENT"]
]

To ensure that the generated text remains safe and professional, we define safety settings that block harmful content related to:
✅ Harassment
✅ Hate Speech
✅ Sexually Explicit Content
✅ Dangerous Content

Now that our AI model is configured, let’s move on to handling resume file uploads and extracting content! 🚀

Processing Resumes with AI and Text Extraction

Now that we’ve set up Gemini AI, the next step is to process uploaded resumes. We’ll implement three key functions:

  1. Generating AI-powered responses using Gemini
  2. Extracting text from PDF resumes
  3. Extracting text from DOCX resumes

1. Generating Responses with Gemini

def generate_response_from_gemini(input_text):
    # Create GenerativeModel instance with 'gemini-2.0-flash'
    llm = genai.GenerativeModel(
        model_name="gemini-2.0-flash",
        generation_config=generation_config,
        safety_settings=safety_settings,
    )

    # Generate content based on input text
    output = llm.generate_content(input_text)

    return output.text

This function takes an input text, sends it to Gemini AI, and returns the generated response. We are using Gemini 2.0 Flash, a lightweight and fast model optimized for quick responses.

💡 This function will be useful for analyzing resumes, summarizing content, and matching candidates to job descriptions.

2. Extracting Text from PDF Resumes

def extract_text_from_pdf_file(uploaded_file):
    pdf_reader = pdf.PdfReader(uploaded_file)
    text_content = ""
    for page in pdf_reader.pages:
        text_content += str(page.extract_text())
    return text_content

Since many resumes are in PDF format, we use PyPDF2 to extract text from each page. This function reads the uploaded PDF, iterates through its pages, and extracts the text.

3. Extracting Text from DOCX Resumes

def extract_text_from_docx_file(uploaded_file):
    return docx2txt.process(uploaded_file)

For Word documents (.docx format), we use docx2txt to extract the text content. This ensures that we can process resumes in multiple formats.

Now that we have the text extraction functions ready, let’s move on to building the Streamlit UI and handling file uploads! 🚀

Building the ATS Resume Tracker UI with Streamlit

With our Gemini AI model and resume text extraction functions ready, let’s now build the Streamlit user interface (UI) for our ATS (Applicant Tracking System) tool.

1. Defining the Prompt for AI Analysis

input_prompt_template = """
As an experienced Applicant Tracking System (ATS) analyst, 
with profound knowledge in technology, software engineering, data science, full-stack web development, cloud engineering, 
cloud developers, DevOps engineering, and big data engineering, your role involves evaluating resumes against job descriptions.
Recognizing the competitive job market, provide top-notch assistance for resume improvement.
Your goal is to analyze the resume against the given job description, 
assign a percentage match based on key criteria, and pinpoint missing keywords accurately.
resume:{text}
description:{job_description}
I want the response in the following format.
Mention strong points of my CV in one section. 
In the next section, mention which of my skills or experience matches with the job description. 
In the last section, highlight missing skills or experience for the job.
"""

This prompt template provides clear instructions to Gemini AI on how to analyze the resume against a job description. The AI will return:
Strong points of the resume
Matching skills & experience
Missing skills or experience

2. Setting Up the Streamlit Page

st.set_page_config(page_title="ATS Resume Pro")
st.title("Track My Resume")

st.markdown('<style>h1{color: orange; text-align: center; font-family:POPPINS}</style>', unsafe_allow_html=True)

We configure Streamlit’s page settings and apply some custom HTML styling to make the UI visually appealing.

3. Accepting Job Descriptions and Resume Uploads

job_description = st.text_area("Paste the Job Description", height=300)

uploaded_file = st.file_uploader("Upload Your Resume", type=["pdf", "docx"], help="Please upload a PDF or DOCX file")

if uploaded_file is not None:
    st.markdown('<h8 style="color: lightgreen;text-align: center;">File uploaded successfully!</h8>', unsafe_allow_html=True)
else:
    st.markdown('<h8 style="color: red;text-align: center;">Please upload your Resume!</h8>', unsafe_allow_html=True)
  • The user pastes the job description in a text area.
  • A file uploader allows users to upload their PDF or DOCX resumes.
  • The app provides real-time feedback on whether the file was uploaded successfully.

4. Processing the Resume and Generating ATS Analysis

submit_button = st.button("Check ATS Result")

if submit_button:   
    if uploaded_file is not None:
        if uploaded_file.type == "application/pdf":
            resume_text = extract_text_from_pdf_file(uploaded_file)
        elif uploaded_file.type == "application/vnd.openxmlformats-officedocument.wordprocessingml.document":
            resume_text = extract_text_from_docx_file(uploaded_file)

        response_text = generate_response_from_gemini(input_prompt_template.format(text=resume_text, job_description=job_description))
        st.write(response_text)

When the “Check ATS Result” button is clicked:
✅ The resume is processed (PDF or DOCX text extraction).
✅ The text is sent to Gemini AI for analysis.
✅ The AI-generated response is displayed, providing insights into how well the resume matches the job description.

Conclusion

In today’s competitive job market, having an ATS-friendly resume is crucial for landing interviews. This AI-powered ATS Resume Tracker simplifies the process by analyzing resumes against job descriptions, highlighting strong points, matched skills, and missing qualifications. With Gemini AI and Streamlit, users receive instant, actionable feedback to optimize their resumes for better job prospects.

The full project, including the source code, is available on GitHub:
🔗 GitHub Repository

Feel free to explore, contribute, and enhance the tool further! 🚀

Category

Leave a Comment