|
| 1 | +import streamlit as st |
| 2 | +import asyncio |
| 3 | +from dotenv import load_dotenv |
| 4 | +from src.scraper import JobScraper |
| 5 | +from src.matcher import JobMatcher |
| 6 | +from src.discord import DiscordNotifier |
| 7 | +from src.database import Database |
| 8 | + |
| 9 | +load_dotenv() |
| 10 | + |
| 11 | + |
| 12 | +async def process_job(scraper, matcher, notifier, job, resume_content): |
| 13 | + """Process a single job posting""" |
| 14 | + job_content = await scraper.scrape_job_content(job.url) |
| 15 | + result = await matcher.evaluate_match(resume_content, job_content) |
| 16 | + |
| 17 | + if result["is_match"]: |
| 18 | + await notifier.send_match(job, result["reason"]) |
| 19 | + |
| 20 | + return job, result |
| 21 | + |
| 22 | + |
| 23 | +async def main(): |
| 24 | + """Main function to run the resume parser application.""" |
| 25 | + st.title("Resume Parser and Job Matcher") |
| 26 | + |
| 27 | + # Initialize services |
| 28 | + scraper = JobScraper() |
| 29 | + matcher = JobMatcher() |
| 30 | + notifier = DiscordNotifier() |
| 31 | + db = Database() |
| 32 | + |
| 33 | + # Sidebar for managing job sources |
| 34 | + with st.sidebar: |
| 35 | + st.header("Manage Job Sources") |
| 36 | + |
| 37 | + # Add new job source |
| 38 | + new_source = st.text_input( |
| 39 | + "Add Job Source URL", placeholder="https://www.company.com/jobs" |
| 40 | + ) |
| 41 | + |
| 42 | + if st.button("Add Source"): |
| 43 | + db.save_job_source(new_source) |
| 44 | + st.success("Job source added!") |
| 45 | + |
| 46 | + # List and delete existing sources |
| 47 | + st.subheader("Current Sources") |
| 48 | + for source in db.get_job_sources(): |
| 49 | + col1, col2 = st.columns([3, 1]) |
| 50 | + with col1: |
| 51 | + st.text(source.url) |
| 52 | + with col2: |
| 53 | + if st.button("Delete", key=source.url): |
| 54 | + db.delete_job_source(source.url) |
| 55 | + st.rerun() |
| 56 | + |
| 57 | + # Main content |
| 58 | + st.markdown( |
| 59 | + """ |
| 60 | + This app helps you find matching jobs by: |
| 61 | + - Analyzing your resume from a PDF URL |
| 62 | + - Scraping job postings from your saved job sources |
| 63 | + - Using AI to evaluate if you're a good fit for each position |
| 64 | + |
| 65 | + Simply paste your resume URL below to get started! |
| 66 | + """ |
| 67 | + ) |
| 68 | + |
| 69 | + # Resume PDF URL input |
| 70 | + resume_url = st.text_input( |
| 71 | + "**Enter Resume PDF URL**", |
| 72 | + placeholder="https://www.website.com/resume.pdf", |
| 73 | + ) |
| 74 | + |
| 75 | + if st.button("Analyze") and resume_url: |
| 76 | + with st.spinner("Parsing resume..."): |
| 77 | + resume_content = await scraper.parse_resume(resume_url) |
| 78 | + |
| 79 | + # Get job sources from database |
| 80 | + sources = db.get_job_sources() |
| 81 | + if not sources: |
| 82 | + st.warning("No job sources configured. Add some in the sidebar!") |
| 83 | + return |
| 84 | + |
| 85 | + with st.spinner("Scraping job postings..."): |
| 86 | + jobs = await scraper.scrape_job_postings([s.url for s in sources]) |
| 87 | + |
| 88 | + if not jobs: |
| 89 | + st.warning("No jobs found in the configured sources.") |
| 90 | + return |
| 91 | + |
| 92 | + with st.spinner(f"Analyzing {len(jobs)} jobs..."): |
| 93 | + tasks = [] |
| 94 | + for job in jobs: |
| 95 | + task = process_job(scraper, matcher, notifier, job, resume_content) |
| 96 | + tasks.append(task) |
| 97 | + |
| 98 | + for coro in asyncio.as_completed(tasks): |
| 99 | + job, result = await coro |
| 100 | + st.subheader(f"Job: {job.title}") |
| 101 | + st.write(f"URL: {job.url}") |
| 102 | + st.write(f"Match: {'✅' if result['is_match'] else '❌'}") |
| 103 | + st.write(f"Reason: {result['reason']}") |
| 104 | + st.divider() |
| 105 | + |
| 106 | + st.success(f"Analysis complete! Processed {len(jobs)} jobs.") |
| 107 | + |
| 108 | + |
| 109 | +if __name__ == "__main__": |
| 110 | + asyncio.run(main()) |
0 commit comments