The objective of this service, as implied by its name, is to speed up the process of updating products' availability. This is achieved by parsing receipts and linking products to the corresponding shops in the database. We begin by addressing the more accessible digital receipts, before progressing to handling physical ones.
- Install Python 3.11
- Install Pipenv
- Run
export PIPENV_VENV_IN_PROJECT=1 && pipenv sync --dev
- Run
pipenv shell
- Create database and required tables
python src/migrations.py
withEnvType.DEV
- Run
func start
- Install Azure CLI
az login
az --version
func azure functionapp publish plante-receipt-parser
Run python -m unittest discover -s src/tests/unit
- Set up environment variables locally:
TEST_COSMOS_DB_ACCOUNT_HOST=https://{Cosmos-DB-account-name}.documents.azure.com:443/
TEST_COSMOS_DB_ACCOUNT_KEY={key}
TEST_COSMOS_DB_DATABASE_ID=PlanteTest
- Create database and required tables by running
python src/migrations.py
withEnvType.TEST
- Run
python -m unittest discover -s src/tests/integration
- Set up environment variables locally:
TEST_COSMOS_DB_ACCOUNT_HOST=https://{Cosmos-DB-account-name}.documents.azure.com:443/
TEST_COSMOS_DB_ACCOUNT_KEY={key}
TEST_COSMOS_DB_DATABASE_ID=PlanteTest
APP_HOST=https://plante-receipt-parser-test.azurewebsites.net/api
- Deploy service to test environment
func azure functionapp publish plante-receipt-parser-test
- If the service was never deployed before, add these values to Function App Configuration:
TEST_COSMOS_DB_ACCOUNT_HOST=https://{Cosmos-DB-account-name}.documents.azure.com:443/
TEST_COSMOS_DB_ACCOUNT_KEY={key}
TEST_COSMOS_DB_DATABASE_ID=PlanteTest
ENV_NAME=test
- If the service was never deployed before, add these values to Function App Configuration:
- Run
python -m unittest discover -s src/tests/functional
The code aims at modularity and loose coupling. External interfaces like database and endpoint handlers should be easily replaceable. Schemas aim to add predictability and consistency to the domain objects but not at the expense of flexibility.
Architecture and infrastructure diagram
To check the code formatting, run pylint src function_app.py
To fix most of the formatting issues, run black src function_app.py