# Project Allocator

[![pipeline status](https://gitlab.doc.ic.ac.uk/edtech/project-allocator/badges/master/pipeline.svg)](https://gitlab.doc.ic.ac.uk/edtech/project-allocator/commits/master)

## Project Requirements

* **Python 3.10** and [Flask](http://flask.palletsprojects.com/)
* [Gunicorn](https://gunicorn.org/) - web server ("in front" of the API)
* **Postgres SQL** - databases

## Running the app

Via `docker-compose`:

```shell
docker compose up -f dev.docker-compose.yml [--build]
docker exec $(docker ps -qf "name=allocator" | head -n1) flask db upgrade
docker exec $(docker ps -qf "name=allocator" | head -n1) flask populate_dev
```

Alternatively, if you want to run the app locally (recommended for debugging):

```shell
# Terminal panel 1
docker run --rm --name project-allocator -p 2000:5432 -e POSTGRES_DB=project-allocator -e POSTGRES_USER=user -e POSTGRES_PASSWORD=pass postgres

# Terminal panel 2
export DB_OVERRIDE=postgresql://user:pass@localhost:2000/project-allocator
python3 -m venv venv
. venv/bin/activate
pip install -r requirements.txt
flask db upgrade
flask populate_dev
flask run
```

Then browse to <http://localhost:5000>.

## Running the tests

Via `docker-compose`, after *upping*:

```shell
docker exec $(docker ps -qf "name=allocator" | head -n1) pytest
```

Alternatively, if you want to run the test locally (Mac specific):

```shell
brew services start postgres
python3 -m venv venv
. venv/bin/activate
pip install -r requirements.txt
pytest
```