Skip to content

SFOE/drillapi

Repository files navigation

CI

drillapi - geothermal drilling

Query the cantonal geoservices to know whether a site in Switzerland is suitable for a geothermal drilling.

What does this FastAPI project do ?

  • take x/y coordinates in EPSG:2056 on route /v1/x/y
  • find in which canton the coordinates are and retrieve specific geoservice configuration
  • send request to corresponding cantonal geoservices, depending on location
  • process and reclass the results (1: OK, 2: With restriction, 3: Forbidden, 4: Unknown or Service Error)
  • return reponse used by drill-frontend vuejs web app

Run

This project can run in docker:

Latest image

docker run -d \
 -p 8000:8000 \
 -e RATE_LIMIT="1000/minute" \
 -e ALLOWED_IPS='["127.0.0.1","192.168.1.10"]' \
 -e ALLOWED_ORIGINS='["http://localhost:5173","https://www.uvek-gis.admin.ch/"]' \
 -e ENVIRONMENT=PROD \
 ghcr.io/sfoe/drillapi:latest

Release specific image

docker run -d \
 -p 8000:8000 \
 -e RATE_LIMIT="1000/minute" \
 -e ALLOWED_IPS='["127.0.0.1","192.168.1.10"]' \
 -e ALLOWED_ORIGINS='["http://localhost:5173","https://www.uvek-gis.admin.ch/"]' \
 -e ENVIRONMENT=PROD \
 ghcr.io/sfoe/drillapi:<vx.y.z>

Local setup for development

Create .env file and ⚠️ adapt values ⚠️

Special attention to the ENVIRONMENT value, MUST never be set to DEV in production environnement

cp env.example .env

Create python virtual environment

python3 -m venv venv

Activate python virtual environment

source venv/bin/activate

Install dependencies

pip install -e .

For dev install dev requirements

pip install -e ".[dev]"

Install pre-commit and activate it

pip install pre-commit
pre-commit install

Run pre-commit manually

pre-commit run --all-files

Start

Run dev server

uvicorn drillapi.app:app --reload

Run project

python -m drillapi

Explore

OpenAPI doc

http://127.0.0.1:8000/docs

Checker that sends predefined calls to all configured cantons - IP restricted ⚠️

http://127.0.0.1:8000/checker

Or check one canton only - IP restricted ⚠️

http://127.0.0.1:8000/checker/VD

Main route v1

http://127.0.0.1:8000/v1/drill-category/2602531.09/1202835.00

Canton's configuration v1

http://127.0.0.1:8000/v1/cantons

Canton's configuration v1 for one canton's code ("NE", "BE")

http://127.0.0.1:8000/v1/cantons/NE

Test

Install dev requirements

pip install -e ".[dev]"

Run tests

python -m pytest -v

Running local docker image

Using Docker Compose

docker compose up -d --build && docker compose logs -f drillapi

Using Docker

Build local image

docker build -t drillapi .

Run container

docker run -d -p 8000:8000 --name drillapi_container drillapi

View logs

docker logs -f drillapi_container

Stop container

docker stop drillapi_container
docker rm drillapi_container

About

New backend for kann-ich-bohren

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 5