Prerequisites
Python Version
GOV.UK Notify API runs on Python 3.13 both locally and in production.Required Services
- PostgreSQL 15 - Database server
- Redis - Caching and message broker (optional but recommended)
- AWS credentials - For local development access
System Dependencies
PostgreSQL
If using notifications-local, PostgreSQL is provided automatically via Docker Compose. For manual setup:- Install Postgres.app on macOS
- Use PostgreSQL 15 (check the docker-compose file for the exact version)
Redis
On macOS using Homebrew:psycopg2 on Apple M1/M2
On Mac M1/M2 machines, follow these special instructions to install psycopg2.Installation
1. Install uv
We use uv for Python dependency management:2. Install pre-commit
We use pre-commit to ensure code quality and consistent formatting:- Trailing whitespace removal
- End-of-file fixing
- YAML validation
- Debug statement detection
- Ruff linting and formatting
3. Configure AWS Credentials
See the Notify Wiki for AWS setup details.4. Create environment.sh
Create anenvironment.sh file in the project root:
- Replace
YOUR_OWN_PREFIXwithlocal_dev_<your_first_name> - Get API keys from the credentials repo:
5. Bootstrap the Application
Run the bootstrap command to install dependencies and set up the database:- Install Python dependencies from
requirements_for_test.txtusing uv - Create the
notification_apidatabase - Run database migrations
- Generate the app version file
Running the Application
Standard Method
Run these commands in separate terminal windows:Docker Method (Alternative)
If you have issues with pycurl (a Celery dependency), you can run Celery via Docker:Database Migrations
Database migrations are managed using Alembic via Flask-Migrate:Flask Commands
The application includes custom Flask commands for various tasks:Dependency Management
Installing Dependencies
Dependencies are managed through.in files and compiled to .txt files:
- Compiles
requirements.intorequirements.txt - Syncs the virtual environment
- Compiles
requirements_for_test.intorequirements_for_test.txt - Syncs test requirements