I'm writing a program in Python that has two different entry points. There's a CLI that processes some data and needs to be installed to run hourly on a server, this populates a database. There's also a web app that has a front end for viewing the data in that database.
I'm using sqlalchemy as an ORM for the database that I'd like this to share between the CLI and the web app. My question is, should I write a single package with the code for all three elements (web app, database and CLI) all in one. Or separate out the database into its own package and use this as an API for the web app and CLI in their own packages?
My current thoughts (based on helpful comments below from @Hans-MartinMosner) are to have a project structure like this:
my_project
database_orm/
db_model1.py
db_model2.py
db_helper.py
my_webapp/
__init__.py
views.py
templates/
index.html
page2.html
static/
site.js
site.css
setup.py
my_cli/
__init__.py
__main__.py
magic.py
tests/
unit_test.py
setup.py
Any opinionated advice on a different structure and ways that I can simplify deployment (I'm planning on hosting the web app on Azure App Services) will be greatly received.
I should probably point out that I'm using Python 3.7 and I don't need to worry about earlier Python versions.