The UK Travel Recommendation project ships with aDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/viet2811/uk-travel-recommendation/llms.txt
Use this file to discover all available pages before exploring further.
docker-compose.yaml that orchestrates two services: the Django REST API backend and a pgvector-enabled PostgreSQL database. Using Docker Compose means you don’t need to install Python, PostgreSQL, or any system dependencies on your host machine — everything runs inside containers with a single command. This page walks you through every step needed to get the full backend stack running locally, from cloning the repository to verifying a live API response.
Prerequisites
Before you begin, make sure the following tools are installed on your machine:Docker Desktop
Installs the Docker Engine, the Compose plugin, and a graphical dashboard. Available for macOS, Windows, and Linux at docs.docker.com/get-docker.
Git
Required to clone the repository. Download from git-scm.com or install via your OS package manager.
If you are on Linux and prefer not to install Docker Desktop, install the Docker Engine and the Compose plugin (
docker-compose-plugin) separately via your distribution’s package manager.Services
Thedocker-compose.yaml defines two services that work together to run the backend stack. Understanding what each service does helps you diagnose issues and customise the setup for your own environment.
backend
Image: Built from
./backend/DockerfileContainer name: backend_csprojRuns the Django REST API with python manage.py runserver on port 8000. The ./backend directory is mounted as a volume so code changes are reflected without rebuilding the image. Reads all secrets from ./backend/.env.db
Image:
pgvector/pgvector:pg15-bookwormContainer name: postgres_vectorA PostgreSQL 15 instance with the pgvector extension pre-installed. Exposes port 5432 and persists data in the named volume postgres_data. Database credentials are injected via the same backend/.env file.Starting the Stack
Create the backend environment file
The Docker Compose stack reads secrets from See the Environment Variables page for a full reference of every required variable and an example
backend/.env. Create this file before starting the services — without it, both the backend and database containers will fail to start correctly..env file you can copy directly.Build and start all services
Run the following command from the project root (the directory that contains The
docker-compose.yaml):--build flag forces Docker to (re)build the backend image from ./backend/Dockerfile. Subsequent starts that don’t involve code changes can omit this flag for a faster startup.Wait for both services to be healthy
Watch the terminal output. You should see log lines from both containers. The stack is ready when you see Django’s development server banner similar to:PostgreSQL is usually ready a few seconds before Django finishes starting. If the backend exits with a database connection error on the very first run, see the troubleshooting section below.
Running Migrations
After the stack is up for the first time you must apply Django’s database migrations. Open a new terminal window and run:| Migration | What it does |
|---|---|
recommendations/0001_enable_vector_extension | Runs CREATE EXTENSION IF NOT EXISTS vector inside PostgreSQL, activating pgvector |
recommendations/0002_initial | Creates the Attraction table with a vector column for embeddings |
users/0001_initial | Creates the UserProfile, UserInteraction, and UserRecommendationBatch tables |
Migration
0001_enable_vector_extension must succeed before 0002_initial can create the Attraction table. Both will run automatically in the correct order when you run migrate. If you are connecting to an external PostgreSQL instance, make sure the database user has SUPERUSER or CREATE EXTENSION privileges.Verify the API Is Running
With migrations applied, confirm the API is responding correctly:POST requests.
Stopping the Stack
- Stop (keep data)
- Stop and wipe data
Stop and remove the containers while preserving the
postgres_data named volume. Your database state is retained and will be available on the next docker compose up.Production Warning
Troubleshooting
pgvector extension not found
pgvector extension not found
Symptom: Migration
0001_enable_vector_extension fails with an error like could not open extension control file ... vector.control.Cause: You are using a plain postgres image that does not have the pgvector shared library installed.Fix: Make sure the db service in docker-compose.yaml uses the image pgvector/pgvector:pg15-bookworm exactly as specified. Do not substitute postgres:15 or any other plain PostgreSQL image. If you previously started the stack with the wrong image, run docker compose down -v to remove the old volume and then restart.backend cannot connect to db (connection refused)
backend cannot connect to db (connection refused)
Symptom: The backend container exits immediately on first start with
django.db.utils.OperationalError: could not connect to server.Cause: Docker Compose’s depends_on directive only waits for the db container to start, not for the PostgreSQL process inside it to finish initialising and accept connections. On slower machines PostgreSQL may still be running its initial setup when Django tries to connect.Fix: Re-run docker compose up — PostgreSQL is already initialised from the first attempt and will be ready much faster. For a permanent fix, add a health check to the db service and update depends_on to wait for service_healthy:Port 5432 is already in use
Port 5432 is already in use
Symptom: Docker Compose fails with Fix (option 2): Change the host port mapping in Remember to update any database connection strings or tooling that references port
bind: address already in use on port 5432.Cause: A PostgreSQL instance is already running on your host machine and listening on port 5432.Fix (option 1): Stop your local PostgreSQL service:docker-compose.yaml so the containerised database listens on a different host port (the container-internal port stays 5432):5432 on the host if you make this change.