Skip to content
This repository was archived by the owner on Aug 1, 2024. It is now read-only.

Commit 38af973

Browse files
committed
feat!: invert dependencies so that backends now depend on frontends
lms now depends on frontend-app-learning; previously, the converse was true. Running `make dev.up.lms` will start the frontend-app-learning container. This change has been made for all Devstack frontends/backends. This is breaking in that `make dev.up.frontend-app-*` is no longer the best way to start a frontend from a clean state, since it will not start related backend service(s). Instead, the backend service should be started, which will cause all related frontend apps to be started as dependencies. See included ADR (#4) for more context. Also includes some doc updates related to this change. TNL-8407
1 parent 40177f7 commit 38af973

File tree

5 files changed

+105
-40
lines changed

5 files changed

+105
-40
lines changed

README.rst

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -13,27 +13,22 @@ The Devstack runs as multiple containers with `Docker Compose`_ at its core.
1313

1414
A Devstack installation includes the following Open edX components by default:
1515

16-
* The Learning Management System (LMS)
17-
* The Learning micro-frontend (A.K.A the new Courseware experience)
16+
* The Learning Management System (LMS).
17+
* LMS micro-frontends, including Gradebook and Learning (a.k.a. the "new courseware experience").
1818
* Open Response Assessments (ORA2), among other LMS plug-ins.
19-
* Open edX Studio
20-
* Discussion Forums
21-
* E-Commerce
22-
* Credentials
23-
* Notes
24-
* Course Discovery
25-
* Open edX Search
26-
* A demonstration Open edX course
27-
* The Publisher and Gradebook micro-frontends
19+
* Discussion Forums.
20+
* Open edX Studio, including the Library- and Course-Authoring micro-frontends.
21+
* E-Commerce, including the Payment micro-frontend.
22+
* Course Discovery, including the Publisher micro-frontend.
23+
* Credentials.
24+
* Notes.
25+
* Open edX Search.
26+
* A demonstration Open edX course.
2827

2928
It also includes the following extra components:
3029

31-
* XQueue
32-
* The Program Console micro-frontend
33-
* The Library Authoring micro-frontend
34-
* edX Registrar service.
35-
* The course-authoring micro-frontend
36-
30+
* XQueue and an example XQueue consumer.
31+
* Registrar, including the Program Console micro-frontend.
3732

3833
.. contents:: **Table of Contents:**
3934

@@ -302,13 +297,13 @@ Instead of a service name or list, you can also run commands like ``make dev.pro
302297
+------------------------------------+-------------------------------------+----------------+--------------+
303298
| `frontend-app-gradebook`_ | http://localhost:1994/ | MFE (React.js) | Default |
304299
+------------------------------------+-------------------------------------+----------------+--------------+
305-
| `registrar`_ | http://localhost:18734/api-docs/ | Python/Django | Extra |
300+
| `frontend-app-library-authoring`_ | http://localhost:3001/ | MFE (React.js) | Default |
306301
+------------------------------------+-------------------------------------+----------------+--------------+
307-
| `frontend-app-program-console`_ | http://localhost:1976/ | MFE (React.js) | Extra |
302+
| `frontend-app-course-authoring`_ | http://localhost:2001/ | MFE (React.js) | Default |
308303
+------------------------------------+-------------------------------------+----------------+--------------+
309-
| `frontend-app-library-authoring`_ | http://localhost:3001/ | MFE (React.js) | Extra |
304+
| `frontend-app-program-console`_ | http://localhost:1976/ | MFE (React.js) | Extra |
310305
+------------------------------------+-------------------------------------+----------------+--------------+
311-
| `frontend-app-course-authoring`_ | http://localhost:2001/ | MFE (React.js) | Extra |
306+
| `registrar`_ | http://localhost:18734/api-docs/ | Python/Django | Extra |
312307
+------------------------------------+-------------------------------------+----------------+--------------+
313308
| `xqueue`_ | http://localhost:18040/api/v1/ | Python/Django | Extra |
314309
+------------------------------------+-------------------------------------+----------------+--------------+

docker-compose.yml

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,7 @@ services:
220220
hostname: discovery.devstack.edx
221221
depends_on:
222222
- elasticsearch7
223+
- frontend-app-publisher
223224
- memcached
224225
- mysql57
225226
# Allows attachment to the discovery service using 'docker attach <containerID>'.
@@ -248,6 +249,7 @@ services:
248249
hostname: ecommerce.devstack.edx
249250
depends_on:
250251
- discovery
252+
- frontend-app-payment
251253
- lms
252254
- memcached
253255
- mysql57
@@ -321,6 +323,8 @@ services:
321323
- discovery
322324
- elasticsearch7
323325
- forum
326+
- frontend-app-gradebook
327+
- frontend-app-learning
324328
- memcached
325329
- mongo
326330
- mysql57
@@ -354,6 +358,7 @@ services:
354358
hostname: registrar.devstack.edx
355359
depends_on:
356360
- discovery
361+
- frontend-app-program-console
357362
- lms
358363
- mysql57
359364
- memcached
@@ -428,8 +433,9 @@ services:
428433
depends_on:
429434
- devpi
430435
- elasticsearch7
431-
- memcached
432-
- mongo
436+
- frontend-app-course-authoring
437+
- frontend-app-library-authoring
438+
- frontend-app-publisher
433439
- lms
434440
- memcached
435441
- mongo
@@ -506,8 +512,6 @@ services:
506512
- edx.devstack.frontend-app-course-authoring
507513
ports:
508514
- "2001:2001"
509-
depends_on:
510-
- studio
511515

512516
frontend-app-gradebook:
513517
extends:
@@ -521,8 +525,6 @@ services:
521525
- edx.devstack.frontend-app-gradebook
522526
ports:
523527
- "1994:1994"
524-
depends_on:
525-
- lms
526528

527529
frontend-app-learning:
528530
extends:
@@ -536,8 +538,6 @@ services:
536538
- edx.devstack.frontend-app-learning
537539
ports:
538540
- "2000:2000"
539-
depends_on:
540-
- lms
541541

542542
frontend-app-library-authoring:
543543
extends:
@@ -551,9 +551,6 @@ services:
551551
- edx.devstack.frontend-app-library-authoring
552552
ports:
553553
- "3001:3001"
554-
depends_on:
555-
- lms
556-
- studio
557554

558555
frontend-app-payment:
559556
extends:
@@ -567,8 +564,6 @@ services:
567564
- edx.devstack.frontend-app-payment
568565
ports:
569566
- "1998:1998"
570-
depends_on:
571-
- ecommerce
572567

573568
frontend-app-program-console:
574569
extends:
@@ -582,9 +577,6 @@ services:
582577
- edx.devstack.frontend-app-program-console
583578
ports:
584579
- "1976:1976"
585-
depends_on:
586-
- lms
587-
- registrar
588580

589581
frontend-app-publisher:
590582
extends:
@@ -598,8 +590,6 @@ services:
598590
- edx.devstack.frontend-app-publisher
599591
ports:
600592
- "18400:18400"
601-
depends_on:
602-
- lms
603593

604594
volumes:
605595
discovery_assets:
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
4. Backend services now depend on frontend apps
2+
-----------------------------------------------
3+
4+
Status
5+
======
6+
7+
Approved
8+
9+
10+
Context
11+
=======
12+
13+
Micro-frontends as default experiences
14+
**************************************
15+
16+
As of mid June 2021 (between the Lilac and Maple releases), an Open edX instance with default configuration will now direct users to the Learning MFE (Micro-Frontend) for courseware, with a temporary opt-out flag existing to revert to legacy LMS-rendered frontend. Thus, to test a typical learner experience, Devstack users now require the frontend-app-learning container to be started alongside the LMS. This is in contrast to the previous state of affairs, in which MFE experiences were only available via an opt-IN flag, allowing reasonable Devstack usage without having to start any MFE containers.
17+
18+
We anticipate that other learner, author, and administrator experiences will soon begin to use MFE features by default, requiring that more and more MFEs be started in order to simulate user experiences in Devstack. Thus, we anticipate an imminent developer experience issue, in which developers will need to type in convoluated commands like::
19+
20+
make dev.up.frontend-app-authn+frontend-app-discussions+frontend-app-gradebook+frontend-app-learning
21+
22+
23+
in order to enable the feature set that was previously available using simply::
24+
25+
make dev.up.lms
26+
27+
28+
Docker-compose service dependencies
29+
***********************************
30+
31+
Devstack uses docker-compose to orchestrate containers by defining services in ``docker-compose.yml``. Note that "services" here encompasses backends, frontends, and generic resources like MySQL.
32+
33+
Each service definition may indicate a list of depentent services using the ``depends_on`` key. Dependencies are transitive, and may not be cyclical. When a developer runs ``make dev.up.<service>``, docker-compose is invoked in order to start both the service as well as its dependencies. For example, LMS depends on Mongo and Discovery, among other services. So, running ``make dev.up.lms`` will start not just LMS, but also Mongo, Discovery, all of Discovery's dependencies, and so on.
34+
35+
Currently, micro-frontend services (those prefixed with ``frontend-app-``) are defined to depend on backends, but not vice versa. So, starting frontend-app-learning will automatically start LMS, but starting LMS will not automatically start frontend-app-learning. This makes sense under logic that "frontends depend on the APIs of backends in order to function".
36+
37+
However, it can be argued that the opposite dependency relationship also makes sense. That is, one may assert that backends should depend on frontends in order to expose their APIs in a usable way. One could further assert that frontends shouldn't have hard dependencies on backend APIs, and should instead gracefully degrade when some or all of its APIs are unavailable.
38+
39+
40+
Decision
41+
========
42+
43+
Whichever dependency direction (frontends depend on backends, or vice versa) is more logically sound, we conclude that, for the purposes of Devstack, *asserting that backends depend on frontends is more useful to developers*. Specifically, it is beneficial to current and future developer workflows if ``make dev.up.lms`` automatically starts and learning-related frontends, ``make dev.up.studio`` automatically starts all authoring-related frontends, ``make dev.up.ecommerce`` starts all purchasing-related frontends, and so on.
44+
45+
A necessary corollary to this decision is that *all micro-frontends required for default functionality must be included in devstack*. While it is encouraged that *all* new and existing micro-frontends are added to devstack using the pattern described above, it is absolutely necessary that MFEs which are required for out-of-the-box functionality be added to devstack.
46+
47+
48+
Consequences
49+
============
50+
51+
* ``docker-compose.yml`` will be updated to reflect that backend services depend on frontend-app services, not the other way around. Devstack documentation will be upated accordingly.
52+
* ``docker-compose-host.yml`` will be updated to address an issue with local usage of JS packages, which currently forces some frontend development workflows to occur outside of devstack. The `documentation in frontend-build`_ will be updated accordingly. See `ADR 5: Mounting frontend packages from src directory`_ for details.
53+
* An email and Slack message will be sent out to explain these changes and how we anticipate that they will impact developer workflows. The email will explain that if a micro-frontend is required to simulate common user story in the default configuration, then that frontend should be devstack, and should be automatically started by the relevant backend using ``depends_on``.
54+
55+
56+
.. _documentation in frontend-build: https://github.com/edx/frontend-build#local-module-configuration-for-webpack
57+
.. _ADR 5: Mounting frontend packages from src directory: ./0005-frontend-package-mounts.rst
58+
59+
Rejected Alternatives
60+
=====================
61+
62+
* Keep the old dependency relationships, but add convenience targets (such as ``dev.up.domain.learning``) to start groups of related micro-frontends. We determine that this would increase the already-large congnitive overhead of the Devstack interface.
63+
* Invert dependency relationships as described in this ADR, and also add targets such as ``make dev.up.lms-backend`` in order to start LMS without associated frontends. We determine that this would create a cascade of new inconsistencies in the Devstack interface: since only one of ``lms`` or ``lms-backend`` could exist as a docker-compose service, rules for the other would have to be hard-coded into the Makefile as special cases.

docs/workflow.rst

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,18 @@ Database backups
5454
~~~~~~~~~~~~~~~~
5555

5656
You can routinely create backups of your local databases. To create a backup, use ``make dev.backup``. When you want to restore you database to the backup, run ``make dev.restore``. Warning, this will retore all your databases. You might have to cycle the database containers off and on using ``make dev.down.<database service name>`` and ``make dev.up.<database service name>``.
57+
58+
Running micro-frontends outside of devstack
59+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
60+
61+
Although several micro-frontends (MFEs) are built into devstack (the full list is in the `service table`_), some users prefer to run those MFEs directly on their host machine. You can achieve this by first removing the devstack MFE container, and then starting the host version. For example::
62+
63+
make dev.down.frontend-app-learning # Bring down the devstack version of the Learning MFE.
64+
cd <path-to-frontend-app-learning> # Navigate to the Learning MFE's repository.
65+
npm install && npm start # Install JS packages, and start the NPM devserver on your local host.
66+
67+
Of course ``learning`` can be replaced with ``gradebook``, ``payment``, or another frontend-app name.
68+
69+
If you forget to bring down the devstack version of the MFE, you will notice a port conflict when trying to start the host version.
70+
71+
.. _service table: ../README.rst#service-list

options.mk

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ FS_SYNC_STRATEGY ?= local-mounts
5858
# Services that are to be pulled, provisioned, run, and checked by default
5959
# when no services are specified manually.
6060
# Should be a subset of $(EDX_SERVICES).
61+
# frontend-apps are not included here, but several of them are dependencies of default
62+
# services.
6163
# Separated by plus signs. Listed in alphabetical order for clarity.
6264
# WARNING: You may remove services from this list in order to make Devstack lighter,
6365
# but beware that some services have implicit, undocumented dependencies on
@@ -68,7 +70,7 @@ FS_SYNC_STRATEGY ?= local-mounts
6870
# The current value was chosen such that it would not change the existing
6971
# Devstack behavior.
7072
DEFAULT_SERVICES ?= \
71-
credentials+discovery+ecommerce+edx_notes_api+forum+frontend-app-gradebook+frontend-app-payment+frontend-app-publisher+frontend-app-learning+lms+studio
73+
credentials+discovery+ecommerce+edx_notes_api+forum+lms+studio
7274

7375
# All edX services, whether or not they are run by default.
7476
# Separated by plus signs.

0 commit comments

Comments
 (0)