Skip to content

An intelligent, AI-powered job application automation system. This system can automatically navigate job sites, fill application forms, upload resumes, and submit applications with comprehensive reporting and analytics.

Notifications You must be signed in to change notification settings

classyrazy/brown-envelope

Repository files navigation

Brown Envelope - An AI Job Application Automation System πŸ€–

An intelligent, AI-powered job application automation system built with Stagehand and Google Gemini. This system can automatically navigate job sites, fill application forms, upload resumes, and submit applications with comprehensive reporting and analytics.

πŸ“š Table of Contents

πŸš€ Features

✨ Core Automation Capabilities

  • Intelligent Page Detection - AI-powered analysis of job sites and application forms
  • Multi-Site Support - Works across different job platforms and company career pages
  • Smart Form Filling - Contextual field analysis and intelligent data entry
  • Resume Upload - Automated file upload with multiple fallback strategies
  • Error Recovery - Robust error handling with retry logic and screenshot debugging
  • Multi-Language Support - Handles job sites in different languages

πŸ“Š Advanced Reporting System

  • Real-time Progress Tracking - Live updates during job processing
  • Comprehensive Analytics - Success rates, processing times, and error analysis
  • Professional Markdown Reports - Detailed reports with statistics and recommendations
  • Screenshot Documentation - Visual debugging with automatic screenshot capture
  • Error Pattern Analysis - Identifies common failure modes for optimization

πŸ›‘οΈ Reliability Features

  • Robust Error Handling - Multiple retry strategies and graceful degradation
  • Form Validation - Pre-submission checks to prevent failures
  • Rate Limiting - Respectful automation with appropriate delays
  • Session Management - Handles authentication and session persistence

πŸ“‹ Prerequisites

  • Node.js (v16 or higher)
  • Google API Key (for Gemini AI model)
  • Resume file (PDF format recommended)

πŸ”§ Installation

  1. Clone the repository

    git clone https://github.com/classyrazy/brown-envelope.git
    cd brown-envelope
  2. Install dependencies

    yarn
  3. Environment setup Copy the example environment file and configure:

    cp .env.example .env
  4. Configure your environment variables (see Configuration section below)

βš™οΈ Configuration

Create a .env file with the following variables:

Required Configuration

# Google AI API Key (Required)
GOOGLE_API_KEY=your_google_api_key_here

# Personal Information
APPLICANT_FIRST_NAME=John
APPLICANT_LAST_NAME=Doe
APPLICANT_EMAIL=john.doe@example.com
APPLICANT_PHONE=+1234567890
APPLICANT_COUNTRY_CODE=+1
APPLICANT_PHONE_WITHOUT_COUNTRY_CODE=234567890
APPLICANT_COUNTRY=United States
APPLICANT_CITY=New York

# Professional Information
APPLICANT_LINKEDIN=https://linkedin.com/in/johndoe
APPLICANT_PORTFOLIO_URL=https://yourportfolio.com
APPLICANT_GITHUB_URL=https://github.com/yourusername
APPLICANT_EXPERIENCE_LEVEL=Mid-level
APPLICANT_EDUCATION_LEVEL=Bachelor's Degree
APPLICANT_COURSE_OF_STUDY=Computer Science
APPLICANT_SKILLS=JavaScript,TypeScript,React,Node.js
APPLICANT_SALARY_RANGE=$60,000 - $80,000

# File Paths
RESUME_PATH=/path/to/your/resume.pdf

# Optional Authentication
DEFAULT_PASSWORD=YourDefaultPassword123!
LINKEDIN_PASSWORD=YourLinkedInPassword123!

Getting Google API Key

  1. Go to Google AI Studio
  2. Create a new API key
  3. Copy the key to your .env file

πŸƒβ€β™‚οΈ Usage

Basic Usage

Run the job application process:

yarn start

Test Resume Upload

Test the resume upload functionality:

# Uncomment the test function in index.ts and run:
yarn start

Adding Jobs

Edit the jobs.ts file to add your target job listings:

export const AvailableJobs: Job[] = [
  {
    job_title: "Frontend Developer",
    company_name: "Tech Company",
    job_url: "https://company.com/careers/frontend-developer"
  },
  // Add more jobs...
];

πŸ“Š Reports and Analytics

The system generates comprehensive reports after each run:

Report Location

  • Reports are saved in ./reports/ directory
  • Screenshots are saved in ./screenshots/ directory
  • Each report includes timestamp for easy tracking

