Skip to content

AustralianBioCommons/aai-backend

Repository files navigation

AAI Backend

The backend library between Auth0 and the AAI portal front end. Technical design document for this project lives in this Google doc.

Requirements

Ensure you have the following installed:

Installation

Follow these steps to set up the project:

  1. Clone the Repository:

    git clone https://github.com/AustralianBioCommons/aai-backend.git
    cd aai-backend
  2. Set Up a Virtual Environment: Create and activate a virtual environment:

    uv venv
    source .venv/bin/activate
  3. Install Dependencies:

    uv sync

    For dev:

    uv sync --extra dev
  4. Install pre-commit:

    pre-commit install

Run the Application

Use uv to run the FastAPI application:

uv run fastapi dev main.py

Run Tests

Execute the test suite using pytest:

uv run pytest

Run the Linter

This command will automatically fix issues where possible:

uv run -- ruff check . --fix

Manually run pre-commit

pre-commit run --all-files

Database management

The deployed service uses a Postgres database on AWS RDS. In order to generate migrations for the database locally, we use a Postgres docker container to generate migrations against.

After making any changes to the database models, run the generate_migrations.py script to create migrations:

python generate_migrations.py -m migration_name

and commit them to git. Once your updated code has been deployed on AWS, you can connect to the container via the AWS CLI. Run aws sso login first, then aws ecs execute-command to access a shell in the container:

aws ecs execute-command \
--cluster <cluster-id> \
--task <task-id> \
--container FastAPIContainer \
--command "/bin/sh" \
--interactive

and run the migrations:

uv run alembic upgrade head

Deployment

Currently the service is deployed to AWS via the CDK scripts in deploy/, and updated on each commit to main.

Secrets/configuration variables for the deployment are stored in the GitHub Secrets for the repository.

About

The backend library between Auth0 and the AAI portal front end.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages