This document provides an overview over the architecture of RDMO and provides information about the different modules.
RDMO is a Django application with an integrated React backend.
On the backend, it makes heavy use of:
- Django Rest Framework (DRF) for the REST API,
- rules for object based permissions.
The frontend code relies on:
- webpack for bundling,
- Redux for state management,
- Redux Thunk for asynchronous Redux actions,
- Bootstrap as CSS framework,
- lodash for various utilities.
Testing is done with:
- pytest for the backend,
- Playwright for the frontend.
The main rdmo package consists of the following modules:
rdmo/
├── core/ ← Core functionality
├── accounts/ ← Authentication & user profiles
├── domain/ ← Domain model
├── questions/ ← Structure of the questionnaire
├── conditions/ ← Conditional display of questions or answers
├── options/ ← Controlled vocabularies for answers
├── tasks/ ← Follow up actions based on answers
├── views/ ← Templating for output and export
├── projects/ ← User projects, snapshots and answers
├── management/ ← Management editing backend
└── services/ ← OAuth / external integrations
Each module (an app in Django terms) tries to follow the conventional layout and naming conventions:
admin.py→ Django admin interface configurationapps.py→ Django app configurationassets/→ Source files for the frontend (JavaScript, CSS, ...)constants.py→ Definition of constant valuesexports.py→ Export plugin functionalityfilters.py→ Filters for DRF viewsetsforms.py→ Django formshandlers/orhandlers.py→ Handlers for Django signalsimports.py→ Helper functionality for the XML importmanagers.py→ Managers for Django modelsmigrations/→ Django database migrationsmixins.py→ Mixins for different classesmodels/ormodels.py→ Django database modelspermissions.py→ DRF permission classesproviders.py→ Optionset provider pluginsrenderers/orrenderers.py→ Render functionality for the XML exportrules.py→ Object based permissionsserializers/orserializers.py→ DRF serializerssignals.py→ Signals for Django signalsstatic/→ Build front end assets, ignored by Gittemplates/→ Django templatestemplatetags/→ Django template tags and filterstests/→ Testsurls/orurls.py→ Django URL mappingutils.py→ Utility functionsvalidators.py→ Additional validators for DRFviews/orviews.py→ Django viewsviewsets.py→ DRF viewsets for the REST API
In addition, the rdmo repository contains the following notable files or directories:
pyproject.toml→ Python package configurationrdmo/locale→ Translation filesrdmo/share→ Supplemental filestesting→ Test configuration & fixturesconftest.py→ pytest setupwebpack.config.js→ Frontend build configurationpackage.jsonandpackage-lock.json→ Frontend dependencies
The assets directories in the modules use the following structure:
assets/js/→ JavaScript front-end code, separated by React appactions/→ Actions for the Redux storeapi/→ API classes with methods mapping the endpoints of the REST APIcomponents/→ React componentsfactories/→ Factory functions for front end objectshooks/→ React hooksreducers/→ Reducers for the Redux storestore/→ Configuration and initialization of the Redux storeutils/→ Utility functions
assets/scss/→ Sass files, separated by React appassets/fonts/,assets/img/→ Additional, static assets
┌────────────┐ ┌────────────┐
│ core │◀───┬────┤ accounts │
└────────────┘ │ └────────────┘
│ ┌────────────┐ ┌────────────┐
├────┤ domain │◀───┬────┤ projects │
│ └────────────┘ │ └────────────┘
│ ┌────────────┐ │ ┌────────────┐
├────┤ conditions │◀───┼────┤ management │
│ └────────────┘ │ └────────────┘
│ ┌────────────┐ │
├────┤ options │◀───┤
│ └────────────┘ │
│ ┌────────────┐ │
├────┤ questions │◀───┤
│ └────────────┘ │
│ ┌────────────┐ │
├────┤ tasks │◀───┤
│ └────────────┘ │
│ ┌────────────┐ │
└────┤ views │◀───┘
└────────────┘
The modules depend on each other in the following way:
coredoes not depend on the other modules.accountsdoes only depend oncore.conditions,domain,options,questions,tasks,viewsdepend only oncore(with the exception that theoptions.Optionsetmodel and theconditions.Conditiondepend on each other).projectandmanagementdepend onconditions,domain,options,questions,tasks,viewsandcore.
Besides those dependencies:
utils.pyandmanagers.pymust not depend on anything inside the module.models.pymust only depend onutils.pyandmanagers.py.
If utility functions, which depend on the models are needed, they are put in special files, e.g. process.py. Utility functions for tests are placed in tests/helpers.py.
Only after careful consideration, functions can use local imports (in the function body) to circumvent the described dependency rules.
RDMO tries to follow the conventional style of Django projects. It should work with all database backends and with all common web server setups. The aim is to limit the dependencies and the effort to maintain an instance to a minimum. For the same reason, RDMO does not depend on a caching solution or an infrastructure for asynchronous tasks.
While some parts of RDMO use the common Django MVC-pattern using models, (class-based) views and templates, other parts use the Django Rest Service pattern using viewsets, serializers and renderers. The latter is used by the interactive frontend (see below), but also as scriptable API.
As already mentioned, major parts of RDMO are implemented as separate interactive single page applications. In particular:
- the projects table located at
/projects/, - the project dashboard located at
/projects/<id>/, - the management interface located at
/management/.
The Django template of these pages contain just an empty element, and the functionality is implemented with JavaScript, React and Redux, and makes heavy use of the REST API.
In order to keep the deployment effort low, no node dependencies need to be handled by the maintainers of the instances. Instead, the frontend is build when creating the release and is then shipped as part of the rdmo Python package. Frontend source files reside in rdmo/<module>/assets/ and the build is stored in rdmo/<module>/static/, from where Django handles them as regular static files.