Report Contents

  • Summary Statistics - Success rates, processing times, error counts
  • Detailed Job Results - Individual job processing outcomes
  • Error Analysis - Common failure patterns and recommendations
  • Visual Documentation - Screenshots of key moments and errors

Sample Report Structure

# Job Application Report

## Summary
- Total Jobs Processed: 50
- Successful Applications: 32
- Success Rate: 64%
- Total Processing Time: 1h 45m

## Detailed Results
[Table with individual job results]

## Recommendations
[AI-generated insights for improvement]

πŸ—οΈ Project Structure

job-applier-stagehand/
β”œβ”€β”€ agent/
β”‚   β”œβ”€β”€ applier/
β”‚   β”‚   β”œβ”€β”€ applier.ts          # Main automation logic
β”‚   β”‚   └── rules.ts            # AI prompts and rules
β”‚   └── types.ts                # TypeScript interfaces
β”œβ”€β”€ utils/
β”‚   β”œβ”€β”€ index.ts                # Personal information utilities
β”‚   └── reporter.ts             # Reporting system
β”œβ”€β”€ reports/                    # Generated reports
β”œβ”€β”€ screenshots/                # Debug screenshots
β”œβ”€β”€ jobs.ts                     # Job listings to process
β”œβ”€β”€ index.ts                    # Main entry point
└── README.md                   # This file

🎯 How It Works

1. Page Analysis

The system uses AI to analyze each page and determine:

  • Page type (job detail, application form, sign-in, etc.)
  • Required actions and form fields
  • Error conditions and recovery strategies

2. Intelligent Form Filling

  • Analyzes form fields contextually
  • Maps personal information to appropriate fields
  • Handles different field types (text, dropdowns, checkboxes)
  • Skips irrelevant or risky fields

3. Resume Upload

  • Multiple upload strategies with fallbacks
  • Intelligent file input detection
  • Error recovery and retry logic

4. Submission Process

  • Pre-submission validation
  • Form error detection and correction
  • Success verification with multiple indicators

5. Reporting

  • Real-time progress tracking
  • Comprehensive result documentation
  • Error pattern analysis
  • Performance metrics

πŸ” Testing and Demo

Test Results

The system has been tested on various job platforms including:

  • βœ… Company career pages
  • βœ… Job board applications
  • βœ… Multi-step application forms
  • βœ… File upload scenarios
  • βœ… Authentication flows

Demo Video

πŸ“Ή Watch Demo Video Link to Google Drive video demonstration

πŸ› οΈ Advanced Configuration

Custom Field Mappings

Extend the field mapping logic in applier.ts to handle specific form fields:

const fieldMappings = [
  {
    keywords: ['custom field', 'special input'],
    value: 'your custom value',
    label: 'Custom Field',
    instruction: 'Fill custom field with specific data'
  }
];

Custom Page Detection Rules

Add custom page detection rules in rules.ts:

export const customPageRules = `
  Analyze this page for custom scenarios:
  - Custom company application flow
  - Specific form requirements
  - Special authentication methods
`;

Adding New Page Types

  1. Update AI Rules: Modify extractJobDetailRules in rules.ts
  2. Add Handler: Create new case in handlePageType() switch statement
  3. Implement Logic: Add new handler method for the page type
private async handleCustomPageType(job: Job): Promise<void> {
  console.log('🎯 Handling custom page type');
  // Your custom logic here
}

Custom Form Fields

Extend the fillApplicationForm() method for specific form requirements:

private async fillCustomFields(job: Job): Promise<void> {
  await this.page.act(`Fill in the "Why do you want this job?" field with a compelling reason`);
  await this.page.act(`Select "Senior" from the experience level dropdown`);
  await this.page.act(`Check the "Remote work" checkbox if available`);
}

File Upload Extensions

The system supports resume uploads via RESUME_PATH. Extend for additional files:

private async uploadCoverLetter(): Promise<void> {
  const coverLetterPath = process.env.COVER_LETTER_PATH;
  if (coverLetterPath) {
    await this.page.act(`Upload "${coverLetterPath}" to the cover letter field`);
  }
}

private async uploadPortfolio(): Promise<void> {
  const portfolioPath = process.env.PORTFOLIO_PATH;
  if (portfolioPath) {
    await this.page.act(`Upload portfolio file from "${portfolioPath}"`);
  }
}

Environment Variables for Customization

Add custom environment variables to .env:

# Custom Configuration
CUSTOM_FIELD_VALUE=Your custom response
COVER_LETTER_PATH=/path/to/cover-letter.pdf
PORTFOLIO_PATH=/path/to/portfolio.pdf
APPLICATION_DELAY_MS=3000
MAX_RETRIES=3
ENABLE_SCREENSHOTS=true
ENABLE_VERBOSE_LOGGING=true

Debugging and Monitoring

Screenshot Configuration

The system automatically captures screenshots for:

// Screenshot naming convention
- `application_form_${companyName}.png` - Application forms
- `error_${companyName}_${timestamp}.png` - Error states
- `unknown_page_${companyName}.png` - Unrecognized pages
- `job_not_found_${companyName}.png` - Missing job listings
- `success_${companyName}.png` - Successful submissions

Detailed Logging

Enable comprehensive logging in your environment:

# Logging Configuration
LOG_LEVEL=debug
ENABLE_CONSOLE_LOGS=true
ENABLE_FILE_LOGS=true
LOG_DIRECTORY=./logs

Console log examples:

πŸ”„ Processing job: Frontend Developer at TechCorp
πŸ“ Navigating to: https://techcorp.com/careers/frontend-dev
πŸ” Page analysis: Application form detected
βœ… Form filled successfully
πŸ“€ Application submitted
⏱️  Processing time: 45 seconds

Browser Session Monitoring

Monitor live browser activity during automation:

# Browser session URL provided in console
Watch live: https://browserbase.com/sessions/[session-id]

Performance Monitoring

Track performance metrics:

interface PerformanceMetrics {
  totalJobs: number;
  successfulApplications: number;
  successRate: number;
  averageProcessingTime: number;
  errorRate: number;
  commonErrors: string[];
}

Error Handling Strategies

The system implements multiple error handling approaches:

1. Network Issues

// Automatic retries with exponential backoff
const retryDelays = [1000, 2000, 4000, 8000]; // milliseconds

2. Missing Elements

// Graceful fallback and detailed logging
try {
  await this.page.click('submit-button');
} catch (error) {
  console.log('❌ Submit button not found, trying alternative selectors');
  await this.tryAlternativeSubmission();
}

3. Authentication Failures

// Retry with manual intervention points
if (authFailed) {
  await this.page.screenshot({ path: 'auth_failure.png' });
  console.log('πŸ” Authentication failed - manual intervention may be required');
}

4. Form Validation Errors

// Pre-submission validation
const validationErrors = await this.validateForm();
if (validationErrors.length > 0) {
  console.log('⚠️ Form validation issues detected:', validationErrors);
  await this.fixValidationErrors(validationErrors);
}

Integration with External Systems

CRM Integration

// Example: Send results to CRM
async function updateCRM(applicationResult: ApplicationResult): Promise<void> {
  await fetch('https://your-crm.com/api/applications', {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify(applicationResult)
  });
}

Notification Systems

// Example: Slack notifications
async function sendSlackNotification(message: string): Promise<void> {
  await fetch(process.env.SLACK_WEBHOOK_URL!, {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({ text: message })
  });
}

Testing and Quality Assurance

Unit Testing

# Run specific tests
npm test -- --testNamePattern="form filling"
npm test -- --testNamePattern="file upload"
npm test -- --testNamePattern="error handling"

Integration Testing

describe('Job Application Flow', () => {
  it('should complete full application process', async () => {
    const result = await jobAgent.processJob(testJob);
    expect(result.success).toBe(true);
    expect(result.applicationSubmitted).toBe(true);
  });
});

End-to-End Testing

# Test with real job sites (be respectful of rate limits)
npm run test:e2e

🚨 Important Notes

Ethical Usage Guidelines

Respectful Automation

  • Rate Limiting: System includes appropriate delays between requests
  • Terms Compliance: Always review and comply with job site terms of service
  • Human Review: Review applications before final submission when possible
  • Quality Control: Ensure application quality and relevance

Best Practices

  • Targeted Applications: Apply only to relevant positions
  • Personal Touch: Customize applications when possible
  • Professional Conduct: Maintain professional standards in all interactions
  • Transparency: Be honest about your qualifications and experience

Technical Limitations

Known Constraints

  • JavaScript-Heavy Sites: Some dynamic sites may need manual intervention
  • CAPTCHA Challenges: Cannot automatically solve CAPTCHA verification
  • Complex Workflows: Multi-page flows may require customization
  • File Format Support: Optimized for common formats (PDF, DOC, DOCX)
  • Browser Detection: Some sites may detect automation

