Spaces:
Sleeping
Sleeping
| """ | |
| ResumeIQ - AI Resume Analyzer | |
| Main application entry point | |
| """ | |
| import streamlit as st | |
| import os | |
| from dotenv import load_dotenv | |
| # Import modular components | |
| from ui.session_state import initialize_session_state | |
| from ui.file_upload import render_file_upload | |
| from ui.job_description import render_job_description_input | |
| from ui.results_display import display_results | |
| from ui.interview_scheduling import display_scheduled_interviews | |
| from core.analyzer import analyze_resumes | |
| from db.database import ResumeMatchDB | |
| # Load environment variables | |
| load_dotenv() | |
| # Page configuration | |
| st.set_page_config(page_title="AI Resume Analyzer", page_icon="π", layout="wide") | |
| st.title("π AI Resume Analyzer") | |
| # Initialize session state | |
| initialize_session_state() | |
| # LLM Configuration | |
| DEEPSEEK_API_KEY = os.getenv("DEEPSEEK_API_KEY") | |
| DEEPSEEK_MODEL = os.getenv("DEEPSEEK_MODEL", "deepseek-chat") | |
| DEEPSEEK_BASE_URL = os.getenv("DEEPSEEK_BASE_URL", "https://api.deepseek.com") | |
| if not DEEPSEEK_API_KEY: | |
| st.warning("β οΈ DEEPSEEK_API_KEY not configured. Please set it in Hugging Face Space Settings β Repository secrets.") | |
| st.info("π‘ Add `DEEPSEEK_API_KEY` as a secret in your Space settings to enable AI analysis.") | |
| # Don't stop - let the UI load so users can see the interface | |
| # Initialize database connection | |
| try: | |
| db = ResumeMatchDB() | |
| except Exception as e: | |
| st.error(f"β Database Connection Error: {str(e)}") | |
| db = None | |
| # File Upload Section | |
| uploaded_files = render_file_upload() | |
| # Job Description Section | |
| job_descriptions = render_job_description_input() | |
| # Analysis Status | |
| if uploaded_files or job_descriptions: | |
| with st.expander("π Ready to Analyze", expanded=False): | |
| st.write(f"**Resumes loaded:** {len(uploaded_files) if uploaded_files else 0}") | |
| st.write(f"**Job descriptions:** {len(job_descriptions) if job_descriptions else 0}") | |
| if job_descriptions: | |
| for idx, jd in enumerate(job_descriptions): | |
| st.write(f" - {jd['title']} ({len(jd['content'])} characters)") | |
| # Analyze Button | |
| if uploaded_files and job_descriptions: | |
| if st.button("π Analyze Resumes"): | |
| analyze_resumes( | |
| uploaded_files, | |
| job_descriptions, | |
| DEEPSEEK_API_KEY, | |
| DEEPSEEK_MODEL, | |
| DEEPSEEK_BASE_URL | |
| ) | |
| elif uploaded_files and not job_descriptions: | |
| st.warning("β οΈ Please enter or upload a job description before analyzing resumes.") | |
| elif not uploaded_files and job_descriptions: | |
| st.warning("β οΈ Please upload resumes before analyzing.") | |
| # Display Content in Tabs | |
| st.divider() | |
| if st.session_state.results: | |
| tab1, tab2 = st.tabs(["π Analysis Results", "π Upcoming Interviews"]) | |
| with tab1: | |
| display_results() | |
| with tab2: | |
| display_scheduled_interviews() | |
| else: | |
| # If no results yet, just show upcoming interviews | |
| display_scheduled_interviews() | |