-
Notifications
You must be signed in to change notification settings - Fork 0
Home
simaps-api is a python flask REST API - server-side of KAVALÉ project. API is consumed via simaps-client.
This web app aims to highlight hike trails in France.
simaps-api/conf/dev.env
simaps-api/conf/prod.env
Configuration .env files sets credentials to access Database (via docker container in development mode, Postgres Cloud SQL instance in production mode) and credentials to setup Firebase app that handles API authorization.
simaps-api/test/functional/test_flask_api.py
API can be tested with pytest, given a Flask application configured for testing.
simaps-api/model/data.py
simaps-api provides 4 dataclass :
- hikes : main class, linked to others via ManyToOne relationships
- trails : gpx tracks
- journeys : hike type
- zones : hike location
SQLAlchemy ORM is used to represent the relational database tables as classes, with attributes representing the columns of those tables.
simaps-api/model/db.py
Depending on the environment, 2 methods are used :
- in development mode a connection pool is made to access DB within Docker Container
simaps-api/docker-compose.yml. Port 5431 is exposed, docker volume is used to persist data, andsimaps-api/database/init.sqlis played as entrypoint to init DB. - in production mode a connection pool is initialized with python connector for Postgres for a Cloud SQL instance of Postgres. User credentials are stored with Google Cloud Secret Manager
simaps-api/wsmain/app.py
Flask class is imported and an instance is created app = Flask(__name__). Cross-Origin requests are enabled. @route decorator is used to specify the URLs that should be triggered.
- in development mode a development server is used and runs on 5001 port
- in production mode a gunicorn server is used and runs on 8080 port
Firebase app is also initialized in order to handle authorization.
CI configuration simaps-api/.github/workflows/google-cloudrun-docker.yml
Dockerfile simaps-api/Dockerfile
Docker entrypoint simaps-api/docker-entrypoint.sh
Requirements simaps-api/requirements.txt
API is deployed with Google Cloud Run. Service is executed with a service account with Client Cloud SQL role.
CI is configured with GitHub Actions. A docker image is build and pushed to Google Artifact Registry. Then a new service version is created on Cloud Run. Another service account is used, and credentials are defined in GitHub Actions secrets and variables.
Firebase Hosting is integrated in order to enable custom domain for the API.
Copyleft GNU GENERAL PUBLIC LICENSE v3.0