Although a beginner in web development, I currently have been working on a larger Flask application.
At the moment I'm working with the structure shown below but I'm wondering what is the best way to structure such an application especially regarding different database connections (SQLAlchemy).
Unlike what is shown in the usual (and very helpful) Flask tutorials, I envision an architecture of multiple, partially independent (sub)apps, each also relying on its own database connection. Also, I don't necessarily want to load all databases immediately when accessing the main website but only the one of the subapp that is needed.
For communication between server and client I plan to use REST API and I already use Blueprints to separate the subapps.
The app has a unified frontend, where the subapps are simply mapped to different URL endpoints (e.g. website.net/app1 and website.net/app2).
Any guidance on structuring such an app is greatly appreciated, thanks!
Current app structure:
project/
├─ run.py
├─ webapp/
│ ├─ __init__.py
│ ├─ static/
│ ├─ templates/
│ ├─ app1/
│ │ ├─ data/
│ │ │ ├─ app1_database.py
│ │ │ ├─ app1_db_session.py
│ │ │ ├─ app1_modelbase.py
│ │ ├─ database/
│ │ ├─ services/
│ │ │ ├─ app1_services.py
│ │ ├─ templates/
│ │ │ ├─ app1/
│ │ │ │ ├─ app1.html
│ │ ├─ __init__.py
│ │ ├─ app1_forms.py
│ │ ├─ app1_views.py
│ ├─ app2/
│ │ ├─ data/
│ │ │ ├─ app2_database.py
│ │ │ ├─ app2_db_session.py
│ │ │ ├─ app2_modelbase.py
│ │ ├─ database/
│ │ ├─ services/
│ │ │ ├─ app2_services.py
│ │ ├─ templates/
│ │ │ ├─ app2/
│ │ │ │ ├─ app2.html
│ │ ├─ __init__.py
│ │ ├─ app2_forms.py
│ │ ├─ app2_views.py