Skip to content

Commit 545d572

Browse files
committed
Production Deployment (Phase 3)
1 parent 2caefda commit 545d572

File tree

12 files changed

+228
-102
lines changed

12 files changed

+228
-102
lines changed

backend/app/__init__.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import os
77
from importlib import import_module
88

9-
import google.generativeai as genai
109
from dotenv import load_dotenv
1110
from flask import Flask
1211
from flask_cors import CORS
@@ -24,15 +23,15 @@ def create_app() -> Flask:
2423

2524
# Initialize Flask app
2625
app = Flask(__name__)
27-
26+
2827
# Configure CORS - allow all origins in development and specific origins in production
2928
is_production = os.getenv("FLASK_ENV") == "production"
30-
29+
3130
if is_production:
3231
# In production, allow specific origins
3332
allowed_origins = [
34-
"https://hxndev.github.io", # GitHub Pages domain
35-
"http://localhost:5173" # Local dev frontend (for testing)
33+
"https://hxndev.github.io", # GitHub Pages domain
34+
"http://localhost:5173", # Local dev frontend (for testing)
3635
]
3736
CORS(app, resources={r"/api/*": {"origins": allowed_origins}}, supports_credentials=True)
3837
else:
@@ -44,4 +43,4 @@ def create_app() -> Flask:
4443
routes = import_module(".routes", package="app")
4544
app.register_blueprint(routes.api_bp)
4645

47-
return app
46+
return app

backend/app/main.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@
33
This module initializes and runs the Flask server.
44
"""
55

6-
import os
76
import logging
7+
import os
88

99
from . import create_app
1010

1111

1212
# Configure logging
1313
logging.basicConfig(
1414
level=logging.INFO,
15-
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
15+
format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
1616
)
1717

1818
logger = logging.getLogger(__name__)
@@ -24,15 +24,15 @@
2424
# Get environment variables
2525
flask_env = os.getenv("FLASK_ENV", "development")
2626
port = int(os.getenv("PORT", "5050"))
27-
27+
2828
# Only enable debug mode in development
2929
debug_mode = flask_env == "development"
30-
30+
3131
logger.info(f"Starting JobFit API in {flask_env} mode on port {port}")
32-
32+
3333
# Run the application
3434
app.run(
3535
debug=debug_mode,
3636
host="0.0.0.0", # Listen on all interfaces
37-
port=port
38-
)
37+
port=port,
38+
)

backend/app/resume_analyzer.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -45,30 +45,30 @@ def extract_text_from_pdf(file_bytes: BinaryIO) -> str:
4545

4646
# Use context manager for better resource management
4747
text = ""
48-
48+
4949
# Open PDF reader with the buffer
5050
pdf = PdfReader(pdf_buffer)
51-
51+
5252
# Process pages one by one to reduce memory usage
5353
for page in pdf.pages:
5454
# Extract text from the page and append to result
5555
page_text = page.extract_text()
5656
if page_text:
5757
text += page_text + "\n"
58-
58+
5959
# Close the buffer explicitly
6060
pdf_buffer.close()
61-
61+
6262
# Force garbage collection to free up memory
6363
gc.collect()
64-
64+
6565
# Truncate very long resume content to prevent token limits
6666
if len(text) > MAX_RESUME_CONTENT_LENGTH:
6767
logger.info(f"Truncating resume content from {len(text)} to {MAX_RESUME_CONTENT_LENGTH} chars")
6868
text = text[:MAX_RESUME_CONTENT_LENGTH] + "..."
69-
69+
7070
return text
71-
71+
7272
except Exception as e:
7373
logger.error(f"Error reading PDF: {str(e)}", exc_info=True)
7474
# Clean up resources on error
@@ -363,14 +363,14 @@ def generate_resume_review(resume_content: str, job_description: str, custom_ins
363363
prompt_resume = resume_content[:MAX_RESUME_CONTENT_LENGTH] + "..."
364364
else:
365365
prompt_resume = resume_content
366-
366+
367367
# Truncate job description if it's very long
368368
if len(job_description) > MAX_JOB_DESCRIPTION_LENGTH:
369369
logger.info(f"Truncating job description for review from {len(job_description)} to {MAX_JOB_DESCRIPTION_LENGTH} chars")
370370
prompt_job = job_description[:MAX_JOB_DESCRIPTION_LENGTH] + "..."
371371
else:
372372
prompt_job = job_description
373-
373+
374374
base_prompt = f"""
375375
You are a professional resume reviewer and career coach. Review this resume against the job description
376376
and provide detailed, actionable feedback to help improve the resume.
@@ -483,7 +483,7 @@ def generate_resume_review(resume_content: str, job_description: str, custom_ins
483483
except json.JSONDecodeError as e:
484484
# Clean up memory on error
485485
gc.collect()
486-
486+
487487
return {
488488
"success": False,
489489
"error": f"Invalid response format from AI model: {str(e)}",
@@ -495,4 +495,4 @@ def generate_resume_review(resume_content: str, job_description: str, custom_ins
495495
except Exception as e:
496496
# Clean up memory on error
497497
gc.collect()
498-
return {"success": False, "error": f"Error generating resume review: {str(e)}"}
498+
return {"success": False, "error": f"Error generating resume review: {str(e)}"}

0 commit comments

Comments
 (0)