|
| 1 | +20. Authoring as an Umbrella App of Smaller Applets |
| 2 | +=================================================== |
| 3 | + |
| 4 | +Context |
| 5 | +------- |
| 6 | + |
| 7 | +Up to this point, Learning Core has used many small apps with a narrow focus (e.g. ``components``, ``collections``, etc.) in order to make each individual app simpler to reason about. This has been useful overall, but it has made refactoring more cumbersome. For instance: |
| 8 | + |
| 9 | +#. Moving models between apps is tricky, requiring the use of Django's ``SeparateDatabaseAndState`` functionality to fake a deletion in one app and a creation in another without actually altering the database. |
| 10 | +#. Renaming an app is also cumbersome, because the process requires creating a new app and transitioning the models over. This came up when trying to rename the ``contents`` app to ``media``. |
| 11 | + |
| 12 | +There have also been minor inconveniences, like having a long list of ``INSTALLED_APPS`` to maintain in edx-platform over time. |
| 13 | + |
| 14 | +Decisions |
| 15 | +--------- |
| 16 | + |
| 17 | +1. Single Authoring App |
| 18 | +~~~~~~~~~~~~~~~~~~~~~~~ |
| 19 | + |
| 20 | +All existing authoring apps will be merged into one Django app (``openedx_learning.app.authoring``). Some consequences of this decision: |
| 21 | + |
| 22 | +- The tables will be renamed to have the ``oel_authoring`` label prefix. |
| 23 | +- All management commands will be moved to the ``authoring`` app. |
| 24 | + |
| 25 | +2. Logical Separation via Applets |
| 26 | +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 27 | + |
| 28 | +We will continue to keep internal API boundaries between individual applets, and use the ``api.py`` modules. This is both to insulate applets from implementation changes in other applets, as well as to provide a set of APIs that third-party plugins can utilize. As before, we will use Import Linter to enforce dependency ordering. |
| 29 | + |
| 30 | +3. Restructuring Plan |
| 31 | +~~~~~~~~~~~~~~~~~~~~~ |
| 32 | + |
| 33 | +In one pull request, we would: |
| 34 | + |
| 35 | +#. Remove the ``apps.py`` files for all existing ``authoring`` apps: ``backup_restore``, ``collections``, ``components``, ``contents``, ``publishing``, ``sections``, ``subsections``, ``units``. |
| 36 | +#. Move the above apps to a new ``openedx_learning.apps.authoring.applets`` package. |
| 37 | +#. Convert the top level ``openedx_learning.apps.authoring`` package to be a Django app. The top level ``admin.py``, ``api.py``, and ``models.py`` modules will do wildcard imports from the corresponding modules across all applet packages. |
| 38 | + |
| 39 | +4. Model Migration Plan |
| 40 | +~~~~~~~~~~~~~~~~~~~~~~~ |
| 41 | + |
| 42 | +Migrating models across apps is tricky. This plan assumes that people will either have a new install or run migrations from Teak or the current "main" branch, both of which have the same models/schema at the time of this writing (v0.30.2). |
| 43 | + |
| 44 | +The new ``authoring`` app's initial migration will detect whether it is a new install or an update to an existing one and either create the tables or simply repoint the models to the existing schema. The next migration will rename the tables to have a common ``oel_authoring`` prefix. |
| 45 | + |
| 46 | + |
| 47 | +4. The Bigger Picture |
| 48 | +~~~~~~~~~~~~~~~~~~~~~ |
| 49 | + |
| 50 | +This practice means that the ``authoring`` Django app corresponds to a Subdomain in Domain Driven Design terminology, with each applet being a Bounded Context. We call these "Applets" instead of "Bounded Contexts" because we don't want it to get confused for Django's notion of Contexts and Context Processors (or Python's notion of Context Managers). |
0 commit comments