Production Deployment
Relevant source files
The following files were used as context for generating this wiki page:
This document outlines the architecture and procedures for deploying the Resume Matcher application in a production environment. The project supports two primary deployment methods: a containerized approach using Docker Compose, which is recommended, and a manual setup for running production builds directly on a host.
The deployment consists of two main services: a Next.js frontend and a Python FastAPI backend. Proper configuration of environment variables, especially for Cross-Origin Resource Sharing (CORS) and inter-service communication, is critical for a functional deployment. For detailed setup instructions, refer to SETUP.md.
Sources: SETUP.md, INSTALL.md
Architecture Overview
The application follows a classic client-server architecture. The frontend is a single-page application (SPA) built with Next.js, and the backend is a RESTful API built with FastAPI. The backend handles all business logic, including AI processing, resume parsing, and data storage using TinyDB (a JSON file-based database).
This diagram illustrates the high-level interaction between components.
Sources: SETUP.md:209-232, INSTALL.md:104-114
Docker Deployment (Recommended)
The recommended method for production is using Docker Compose, which orchestrates the frontend and backend services in isolated containers. This approach simplifies dependency management and ensures a consistent environment.
Sources: SETUP.md:104-118
Services
The docker-compose.yml file defines two main services: backend and frontend.
| Service | Image Source | Exposed Port (Host) | Container Port | Description |
|---|---|---|---|---|
backend | Dockerfile in apps/backend | 8000 | 8000 | The FastAPI application server. |
frontend | Dockerfile in apps/frontend | 3000 | 3000 | The Next.js application server. |
A Docker volume named db_data is used to persist the TinyDB database files from the backend container, ensuring data is not lost when containers are restarted.
Sources: docker-compose.yml:1-25
The following diagram shows the Docker service architecture.
Sources: docker-compose.yml
Commands
The following commands are used to manage the Docker deployment.
# Build and start the containers in detached mode
docker-compose up -d
# View logs for all services
docker-compose logs -f
# Stop and remove the containers
docker-compose down
Note: When using Docker, API keys are configured through the UI at http://localhost:3000/settings, not through .env files.
Sources: SETUP.md:108-114
Manual Production Deployment
For environments without Docker, the frontend and backend can be built and run manually.
Backend
The backend is a FastAPI application run with a production-grade ASGI server like Uvicorn.
- Install dependencies:
cd apps/backend uv sync - Start the production server:
uv run uvicorn app.main:app --host 0.0.0.0 --port 8000
Sources: INSTALL.md:175-178, SETUP.md:141-142
Frontend
The frontend is a Next.js application that needs to be built before serving.
- Install dependencies:
cd apps/frontend npm install - Build for production:
npm run build - Start the production server:
npm run start
Sources: INSTALL.md:183-185, SETUP.md:160-163
Configuration
Backend Environment Variables
The backend requires an .env file in the apps/backend directory. Key variables for production include:
| Variable | Example Value | Description |
|---|---|---|
LLM_PROVIDER | openai | The selected AI provider (e.g., openai, ollama). |
LLM_MODEL | gpt-4o-mini | The specific model to use. |
LLM_API_KEY | sk-your-key | API key for the selected cloud provider. |
FRONTEND_BASE_URL | http://localhost:3000 | The public URL of the frontend. Crucial for PDF generation. |
CORS_ORIGINS | ["https://your-domain.com"] | A list of allowed origins for API requests. Must include the frontend URL. |
Sources: INSTALL.md:55-70
Frontend Environment Variables
The frontend can be configured via an .env.local file in the apps/frontend directory.
NEXT_PUBLIC_API_URL: The public URL of the backend API (e.g.,http://localhost:8000). This is only needed if the backend is not running on the default URL.
Sources: INSTALL.md:98-102
CORS Configuration
The backend uses FastAPI's CORSMiddleware to control which domains can access the API. This is a critical security feature and must be configured correctly for the frontend to function.
The CORS_ORIGINS environment variable in the backend's .env file must contain the URL of the deployed frontend.
# apps/backend/app/main.py
app.add_middleware(
CORSMiddleware,
allow_origins=settings.CORS_ORIGINS,
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
Sources: apps/backend/app/main.py:33-40, INSTALL.md:189-193
The following sequence diagram shows how a request from the frontend is validated by the CORS middleware.
Sources: apps/backend/app/main.py:33-40
Summary
Deploying Resume Matcher for production involves running the frontend and backend services and ensuring they can communicate. The recommended approach is using the provided docker-compose.yml file, which handles the setup automatically. For manual deployments, it is essential to build both applications for production and configure environment variables correctly, paying close attention to FRONTEND_BASE_URL and CORS_ORIGINS to enable PDF generation and prevent cross-origin errors.
Sources: README.md:144-147, INSTALL.md:173-193