Backend service for Active10 applications
- Python 3.10+
- pip (Python package installer)
- Docker (optional for Docker setup)
You can run the project in two ways:
If you'd prefer to run the project using Docker, follow these steps:
-
Set the environment variables:
Create a
.envfile in the root directory and add the following variables:NHS_LOGIN_AUTHORITY_URL= NHS_LOGIN_CLIENT_ID= NHS_LOGIN_SCOPES= NHS_LOGIN_CALLBACK_URL= NHS_API_URL= NHS_API_KEY= AUTH_JWT_SECRET= APP_URI= DB_HOST= DB_PORT= DB_USER= DB_PASS= DB_NAME= AWS_SQS_QUEUE_URL= AWS_SQS_ACTIVITIES_MIGRATIONS_QUEUE_URL= GOJAUNTLY_KEY_ID= GOJAUNTLY_PRIVATE_KEY= GOJAUNTLY_ISSUER_ID= NHS_PDS_JWT_PRIVATE_KEY= # Local only AWS_REGION= AWS_ACCESS_KEY_ID= AWS_SECRET_ACCESS_KEY= REDIS_HOST= REDIS_PORT= # Update the environment variables with your values.
-
Run the application using Docker Compose:
docker-compose up --build
-
Access the application:
The app will be available at
http://localhost:8000. If you're using HTTPS, it will be accessible athttps://localhost:8000.
The docker-compose.yaml file defines two services:
- app: The FastAPI backend service.
- db: A PostgreSQL 13 database service.
The app service depends on the PostgreSQL database and runs using environment variables specified in the .env file. The app is accessible via port 8000, and the database is available on port 5432.
-
Create and activate a virtual environment:
python3 -m venv venv
source venv/bin/activateOn Windows use
venv\Scripts\activate
-
Install the dependencies:
pip install -r requirements.txt
-
Set the environment variables:
Create a
.envfile in the root directory and add the following variables:NHS_LOGIN_AUTHORITY_URL= NHS_LOGIN_CLIENT_ID= NHS_LOGIN_SCOPES= NHS_LOGIN_CALLBACK_URL= NHS_API_URL= NHS_API_KEY= AUTH_JWT_SECRET= APP_URI= DB_HOST= DB_PORT= DB_USER= DB_PASS= DB_NAME= AWS_SQS_QUEUE_URL= AWS_SQS_ACTIVITIES_MIGRATIONS_QUEUE_URL= GOJAUNTLY_KEY_ID= GOJAUNTLY_PRIVATE_KEY= GOJAUNTLY_ISSUER_ID= NHS_PDS_JWT_PRIVATE_KEY= # Local only AWS_REGION= AWS_ACCESS_KEY_ID= AWS_SECRET_ACCESS_KEY= REDIS_HOST= REDIS_PORT= # Update the environment variables with your values. # For Integration Test TEST_NHS_LOGIN_API= TEST_NHS_EMAIL= TEST_NHS_PASSWORD= TEST_NHS_OTP=
-
Run the database migrations:
alembic upgrade head
-
Start the FastAPI application:
uvicorn main:app --host 0.0.0.0 --port 8000 --ssl-certfile cert/cert.pem --ssl-keyfile cert/key.pem
The above is applicable only when running in a local development environment.
-
Access the application:
Open your browser and navigate to https://localhost:8000.
- Install test dependencies:
pip install -r requirements.txt
- Start the FastAPI application:
uvicorn main:app --host 0.0.0.0 --port 8000 --ssl-certfile cert/cert.pem --ssl-keyfile cert/key.pem
- Run the tests:
pytest --headless --wire
Please read the CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.
This project is licensed under the MIT License. See the LICENSE file for details.