Skip to content

SK2837/AI-JobAgent

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

4 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

AI Job Agent πŸ€–

An intelligent automation system that scrapes job postings, tailors resumes using AI, and automates job application submissions.

πŸ“‹ Overview

AI Job Agent is a FastAPI-based application that leverages LangChain, OpenAI, and Playwright to streamline the job application process. It consists of three core services that work together to automate job hunting:

  1. Job Scraper: Extracts job details from various platforms (LinkedIn, Indeed, etc.)
  2. Resume Tailoring: Uses LLM to customize resumes for specific job descriptions
  3. Application Submitter: Automates form filling and submission (LinkedIn Easy Apply)

✨ Features

  • πŸ” Intelligent Job Scraping: Playwright-based scrapers for dynamic content
  • πŸ€– AI-Powered Resume Customization: LangChain + OpenAI GPT-3.5 integration
  • πŸ“ Automatic Application Submission: Browser automation with Playwright
  • πŸ’Ύ Database Persistence: SQLAlchemy with PostgreSQL/SQLite support
  • πŸš€ RESTful API: FastAPI with automatic interactive documentation
  • πŸ›‘οΈ Robust Error Handling: Graceful degradation when services unavailable
  • πŸ§ͺ Comprehensive Testing: Unit and integration tests with pytest

πŸ› οΈ Tech Stack

Backend

  • FastAPI: Modern async web framework
  • LangChain: LLM orchestration framework
  • OpenAI API: GPT-3.5-turbo for resume tailoring
  • Playwright: Browser automation for scraping/submission
  • SQLAlchemy: ORM for database operations

Database

  • PostgreSQL: Production database (recommended)
  • SQLite: Development/testing database

Libraries

  • BeautifulSoup4: HTML parsing
  • Pydantic: Data validation
  • Uvicorn: ASGI server

πŸ“¦ Installation

Prerequisites

  • Python 3.10+
  • PostgreSQL (optional, SQLite works for development)
  • OpenAI API key

Setup

  1. Clone the repository
git clone <repository-url>
cd ai-job-agent
  1. Create virtual environment
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
  1. Install dependencies
pip install -r requirements.txt
  1. Install Playwright browsers
playwright install chromium
  1. Configure environment variables
cp .env.example .env
# Edit .env with your credentials

Required environment variables:

DATABASE_URL=postgresql://user:password@localhost/dbname
OPENAI_API_KEY=sk-your-openai-api-key
  1. Initialize database
# Database tables are created automatically on first run
# Or manually with:
python -c "from app.database import engine, Base; from app.models import *; Base.metadata.create_all(bind=engine)"

πŸš€ Usage

Start the server

Development:

uvicorn app.main:app --reload

Production:

uvicorn app.main:app --host 0.0.0.0 --port 8000

API Documentation

Once running, visit:

API Endpoints

1. Scrape Job Posting

POST /jobs/scrape
Content-Type: application/json

{
  "url": "https://www.linkedin.com/jobs/view/123456"
}

Response:

{
  "id": 1,
  "title": "Senior Software Engineer",
  "company": "Tech Corp",
  "description": "Job description...",
  "url": "https://...",
  "source": "linkedin",
  "created_at": "2025-11-24T12:00:00"
}

2. Tailor Resume

POST /resumes/tailor
Content-Type: application/json

{
  "base_resume": "Your base resume content...",
  "job_description": "Target job description..."
}

Response:

{
  "id": 1,
  "content": "Tailored resume content optimized for the job...",
  "base_resume": false,
  "created_at": "2025-11-24T12:00:00"
}

3. Submit Application

POST /applications/submit
Content-Type: application/json

{
  "job_id": 1,
  "resume_id": 1
}

Response:

{
  "id": 1,
  "job_id": 1,
  "resume_id": 1,
  "status": "submitted",
  "created_at": "2025-11-24T12:00:00"
}

πŸ“ Project Structure

ai-job-agent/
β”œβ”€β”€ app/
β”‚   β”œβ”€β”€ __init__.py
β”‚   β”œβ”€β”€ main.py                 # FastAPI application & endpoints
β”‚   β”œβ”€β”€ database.py             # Database configuration
β”‚   β”œβ”€β”€ models.py               # SQLAlchemy models
β”‚   β”œβ”€β”€ agent.py                # LangChain agent setup
β”‚   └── services/
β”‚       β”œβ”€β”€ __init__.py
β”‚       β”œβ”€β”€ scraper.py          # Base scraper & factory
β”‚       β”œβ”€β”€ resume.py           # LLM resume builder
β”‚       β”œβ”€β”€ submitter.py        # Application submitter
β”‚       └── scrapers/
β”‚           β”œβ”€β”€ __init__.py
β”‚           └── linkedin.py     # LinkedIn-specific scraper
β”œβ”€β”€ tests/
β”‚   β”œβ”€β”€ test_basic.py           # Service unit tests
β”‚   β”œβ”€β”€ test_scraper.py         # Scraper tests
β”‚   β”œβ”€β”€ test_resume_llm.py      # LLM integration tests
β”‚   └── test_api.py             # API endpoint tests
β”œβ”€β”€ requirements.txt
β”œβ”€β”€ .env.example
└── README.md

πŸ”„ Implementation Workflow

1. Job Scraping Flow

User provides URL
    ↓
ScraperFactory selects appropriate scraper
    ↓
Playwright launches browser β†’ Navigates to URL
    ↓
BeautifulSoup parses HTML β†’ Extracts data
    ↓
Job saved to database β†’ Returns Job object

2. Resume Tailoring Flow

User provides base resume + job description
    ↓
ResumeBuilder initializes ChatOpenAI
    ↓
Prompt template formats input
    ↓
LLM generates tailored resume
    ↓
Resume saved to database β†’ Returns Resume object

3. Application Submission Flow

User provides job_id + resume_id
    ↓
Application record created (status: PENDING)
    ↓
ApplicationSubmitter routes to correct submitter
    ↓
LinkedIn: Launch browser β†’ Login β†’ Navigate to job β†’ Click Easy Apply
    ↓
Fill form fields β†’ Submit β†’ Update status

πŸ§ͺ Testing

Run all tests:

DATABASE_URL=sqlite:///./test.db pytest tests/

Run specific test file:

DATABASE_URL=sqlite:///./test.db pytest tests/test_api.py -v

With coverage:

DATABASE_URL=sqlite:///./test.db pytest --cov=app tests/

βš™οΈ Configuration

Database Options

PostgreSQL (Production):

DATABASE_URL=postgresql://user:password@localhost:5432/jobagent

SQLite (Development):

DATABASE_URL=sqlite:///./dev.db

Scraper Configuration

The ScraperFactory automatically selects scrapers based on URL:

  • Contains linkedin.com β†’ LinkedInScraper
  • Default β†’ MockScraper

LLM Configuration

Edit app/services/resume.py to customize:

self.llm = ChatOpenAI(
    temperature=0.7,        # Creativity (0-1)
    model="gpt-3.5-turbo"  # Model selection
)

Available models:

  • gpt-3.5-turbo (faster, cheaper)
  • gpt-4 (higher quality, slower)

πŸ”’ Security Notes

  • Never commit .env file or API keys to version control
  • Use environment variables for all sensitive data
  • Implement rate limiting for production deployments
  • Consider using background tasks (Celery/Arq) for long-running operations
  • Add authentication/authorization for production API

🚧 Current Limitations

  1. LinkedIn Scraper: Only handles public job pages (no authentication)
  2. Application Submitter: Skeleton implementation (requires manual login setup)
  3. Error Recovery: Limited retry logic for network failures
  4. Rate Limiting: No built-in request throttling

🎯 Future Enhancements

  • Complete LinkedIn Easy Apply automation with cookie-based auth
  • Add Indeed, Glassdoor scrapers
  • Implement background task queue (Celery)
  • Add job matching/filtering based on criteria
  • Email notifications for application status
  • Web UI dashboard for monitoring
  • Export applications to CSV/PDF
  • Multi-tenant support with user authentication

🀝 Contributing

  1. Fork the repository
  2. Create feature branch (git checkout -b feature/amazing-feature)
  3. Commit changes (git commit -m 'Add amazing feature')
  4. Push to branch (git push origin feature/amazing-feature)
  5. Open Pull Request

πŸ“ License

This project is licensed under the MIT License - see LICENSE file for details.

πŸ™ Acknowledgments

πŸ“§ Support

For issues and questions:


Note: This tool is for educational purposes. Always respect websites' Terms of Service and robots.txt when scraping. Use responsibly and ethically.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages