MT-05 Design Offline Architecture

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

Role/Name

Expectations

Communication

User openIMIS

  • No negative impact during usage of openIMIS

  • Reliability and Visibility of the current state

  • User Manual

Implementer openIMIS

  • Enhancement of reliability and performance using openIMIS in areas with unstable internet connection

  • Clear introduction into the feature to use in national implementations

  • Full functional new feature

  • Presentation of final version

  • User Manual

  • Configuration Manual

  • Jira Tickets

Developer openIMIS

  • Easy integration and local usage of feature

  • Fitting into the current architecture

  • Jira Tickets

  • Project Documentation

  • Git PRs

  • Developer Manual

Swiss-TPH

  • Functional feature for core openIMIS

  • Following the development standards for openIMIS

  • Direct reporting

  • Jira Tickets

  • Project Documentation

  • Git PRs

GIZ

  • New feature for the core

  • Enhance openIMIS for further use in LMICs

  • Developer Calls

  • Project Documentation

Architecture Constraints

The final architecture needs to consider the following constrains:

ID

Title

Description

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

context_openIMSI.drawio.png

Technical Context

tech-context.drawio.png

Artifact

Description

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:

  1. Implementation of an Service Worker in the openIMIS frontend to handle offline/online state changes as well as initial master data download and synchronisation.

  2. 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.

  3. Implementation of GraphQL Actions to query master data and synchronisation options for offline/online sync

  4. Implementation of an conflict resolution module in the openIMIS Backend to handle transactional conflicts with online changes.

  5. Implement visuals for showing the current state of the application as well as of the synchronisation transactions and conflicts to handle manually

  6. 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

context_openIMSI-openIMIS-Backend-L1.drawio (1).png

Level 2

context_openIMSI-openIMIS-back-L2.drawio (1).png

Artifact (openIMIS-…)

Description

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

context_openIMSI-openIMIS-back-L3.drawio.png

Artifact (openIMIS-…)

Description

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

  1. Initialisation offline mode

image-20250711-134517.png
  1. Online mode with offline-first queries

image-20250711-134957.png
  1. Offline mode

image-20250711-135516.png

 

  1. Conflict Resolution

 

  1. 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

Definition

<Term-1>

<definition-1>

<Term-2>

<definition-2>