This is a simple Flask API that provides Get/Post/Patch services for documents in the Curriculum collection. This API uses data from a backing Mongo Database, and supports a Single Page Application.
The OpenAPI specifications for the api can be found in the docs
folder, and are served here
- Mongo Compass - if you want a way to look into the database
pipenv install
pipenv run test
NOTE: This excludes the tests with a backing service i.e. testbacking_mentorhub_mongo_io.py which can be run in vscode with the mongodb backing database running.
pipenv run start
pipenv run local
pipenv run container
This will build the new container, and {re}start the mongodb and API container.
NOTE: Assumes the API is running at localhost:8088
pipenv run stepci
NOTE: Assumes the API is running at localhost:8088
pipenv run load
/src
this folder contains all source code/src/server.py
is the main entrypoint, which initializes the configuration and registers routes with Flask/src/config/Config.py
is the singleton config object that manages configuration values and acts as a cache for enumerators and other low volatility data values./src/models
contains helpers related to creating transactional data objects such as breadcrumbs or RBAC tokens/src/routes
contains Flask http request/response handlers/src/services
service interface that wraps database calls with RBAC, encode/decode, and other business logic/src/utils/mentorhub_mongo_io.py
is a singleton that manages the mongodb connection, and provides database io functions to the service layer./test
this folder contains unit testing, and testing artifacts. The sub-folder structure mimics the/src
folder
If you want to do more manual testing, here are the curl commands to use
This endpoint supports the Prometheus monitoring standards for a healthcheck endpoint
curl http://localhost:8088/api/health/
curl http://localhost:8088/api/config/
curl http://localhost:8088/api/curriculum/{_id value}
curl -X PATCH http://localhost:8088/api/curriculum/{_id value} \
-d '{"now":"[]"}'
curl -X DELETE http://localhost:8088/api/curriculum/{_id value}
The api/config/
endpoint will return a list of configuration values. These values are either "defaults" or loaded from a singleton configuration file, or an Environment Variable of the same name. Configuration files take precedence over environment variables. The environment variable "CONFIG_FOLDER" will change the location of configuration files from the default of ./
The api/health/
endpoint is a Prometheus Health check endpoint.
The Dockerfile uses a 2-stage build, and supports both amd64 and arm64 architectures.