Skip to content

Copy of README.md from smart_apply_backend

Generated from smart_apply_backend/README.md at commit e15126d9. Edit the source file, not this copy.

Smart Apply Backend

Explore in graph

FastAPI backend service for job application tracking, using MongoDB as the data store and JWT-based authentication.

Tech stack

  • FastAPI
  • MongoDB (Motor async driver)
  • JWT auth with python-jose

Running locally

  1. Install uv, then install dependencies for your platform. uv sync creates .venv (Python from .python-version) and installs the locked versions from uv.lock, including the dev group (pytest).

Intel Mac (local dev, no ML):

uv sync

Set RESUME_MATCHING_ENABLED=false in .env. Resume selection falls back to preferred title or the first resume.

Apple Silicon Mac, or Linux with NVIDIA GPU (production / CUDA):

uv sync --extra ml

The ml extra adds PyTorch and the embedding libraries (CUDA build on Linux, CPU/MPS on Apple Silicon).

  1. Run commands inside the venv with uv run ..., or source .venv/bin/activate. To add or upgrade a dependency, use uv add <pkg> / uv lock --upgrade-package <pkg> and commit both pyproject.toml and uv.lock.

  2. Download the MiniLM model (skip if RESUME_MATCHING_ENABLED=false; the spaCy en_core_web_lg model is already installed by uv sync):

uv run hf download sentence-transformers/all-MiniLM-L6-v2 --local-dir app/models/all-MiniLM-L6-v2
  1. Export environment variables (or create a .env file in backend):

  2. MONGODB_URI (optional, defaults to mongodb://localhost:27017)

  3. MONGODB_DB (optional, defaults to smart_apply)
  4. JWT_SECRET_KEY (required, any strong random string)
  5. JWT_ALGORITHM (optional, defaults to HS256)
  6. ACCESS_TOKEN_EXPIRE_MINUTES (optional, defaults to 60)
  7. RESUME_MATCHING_ENABLED (optional, defaults to true; set to false on Intel Mac local dev)

  8. Start the API server from the project root:

uv run uvicorn app.main:app --reload --host 0.0.0.0

The API will be available at http://localhost:8000. Interactive docs are at http://localhost:8000/docs.

MONGODB_URI=
MONGODB_DB=
JWT_SECRET_KEY=
JWT_ALGORITHM=
ACCESS_TOKEN_EXPIRE_MINUTES=
OPENAI_API_KEY=

# TIGRIS Credentials (for S3)
TIGRIS_ACCESS_KEY_ID=
TIGRIS_SECRET_ACCESS_KEY=
TIGRIS_DEFAULT_REGION=
TIGRIS_S3_BUCKET_NAME=
TIGRIS_S3_ENDPOINT_URL=

Running tests

Unit tests live in tests/ and run with pytest. They never touch a real MongoDB, OpenAI or Tigris: tests/conftest.py sets safe environment variables before the app is imported, and the database is replaced by a fake.

uv sync
uv run pytest               # run the suite
uv run pytest --cov=app     # with coverage

CI

.github/workflows/ci.yml runs on every push to master / feature/** and on pull requests to master. It installs the locked dependencies with uv (skipping the large spaCy model, which the tests don't need), checks that app.main imports, and runs the test suite with coverage on Python 3.11 and 3.12. JUnit and coverage XML reports are uploaded as build artifacts.