Skip to content

Latest commit

 

History

4 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

AI Job Agent Backend

AI Job Agent Backend is a FastAPI-based service that uses an LLM (OpenAI) to automatically generate answers for job application forms.

It works with a browser extension or frontend agent that extracts form fields from job application pages and sends them to this backend. The backend then generates appropriate answers using the user's profile and job context.


Features

  • FastAPI REST API
  • AI-powered form answer generation
  • Uses OpenAI GPT models
  • Token-based authentication
  • Basic rate limiting
  • JSON structured responses
  • CORS enabled for browser extensions
  • Health monitoring endpoint

Architecture

Browser Extension / Frontend

│ POST /generate

AI Job Agent Backend (FastAPI)


OpenAI GPT Model


Generated Answers


Project Structure

ai-job-agent-backend/ │ ├── main.py ├── .env ├── requirements.txt └── README.md


Requirements

  • Python 3.9+
  • FastAPI
  • Uvicorn
  • OpenAI API key

Installation

Clone repository

git clone https://github.com/YOUR_USERNAME/ai-job-agent-backend.git\ cd ai-job-agent-backend

Create virtual environment

python -m venv venv
source venv/bin/activate

Windows:

venv\Scripts{=tex}\activate{=tex}


Install dependencies

pip install fastapi uvicorn python-dotenv openai pydantic

Or create a requirements.txt:

fastapi
uvicorn
python-dotenv
openai
pydantic

Then run:

pip install -r requirements.txt


Environment Variables

Create a .env file in the project root.

OPENAI_API_KEY=your_openai_api_key
AGENT_API_TOKEN=your_secret_token
MODEL=gpt-4o-mini
ALLOWED_ORIGINS=chrome-extension://*

Variable Description


OPENAI_API_KEY OpenAI API key AGENT_API_TOKEN Token used for authenticating requests MODEL OpenAI model used for generation ALLOWED_ORIGINS Allowed origins for CORS


Running the Server

Start the FastAPI server:

uvicorn main:app --reload

Server runs at:

http://localhost:8000

API documentation:

http://localhost:8000/docs


API Endpoints

Health Check

GET /health

Response:

{ "ok": true, "model": "gpt-4o-mini" }


Generate Answers

POST /generate

Headers:

x-agent-token: YOUR_AGENT_API_TOKEN
Content-Type: application/json

Request Example:

{ "page_url": "https://jobs.company.com/apply", "profile": { "name": "John Doe", "skills": ["Python", "SQL", "FastAPI"] }, "fields": [ { "id": "q1", "label": "Why do you want to work here?", "tag": "textarea", "type": "text" } ], "job_context": "Backend software engineer role" }

Response:

{ "answers": { "q1": "I am interested in this role because it aligns with my backend engineering experience." } }


Security

Token Authentication

Requests must include:

x-agent-token

Otherwise the API returns:

401 Unauthorized


Rate Limiting

The backend enforces a simple in-memory rate limit:

1 request per 0.8 seconds per token

If exceeded:

429 Too Many Requests


LLM Prompt Rules

The system instructs the model to:

  • Be professional and concise
  • Never invent credentials
  • Use only provided profile data
  • Return "NEEDS_USER" if a question requires user decision
  • Choose best option for dropdown fields

Output format:

{ "field_id": "answer" }


Future Improvements

Possible improvements:

  • Redis rate limiting
  • Resume parsing
  • Vector search for profile knowledge
  • Logging and monitoring
  • OAuth authentication
  • Multi-model support

License

MIT License

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages