-
Notifications
You must be signed in to change notification settings - Fork 54
Contributing guide #1565
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
jochenklar
wants to merge
3
commits into
main
Choose a base branch
from
contributing-guide
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+327
−56
Draft
Contributing guide #1565
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,159 @@ | ||
| # Architecture | ||
|
|
||
| This document provides an overview over the architecture of RDMO and provides information about the different modules. | ||
|
|
||
| ## Core dependencies | ||
|
|
||
| RDMO is a [Django](https://www.djangoproject.com/) application with an integrated [React](https://react.dev/) backend. | ||
|
|
||
| On the backend, it makes heavy use of: | ||
|
|
||
| * [Django Rest Framework](https://www.django-rest-framework.org/) (DRF) for the REST API, | ||
| * [rules](https://github.com/dfunckt/django-rules) for object based permissions. | ||
|
|
||
| The frontend code relies on: | ||
|
|
||
| * [webpack](https://webpack.js.org) for bundling, | ||
| * [Redux](https://redux.js.org/) for state management, | ||
| * [Redux Thunk](https://github.com/reduxjs/redux-thunk) for asynchronous Redux actions, | ||
| * [Bootstrap](https://getbootstrap.com/) as CSS framework, | ||
| * [lodash](https://lodash.com/) for various utilities. | ||
|
|
||
| Testing is done with: | ||
|
|
||
| * [pytest](https://docs.pytest.org) for the backend, | ||
| * [Playwright](https://playwright.dev) for the frontend. | ||
|
|
||
| ## File layout | ||
|
|
||
| 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 configuration | ||
| * `apps.py` → Django app configuration | ||
| * `assets/` → Source files for the frontend (JavaScript, CSS, ...) | ||
| * `constants.py` → Definition of constant values | ||
| * `exports.py` → Export plugin functionality | ||
| * `filters.py` → Filters for DRF viewsets | ||
| * `forms.py` → Django forms | ||
| * `handlers/` or `handlers.py` → Handlers for Django signals | ||
| * `imports.py` → Helper functionality for the XML import | ||
| * `managers.py` → Managers for Django models | ||
| * `migrations/` → Django database migrations | ||
| * `mixins.py` → Mixins for different classes | ||
| * `models/` or `models.py` → Django database models | ||
| * `permissions.py` → DRF permission classes | ||
| * `providers.py` → Optionset provider plugins | ||
| * `renderers/` or `renderers.py` → Render functionality for the XML export | ||
| * `rules.py` → Object based permissions | ||
| * `serializers/` or `serializers.py` → DRF serializers | ||
| * `signals.py` → Signals for Django signals | ||
| * `static/` → Build front end assets, ignored by Git | ||
| * `templates/` → Django templates | ||
| * `templatetags/` → Django template tags and filters | ||
| * `tests/` → Tests | ||
| * `urls/` or `urls.py` → Django URL mapping | ||
| * `utils.py` → Utility functions | ||
| * `validators.py` → Additional validators for DRF | ||
| * `views/` or `views.py` → Django views | ||
| * `viewsets.py` → DRF viewsets for the REST API | ||
|
|
||
| In addition, the `rdmo` repository contains the following notable files or directories: | ||
|
|
||
| * `pyproject.toml` → Python package configuration | ||
| * `rdmo/locale` → Translation files | ||
| * `rdmo/share` → Supplemental files | ||
| * `testing` → Test configuration & fixtures | ||
| * `conftest.py` → pytest setup | ||
| * `webpack.config.js` → Frontend build configuration | ||
| * `package.json` and `package-lock.json` → Frontend dependencies | ||
|
|
||
| The `assets` directories in the modules use the following structure: | ||
|
|
||
| * `assets/js/` → JavaScript front-end code, separated by React app | ||
| * `actions/` → Actions for the Redux store | ||
| * `api/` → API classes with methods mapping the endpoints of the REST API | ||
| * `components/` → React components | ||
| * `factories/` → Factory functions for front end objects | ||
| * `hooks/` → React hooks | ||
| * `reducers/` → Reducers for the Redux store | ||
| * `store/` → Configuration and initialization of the Redux store | ||
| * `utils/` → Utility functions | ||
| * `assets/scss/` → Sass files, separated by React app | ||
| * `assets/fonts/`, `assets/img/` → Additional, static assets | ||
|
|
||
| ## Internal dependencies | ||
|
|
||
| ```plain | ||
| ┌────────────┐ ┌────────────┐ | ||
| │ core │◀───┬────┤ accounts │ | ||
| └────────────┘ │ └────────────┘ | ||
| │ ┌────────────┐ ┌────────────┐ | ||
| ├────┤ domain │◀───┬────┤ projects │ | ||
| │ └────────────┘ │ └────────────┘ | ||
| │ ┌────────────┐ │ ┌────────────┐ | ||
| ├────┤ conditions │◀───┼────┤ management │ | ||
| │ └────────────┘ │ └────────────┘ | ||
| │ ┌────────────┐ │ | ||
| ├────┤ options │◀───┤ | ||
| │ └────────────┘ │ | ||
| │ ┌────────────┐ │ | ||
| ├────┤ questions │◀───┤ | ||
| │ └────────────┘ │ | ||
| │ ┌────────────┐ │ | ||
| ├────┤ tasks │◀───┤ | ||
| │ └────────────┘ │ | ||
| │ ┌────────────┐ │ | ||
| └────┤ views │◀───┘ | ||
| └────────────┘ | ||
| ``` | ||
|
|
||
| The modules depend on each other in the following way: | ||
|
|
||
| * `core` does not depend on the other modules. | ||
| * `accounts` does only depend on `core`. | ||
| * `conditions`, `domain`, `options`, `questions`, `tasks`, `views` depend only on `core` (with the exception that the `options.Optionset` model and the `conditions.Condition` depend on each other). | ||
| * `project` and `management` depend on `conditions`, `domain`, `options`, `questions`, `tasks`, `views` and `core`. | ||
|
|
||
| Besides those dependencies: | ||
|
|
||
| * `utils.py` and `managers.py` must not depend on anything inside the module. | ||
| * `models.py` must only depend on `utils.py` and `managers.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. | ||
|
|
||
| ## Backend considerations | ||
|
|
||
| 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. | ||
|
|
||
| ## Frontend considerations | ||
|
|
||
| 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. | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean integrated React frontend?