Building Offline First Mobile Apps - The Mechanics | App Modernization

Table of Content

    A common problem many of our clients face these days is deciding which business cases should be digitized as mobility solutions and which ones as traditional web platforms. When clients choose mobility, they need to take further decisions to decide if the app platform should be built as a purely online platform or as support for offline functioning or both. If the business case demands an offline-first mobile app platform to be built, then clients need to brace themselves for technical complexities, associated costs, and the time it will take for the platform to mature and become robust to be able to handle every possible scenario.

    Having worked in the enterprise mobility domain for the last 9 years, we, at Neebal Technologies have seen almost everything around the use of enterprise mobility with respect to solving customer business problems. We have been riding the enterprise mobility wave which has swept the enterprise and start-up landscape for almost a decade now. I believe this gives us the credibility to write about our experiences in mobility tech.

    In this article, I will focus on the pain points that organizations face while building Offline First Mobility platforms, how our experience of building them led to us conceptualizing and building our Offline Mobility Platform named Blynk. I plan on converting this into a series of posts that will cover the finer details of everything that goes into building offline-first mobile apps.

    Offline First Mobile Apps

    Let me begin by explaining what offline-first mobile apps are. Mobile apps are a great fit where business users are constantly on the move capturing data in real-time. It could vary from performing business transactions, to making decisions, and to triggering actions which set in motion dependent business workflows. But what if business users are working in areas of poor network connectivity and intermittent network? An offline-first mobile app allows users to perform their day-to-day business on mobile apps without the need of being connected to the internet. Executives that are constantly on the move, field force users like medical representatives (MRs), and sales teams working in villages (especially in the Agro sector) are some examples that come to mind.

    So, what are the typical problems associated with Offline-First Mobile Apps?

    • Support for fire & forget transactions (i.e. users are not bothered if transactions are synced) >> asynchronous automatic data synchronization with the server

    • Synchronization of new data updates from Server - master & transaction

    • Differential data sync - sync what has changed to reduce the data packet size

    • Handle intermittent network connectivity with support for pause and resume of data sync between servers

    • 0% data loss because of intermittent network connectivity

    • Effective data synchronization protocol to track server and client acknowledgement

    • Robust retry mechanism to avoid data duplication for transactions

    • Data Security - both at REST and In-Transit

    • Compliance requirements like HIPAA from a technical implementation perspective, especially when clients are dealing with PHI (Patient Health Information) records

    Neebal Solution - Blynk a truly Offline-First Mobile Platform

    Here are a few design decisions that we took to solve the above problems when we built Blynk, Neebal’s Offline-First Mobile App Accelerator Platform.

    • Queue for asynchronous processing

      • JMS compliant queue

      • Default support for AWS SQS to focus on core business functionality rather than building & maintaining web scale queueing infrastructure

    • REST APIs + JMS Compliant Queue
      • Transactional data was still to be persisted with APIs following REST standard

      • Enabled auditing and logging of processing of asynchronous data received 

    • Multi-threaded listener pattern for SQS processing

      • Dynamic & configurable listener configuration to horizontally scale queue processing basis user transaction load

    • Offline data storage in mobile using a relational database

    • Direct upload of media to file servers

      • Eliminate server platform as a proxy for pushing media, reducing the complexity associated with large size data transfers

    • SSL based communication for data in transit

      • Use of SSL for all communication between client & Server

      • SSL pinning to prevent a man-in-the-middle attack

    • Encryption of data for data at rest

      • Datastore in AWS SQS/JMS compliant queue in an encrypted format

      • Encryption of offline database maintained on the mobile -

    • Dynamic key generation

      • Native library implementation for dynamic key generation for encrypting data payload

    • Data content-agnostic payload transfer 

      • Data payload transferred as a zip file

      • Large chunk of data split into multiple files

      • Each file is password protected by the bundle

      • Guarantees data compression with pause and resume support for patchy network conditions

    • Android/iOS SDK for handling complexities of offline data sync, retries, exception handling which can be integrated by any mobile app meant to perform offline data transfer

    As I mentioned earlier, I will cover the finer details of the above-listed problems and the design decisions we took to solve them in a series of posts.

    Offline-first Architecture

    Basis the above design decisions, we came up with the following high-level server architecture for Blynk.

    Blynk Architechture

    Not all of the design decisions listed above were made on day one. Few of them were discovered as part of our experiences of deploying the platform for our customers. The platform has evolved and is now on its own journey towards maturity.

    Industries where Neebal has introduced Offline-First Mobile Apps via Blynk

    Over the years, we have worked with multiple clients on numerous business cases to build offline mobility platforms

    • Digital Diagnostic Device Platform in Pharma and Healthcare sector

      • Enables patients to get real-time feedback on mobile on their usage and dosage performed via BLE enabled diagnostic devices

    • Field Force Management Platform in Pharma, Agro, and Retail sectors

      • Used by sales reps constantly on the move in villages and small towns interacting with their end customers, retailers, patients, and farmers

    • Digital Prescription Platform in the Healthcare sector

      • Enabling doctors to write prescriptions on paper with a digital pen without being connected to a system with internet with a daily sync

    In our experience, we have noticed that Offline First Mobile App platforms have common patterns of problems and subsequently a common set of design decisions and architectural patterns are introduced to solve these problems. Once the identified pattern is systemized, it can be used as a framework to solve almost all offline business cases.

    There is no denying that building offline-first mobile apps is challenging. I believe that we have mastered building them with the knowledge gained over a decade of working with different business problems with the sole focus of helping our clients achieve their full potential.

    Blynk also powers our own product, H2O Works - a platform for field force management driving secondary sales for Pharma, Retail, OTC, and Agro businesses. All the offline-first apps that we build for our customers are based on Blynk. At the same time, we ensure that our customers are not bound to the platform code since its code is open for modification if they wish to maintain and extend the same on their own.

    About the Author: Priyadarshan Patil is the Chief Operating Officer at Neebal Technologies. As our COO, he strive towards streamlining delivery processes and their implementations while nurturing relationships across Neebal's customers.

    Topics: App Modernization