I've inherited a GCP project using Python as the primary language. Its my first exposure to GCP and I'm concerned that the project may not be structured properly as far as best-practices are concerned.
The project consists of App-Engine (standard) to expose several HTTP endpoints for use by an web-app, as well as several 'trigger' Cloud Functions which are deployed to handle various situations requiring backend processing, ex: object uploads to a bucket. Currently the project code base contains both the App-Engine code and the Cloud Functions code.
The code structure looks like this:
project/
├── main.py
└── common-ftns/
├── __init__.py
└── initialize-app.py
└── utils.py
└── cloud-ftns/
└── cloud_ftn-1.py
└── cloud_ftn-2.py
└── services/
└── service-1-routes.py
└── service-1.py
└── service-2-routes.py
└── service-2.py
We are using GCP Cloud Build to deploy the entire solution and everything works great. However my concern is around the common use of main.py for both App-Engine and the Cloud Functions. Both GAE and Cloud Functions seem to require the existence of the root-level main.py file to initialize the app (including Flask) as well as declare the Cloud Function entry points. This bothers me since it seems that Cloud Functions and App-Engine should not be requiring a common starting point, not to mention that the trigger-handling Cloud Functions should not need to have Flask since they are not using it.
My question is this: is this type of structure considered "best-practice" in the GCP/Python world? If not then is there a better way to leverage main.py such that Cloud Functions and GAE do not have to run the exact same start-up script?