We need to serve the Internet offline

Designing offline-first web applications has long been a central technical concern for the CHT. Medic started using couchDB in 2010 for its great sync capabilities, and I’ve benefited greatly from following the conversation on offline-first design patterns. One of the early contributors to the CHT went on to co-found http://hood.ie, along with Alex Feyerke who in 2013 wrote this great A List Apart article on offline first. Not long after that Google started more heavily promoting Progressive Web Apps, which includes a focus on supporting offline first–their PWA resources are great.

From time to time I come across older and newer articles on the topic, and thought it would be nice to have a Topic on the CHT forum to share them. The most recent one that came to my attention discusses peer to peer sync and Tangerine, data collection software which has been used quite widely by people we know at RTI (more in education than in health). Tangerine has a lot in common technically with the CHT Core Framework and I thought the article was pretty cool.

1 Like

Dear @isaacholeman ,

Thank you for your thoughts. This indeed is very interesting and important for us as well. We want to be able to sync two devices (peer to peer sync). That are not connected to the internet.
The idea is of a tablet in a remote outpost without internet connection. Updates are brought and recorded data is pulled from the device during a regular physical supervision, by using a second device.
This could use bluetooth or wifi-direct for exchanging files or direct sync of couchDB.

Do you know by chance if this could be implemented to CHT at some point?

@raf - Currently the CHT is set up for a server ↔ client architecture in which the after client has synchronized the first time, the client can then operate for minutes to months with out Internet. This is what we mean by “Offline First”.

While the CHT does not support client ↔ client sync, we have experimented with a fully offline server set up. In this configuration, a remote outpost would have the minimum equipment to deploy a viable CHT server, but would not need the Internet to work. When ever the client, a tablet in your case, comes with in range of the outpost, sync could occur. Otherwise, both the client tablet and the server could continue to operate independently until sync happens.

Please review our documentation on this topic as well as a proof of concept forum post. However, please note that this is at an experimental stage and not supported for a production environment:

This is not meant for a production CHT instance. Support may be added in the future an offline CHT server in a production environment.

1 Like

@mrjones Thank you very much explaining this. I think it would be rather complex to set up an offline CHT server for the purpose of updating devices that have no internet connection.

Is it possible to directly work at CouchDB level? The idea would be that the database of an updated device, that is brought to an outpost without internet, gets replicated into a field-tablet. I have read some people wanting to replicate CouchDB databases from one device to another, but there is little information on the internet.

Do you think it is technically possible and reasonable to develop such a feature for CouchDB and would this solve our issue?

@raf - Yes, it is a commitment to deploy a fully offline CHT instance. While we want to document the technical process to do so, we want to ensure implementers are successful and appreciating the technical skills needed for the task via our docs and forums.

I can’t speak to the specific complexities of a custom CouchDB solution having never written or researched such software, but I suspect you would be better off adopting an off the shelf solution. One such solution might be OpenMRS which has server software intended run on the desktop. While it would still require a server, thus not support your desired fully peer to peer model, it might be able work in a fully offline scenario. Their wiki includes content about the realities of this.

Best of luck!

@mrjones - Thank you again. We will stick to CHT, it meets our requirements much more that openMRS.
What if we lowered the bar a little bit? We want just pull down the reports from an offline device, copy it on another device (or external harddrive) and the upload this file to CHT server.

Is that possible? I have build an app based on our configuration but I saw no option to extract the data (or to logout).

@raf - I think the lowering the bar as you described is actually back to where we started - a fully offline CHT deployment :wink: . While not a bad thing, it is as easy or hard as described in our docs and also, as already mentioned, an unsupported deployment approach for a production CHT instance.

I would not let this hinder you though! If you have the technical skills, you could approach the “pull down the reports from an offline device, copy it on another device” part as an Android client and the “upload this file to CHT server” part as an offline instance of the CHT. By setting up the simplest of test deployments in a home lab or using cheap cloud compute instances, you could see how viable your idea is.

While Medic doesn’t support using subsets of our tech stack in production, everything is very intentionally open source. If you can figure out how to re-use subsets of the technology, please report back - we’d love to hear about it as would others!