Workarounds

  • Manual Checkpoints: System allows for manual intervention points
  • Screenshot Analysis: Visual debugging helps identify issues
  • Fallback Strategies: Multiple approaches for critical operations
  • Error Recovery: Robust error handling with continuation options

Security Considerations

Data Protection

  • Environment Variables: All personal data stored in .env file
  • No Hardcoded Secrets: API keys and passwords secured properly
  • Local Storage: All data processing happens locally
  • Session Security: Browser sessions properly managed and cleaned

Privacy Measures

  • Minimal Data Retention: Reports and screenshots cleaned regularly
  • Secure Transmission: HTTPS for all external communications
  • Access Control: Secure API key management
  • Audit Trail: Comprehensive logging for security monitoring

Legal Considerations

Compliance Requirements

  • Website Terms: Respect robots.txt and terms of service
  • Data Privacy: Comply with GDPR, CCPA, and local privacy laws
  • Professional Ethics: Maintain honesty in applications
  • Rate Limits: Respect website rate limiting and anti-bot measures

Disclaimer

This tool is for educational and personal use. Users are responsible for:

  • Compliance with website terms of service
  • Accuracy of application information
  • Professional and ethical use of automation
  • Understanding local laws and regulations

Troubleshooting Common Issues

Setup Issues

# Node.js version conflicts
nvm use 18  # or latest LTS

# Dependency conflicts
rm -rf node_modules package-lock.json
npm install

# Environment variables
cp .env.example .env
# Then configure all required variables

Runtime Issues

  • Page Loading: Increase timeout values for slow sites
  • Form Detection: Check screenshot outputs for debugging
  • File Upload: Verify file paths and permissions
  • Authentication: Update credentials and check for 2FA requirements

Performance Optimization

  • Parallel Processing: Limit concurrent applications to avoid rate limiting
  • Memory Management: Monitor memory usage for long-running sessions
  • Error Recovery: Review error patterns in reports for optimization
  • Network Stability: Ensure stable internet connection for best results

πŸ“ž Support

Getting Help

Documentation Resources

  • Setup Guide: Complete installation and configuration instructions above
  • API Reference: Technical documentation in /docs/ directory
  • Examples: Sample configurations and use cases
  • FAQ: Common questions and solutions

Community Support

  • GitHub Issues: Report bugs and request features
  • GitHub Discussions: Ask questions and share experiences
  • Code Review: Submit PRs for community review
  • Best Practices: Share tips and optimization strategies

Professional Support

For enterprise use or complex customization needs:

  • Custom implementation services
  • Integration with existing systems
  • Compliance and security consulting
  • Training and onboarding

Contact Information

Response Times

  • Bug Reports: Within 48 hours
  • Feature Requests: Within 1 week
  • Security Issues: Within 24 hours
  • General Questions: Within 3-5 business days

πŸ™ Acknowledgments

Core Technologies

Inspiration and Community

  • Open source automation community
  • Job seekers sharing their challenges
  • Contributors and beta testers
  • Stagehand and Playwright communities

⚠️ Important Disclaimer: This tool is designed for educational and personal use to assist job seekers. Always respect website terms of service, maintain professional standards, and use responsibly. The authors are not responsible for any misuse of this software or violations of third-party terms of service.


Made with ❀️ for job seekers everywhere

🀝 Contributing

We welcome contributions! Please see our detailed contribution guidelines below.

Development Setup

  1. Fork and Clone

    git clone https://github.com/YOUR_USERNAME/job-applier-stagehand.git
    cd job-applier-stagehand
  2. Install Dependencies

    npm install
  3. Environment Setup

    cp .env.example .env
    # Configure your environment variables
  4. Development Commands

    # Development mode with auto-reload
    npm run dev
    
    # Production build
    npm run build
    
    # Run tests
    npm test
    
    # Type checking
    npm run type-check

Code Style Guidelines

// Good: Clear interfaces and error handling
interface JobApplication {
  company: string;
  position: string;
  status: ApplicationStatus;
}

async function fillJobForm(page: Page, jobData: JobApplication): Promise<boolean> {
  try {
    // Implementation with proper error handling
    return true;
  } catch (error) {
    logger.error('Form filling failed:', error);
    return false;
  }
}

Testing Guidelines

  • Unit tests for utility functions
  • Integration tests for automation flows
  • End-to-end tests for complete workflows

Pull Request Process

  1. Before Submitting

    • Ensure all tests pass
    • Update documentation if needed
    • Follow code style guidelines
    • Write descriptive commit messages
  2. PR Requirements

    • Clear description of changes
    • Type of change (bug fix, feature, docs, etc.)
    • Testing completed
    • Documentation updated

Areas for Contribution

  • Job Site Support: Add support for new job platforms
  • Form Analysis: Improve AI-powered form detection
  • Error Handling: Enhance error recovery mechanisms
  • Reporting: Add new report formats or analytics
  • Testing: Improve test coverage
  • Documentation: Enhance docs and examples

πŸ”’ Security Policy

Reporting Vulnerabilities

Please do not report security vulnerabilities through public GitHub issues.

For security issues, please email: [security@yourproject.com]

Include:

  • Type of issue
  • Location of affected source code
  • Step-by-step reproduction instructions
  • Potential impact assessment

Security Best Practices

For Users

  1. Environment Security

    # Use strong, unique API keys
    GOOGLE_AI_API_KEY=your_secure_api_key_here
    
    # Never commit .env files
    echo ".env" >> .gitignore
  2. System Security

    • Keep Node.js and dependencies updated
    • Use dedicated user account for automation
    • Run in isolated containers when possible

For Developers

  1. Dependency Management

    # Regular security audits
    npm audit
    npm audit fix
    
    # Keep dependencies updated
    npm update
  2. Input Validation

    function validateJobData(data: unknown): JobData {
      if (!isValidJobData(data)) {
        throw new ValidationError('Invalid job data');
      }
      return data;
    }

Security Considerations

Browser Automation Risks

  • Fingerprinting: Automated browsers can be detected
  • Rate limiting: Excessive requests may trigger anti-bot measures
  • Account security: Using saved credentials poses risks
  • Session persistence: Browser sessions should be properly cleaned

Mitigation Strategies

  • Human-like behavior: Realistic delays and interactions
  • Session management: Fresh sessions for each application
  • Credential rotation: Regular credential updates
  • Monitoring: Comprehensive logging and alerting

Data Handling Security

  • Personal Information: Handle personal data with care and minimal retention
  • File Uploads: Validate file types and sizes before processing
  • Logging: Avoid logging sensitive information in plain text
  • Storage: Use secure storage and encryption for sensitive data

Compliance

This project aims to comply with:

  • GDPR: European data protection regulations
  • CCPA: California Consumer Privacy Act
  • Industry Standards: OWASP security guidelines

πŸ“ License

This project is licensed under the MIT License.

MIT License

Copyright (c) 2024 Job Application Automation Contributors

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

Third-Party Licenses

  • Stagehand: MIT License (BrowserBase Inc.)
  • Google Generative AI: Apache 2.0 (Google LLC)
  • See package.json for complete dependency list

License Notes

  1. Commercial Use: This software can be used commercially under MIT terms
  2. Attribution: Attribution appreciated for commercial use
  3. Liability: Software provided "as is" without warranty
  4. API Compliance: Users responsible for third-party service compliance

πŸ™ Acknowledgments

Core Technologies

Inspiration and Community

  • Open source automation community
  • Job seekers sharing their challenges
  • Contributors and beta testers
  • Stagehand and Playwright communities

πŸ“‹ Changelog

[1.0.0] - 2024-01-XX

Added

  • Initial release of Job Application Automation system
  • Stagehand browser automation integration with Google Gemini AI
  • Intelligent form detection and filling capabilities
  • Multi-strategy file upload system with 6 fallback approaches
  • Comprehensive error handling and recovery mechanisms
  • Detailed markdown report generation with analytics
  • Support for multiple job sites and international platforms
  • Environment-based configuration for security
  • TypeScript implementation with full type safety
  • Professional documentation suite

Features

  • AI-Powered Analysis: Uses Google Gemini 2.5-flash for page analysis
  • Smart Form Filling: Intelligent field detection and data mapping
  • Robust File Upload: Multiple strategies for resume/cover letter uploads
  • Error Recovery: Comprehensive error handling with retry mechanisms
  • Progress Tracking: Real-time progress updates and statistics
  • Report Generation: Detailed markdown reports with analytics
  • Multi-Site Support: Works across various job platforms
  • Security First: Environment-based personal information management

Technical Implementation

  • TypeScript for type safety and better development experience
  • Stagehand framework for browser automation
  • Google Gemini AI for intelligent page interaction
  • Comprehensive logging and debugging capabilities
  • Modular architecture for easy extension
  • Professional error handling and validation

About

An intelligent, AI-powered job application automation system. This system can automatically navigate job sites, fill application forms, upload resumes, and submit applications with comprehensive reporting and analytics.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published