This means creating a new module (core) inside tjf with all the business models and logic, similar to the API one in structure.
We might want to create a Core interface class with all the methods that the api module will use (similar strategy than with storage or runtime, but no need for abstract class for this one). This should be created at startup time (app.py) and stored in the app object.
It should accept the storage and runtime as init parameters, and we should stop using them directly on the api module, and call the Core methods instead (api should not be aware of a storage or runtime, just core). For example:
# app.py
def create_app(...):
...
my_core = Core(storage=Storage(), runtime=Runtime())
...
# ex. jobs_handlers.py
def create_job(app, new_job: NewJob, tool_name: str, ...) -> DefinedJob:
...
gotten_job = DefinedJob.from_job(app.core.create_job(job=new_job.to_job(), tool_name=tool_name)
return gotten_job