MT-05 Design Offline Architecture
Goal:”Design a comprehensive offline storage architecture to later use for implementation”
The documentation and design of openIMIS Offline Mode will be developed using arc42.org
Introduction and Goals
Requirements Overview
# | User Story |
FREQ01 | As a user, I want the application to load even without an internet connection so that I can continue using it offline. |
FREQ02 | As a user, I want previously visited pages or content to be available when I'm offline so that I can access information I’ve already seen. |
FREQ03 | As a user, I want to see a fallback message or page when a resource isn’t available offline so that I understand what’s happening. |
FREQ04 | As a user, I want my inputs and data to be saved locally when offline so that I don’t lose work if I lose connection. |
FREQ05 | As a user, I want any changes I make offline to sync automatically when I regain internet access so that I don’t have to remember to submit them again. |
FREQ06 | As a user, I want to be notified when I go offline or come back online so that I understand the app’s current capabilities. |
FREQ07 | As a user, I want any unavailable UI elements in offline mode to be disabled so that I don’t try actions that won’t work. |
FREQ08 | As a user, I want to be notified if there’s a conflict between my offline changes and server data so that I can choose what to keep. |
FREQ09 | As a user, I want to use the offline mode without any additional installation needed, so that I don’t have to learn new functionalities |
FREQ10 | As a user, I want to use the offline mode in my Webrowser which is supported by openIMIS so that I dont have to install/use another one |
FREQ11 | As a user, I want to have the same performance of using openIMIS while background synchronisation is happening, so that I’m still possible to work. |
FREQ12 | As a user, I want to Login/Logout to openIMIS even if the system is in offline mode. |
FREQ13 | As a user, I want to get, create, update and deleted all patients and claims, same as in the online version, so that I can work efficiently. |
Quality Goals
# |
Requirement | Topic |
QREQ01 | The Offline Mode Module must register service workers only over HTTPS. | Security |
QREQ02 | The Offline Mode Module must encrypt locally stored patient data. | Security |
QREQ03 | The Offline Mode Module must use only trustful and supported packages as dependencies | Security |
QREQ04 | The Offline Mode Module must ensure, that responses are generated and send at least as fast as the online version. | Performance |
QREQ05 | The Offline Mode Module must ensure caching does not significantly degrade online performance. | Performance |
QREQ06 | The Offline Mode Module must complete background synchronization operations within 500ms | Performance |
QREQ07 | The Offline Mode Module must retain cached content for a minimum of 30 days unless explicitly cleared or updated. | Reliability |
QREQ08 | The Offline Mode Module must handle offline-to-online transitions without data corruption or user disruption. | Reliability |
QREQ09 | The Offline Mode Module must retry failed offline sync operations using exponential backoff. | Reliability |
QREQ10 | The Offline Mode Module must support offline mode in all modern browsers (Chrome, Firefox, Safari, Edge). | Availability |
QREQ11 | The Offline Mode Module must log offline errors and sync issues for developer diagnostics. | Observability |
QREQ12 | The Offline Mode Module must support Linux, MacOS as well as Windows | Compatibility |
QREQ13 | The Offline Mode Module must implement cache versioning to safely manage service worker updates. | Maintainability |
QREQ14 | The Offline Mode Module should track usage and performance of offline mode (e.g., sync success rates, offline sessions). | Observability |
QREQ15 | The Offline Mode Module must make sure, that no additional installations are needed for. | Maintainability |
Stakeholders
Role/Name | Expectations | Communication |
|---|---|---|
User openIMIS |
|
|
Implementer openIMIS |
|
|
Developer openIMIS |
|
|
Swiss-TPH |
|
|
GIZ |
|
|
Architecture Constraints
The final architecture needs to consider the following constrains:
ID | Title | Description |
|---|---|---|
C001 | Focus on LIMCs | The architecture must consider that the client computer could be an older version with less computing power, disk space and older operating system/web browsers |
C002 | Costs | The architecture should not use components which will include any fee. Therefore, only open-source libraries, frameworks, etc must be used. |
C003 | Installation | The installation of the offline mode functionality should not include any manual labour from implementers or users. |
C004 | Configuration | The architecture must include a configuration which is compatible with the standard openIMIS config. |
C005 | Technology | The architecture must use and work with the current openIMIS modular version. It must use React and Python Django for the Front- and Backend |
Context and Scope
Business Context
The following context diagram shows a small abstracted illustration of the business context of openIMIS. To oversee the complete functionalities take a look at: https://openimis.org/workflows-and-functionalities
Technical Context
Artifact | Description |
|---|---|
openIMIS Server | Server Instance which runs as central node to host the web application and postgres database |
openIMIS Backend | The modular backend of openIMIS with a core module and multiple add-on modules providing business logic, data exchange and read/write accessibility to the openIMIS database. |
openIMIS Database | Postgres or MySQL Database to persist entered data from healthcare facilities and other users. |
Client Webbrowser | Browser instance of openIMIS user (eg. Chrome, Edge, Firefox, Arc, …) |
openIMIS Frontend | The modular frontend of openIMIS to view, enter, change data. Includes a core module and many add-on modules with different forms and search functionalities. |
Offline Database | Local database which is running inside the users webbrowser to store and queue entered data whenever the user is not connected to the internet. |
DHIS Server | Example 3rd Party Instance where openIMIS could be connected to exchange health data of insurees or healthcare facilities. |
Solution Strategy
The architecture of the openIMIS offline storage solution will be based on the concept of progressive web applications (PWA). The architecture was evaluated together with 2 other competitors. The evaluation showed, that this architecture would be the most suitable for implementing an offline storage solution. (To go through the evaluation look at MT-04 Evaluate Offline-Architectures.
Given the quality requirements above MT-05 Design Offline Architecture the strategy will include the following artefacts and concepts:
Implementation of an Service Worker in the openIMIS frontend to handle offline/online state changes as well as initial master data download and synchronisation.
Implementation of Dexie.js as local data storage solution. As its a lightweight database with an SQL Query Language and fast processing transactions. Comes with the implementation of all necessary CRUD operations and data encryption and decryption.
Implementation of GraphQL Actions to query master data and synchronisation options for offline/online sync
Implementation of an conflict resolution module in the openIMIS Backend to handle transactional conflicts with online changes.
Implement visuals for showing the current state of the application as well as of the synchronisation transactions and conflicts to handle manually
Implement a configuration to customize the offline mode per instance.
To further increase the performance of the web application we consider to store and request master data always offline. This would also support the execution time while the openIMIS Application is in Online-Mode.
Building Block View
Whitebox Overall System
Level 2
Artifact (openIMIS-…) | Description |
|---|---|
be/fe_js | The backend and frontend module used for the assembly. Needed to register and unregister modules, as well as main entry to the program. |
be/fe-core | The module includes components which are needed by all other modules like database connection, internationalisation and more. |
be/fe-insuree | This module includes the logic to create, read, update and delete insurees. The frontend uses react-components for forms and visuals. |
be/fe-claim | This module includes the logic to create, read, update and delete claims. The frontend uses react-components for forms and visuals. |
be/fe-policy | This module includes the logic to create, read, update and delete policies. The frontend uses react-components for forms and visuals. |
be/fe-* | All other possible modules of openIMIS which are implemented and can be registered. |
Level 3
Artifact (openIMIS-…) | Description |
|---|---|
ServiceWorker | This Artifact introduces a backround worker which is diconnected from the main frontend thread to perform asynchron actions like trigger synchronisation. |
localDB | The local Database implementation as well as the main interface to store and retrieve data from and to the storage. |
conflictResolutionComp | To handle local conflicts and show the connected states of the application and synchronisation to users |
offlineStatusComp | To show the current state of the application to users. |
offlineSyncComp | Handle offline/online synchronization for offline mode. Includes masterdata as well as transactional data. |
Runtime View
Initialisation offline mode
Online mode with offline-first queries
Offline mode
Conflict Resolution
Authentification
<Runtime Scenario 1>
<Runtime Scenario 2>
Deployment View
Infrastructure Level 1
Infrastructure Level 2
Cross-cutting Concepts
Conflict Resolution
Local Data Encryption
Architecture Decisions
Quality Requirements
Quality Tree
Quality Scenarios
Risks and Technical Debts
Glossary
Term | Definition |
|---|---|
<Term-1> | <definition-1> |
<Term-2> | <definition-2> |