Emergency Tech: Cross-Platform Decentralized Solution with Flutter

03 Nov 2023 Oleksii Kalashnikov, Oleksii Svitlychnyi

The Beacon Emergency Dispatch platform stands out as a cross-platform solution in the realm of Emergency Tech. Amidst the chaos of unexpected emergencies, the challenge lies not just in the immediate response but in the efficient coordination of available resources. Beacon addresses this by transforming every smartphone into a real-time alerting system, ensuring that the right help arrives when and where it’s needed most, optimizing human resources, and decentralizing emergency dispatching.

If our previous blog post acquainted you with its innovative functionalities, this entry promises a deep dive into its technical bedrock. From the nuances of cross-platform mobile development to the integration of diverse map services, we’re about to peel back the layers. Let’s begin with a high-level overview of the platform’s underlying architectural framework.

System Architecture: An Overview

Understanding the system architecture of a software solution provides insights into its design, functionality, and potential. The Beacon Emergency Dispatch platform, with its multi-faceted approach, serves as an excellent example of this. Let’s delve deeper into the design choices and architecture of this platform to understand its capabilities.

A Bird’s Eye View of the Entire System

Clients (Mobile & Web)
Users access the platform via mobile (Android and iOS) and web applications. Developed with Flutter, enhanced by Kotlin and Swift for specific tasks, they ensure a unified user experience.

Backend
Developed in Ruby on Rails and deployed via Docker, the backend is the heart of operations for the Beacon platform.

Storage
Data integrity is pivotal for Beacon. Here’s how it’s managed:
– Global Database (on AWS RDS for PostgreSQL): Holds most application data, excluding specialized and confidential information.
– Case Reports Database (also on AWS RDS for PostgreSQL): Houses patient records while maintaining confidentiality standards.
– Media Storage for Case Reports (on AWS S3): Securely stores patient medical images with stringent security measures.
– Media Storage (on AWS S3): Stores all other images such as chat attachments, map markers, or other non-medical media.

Third-party Services
Firebase Crashlytics addresses crashes, Google Analytics tracks user behavior, while PagerDuty along with NewRelic monitor the system’s health. The platform also integrates several map services, including Google Maps and OpenStreetMap, complemented by OpenTopoMap’s topographical data. Moreover, contextual weather updates via OpenWeather provide users with location-specific weather information.

Importance of Adopting a Modular Architecture
The platform’s design showcases a modular architecture, meaning each component functions both individually and as part of an interconnected system. This modularity offers scalability, eases maintenance, and ensures adaptability, making the system resilient to changing needs.

Multi-Platform Mobile Clients: Harnessing the Power of Flutter

In today’s digital landscape, ensuring an app’s presence on both Android and iOS is no longer a luxury but a necessity. With the ubiquity of smartphones and an almost equal split between Android and iOS users, a dual-platform approach becomes essential. The aspiration? Code once and deploy universally. This promise of cross-platform mobile applications is precisely what we aimed to fulfill, ensuring a solution for the two dominant mobile platforms… and perhaps even beyond.

Flutter: The Choice and its Reasoning

We’ve delved into the benefits of Flutter, and while there are many, here are a few key takeaways: it offers a unified Dart codebase, genuine native performance, customizable widgets, a swift Hot Reload feature, and robust community support. Interested in a deeper dive? Check out our dedicated blog post where we thoroughly analyze Flutter based on our research.

Integration of Native Kotlin and Swift Code: A Unique Blend

While Flutter, aided by Dart, addressed a significant chunk of our development needs, certain moments demanded platform-specific functionalities. To address these, we wrote functions in Kotlin and Swift, which could then be seamlessly called from our Dart code. This approach melded the strengths of Flutter with the native capabilities of each platform, ensuring that no unique feature was left unexplored. Moreover, we derived a Web application from the same unified codebase, a topic we’ll delve deeper into in the subsequent chapter.

Web Client: Beyond Traditional Browsing

In our exploration of Flutter, we discovered its potential beyond mobile to the web. With the same codebase for mobile, we effortlessly adapted it for web use. This not only streamlined our development process but also ensured consistent functionality and look across platforms. The efficiency, the reduced time to market, and the consistent user experience? That’s the beauty of Flutter for the web.

The Magic of Progressive Web Apps (PWA): Benefits and Real-World Implications

Progressive Web Apps (PWAs) are a transformative step in web development. Bridging the gap between web and mobile apps, PWAs offer the resilience of web pages combined with the user experience of an app. They’re accessible across browsers, can be saved to the home screen, push notifications, and even access device-specific features. For Beacon, adopting a PWA approach meant our web client could offer the same features as our mobile app, ensuring a consistent experience across platforms. When a fire service client sought a Windows app for alarm alerts, we proposed a PWA, which runs on Windows as a native app yet is browser-based. Both the web client and the PWAs that inherit its capabilities can work offline, which we’ll discuss next.

Offline Capabilities

Beacon maintains functionality even without an internet connection. While not fully operational offline, it leverages service workers and cached assets to facilitate specific offline tasks, automatically syncing them once reconnected. For instance, in areas with limited connectivity, a responder can update data offline, and the application ensures these updates are automatically synchronized when the connection improves. If internet access is compromised, Beacon can still relay vital information via SMS. In short, Beacon’s web client adeptly addresses the challenges of inconsistent internet access, guaranteeing continuous service.

Data Storages: The Pillars of Information

For the Beacon Emergency Dispatch platform, data is paramount. This solid data storage system ensures accessible, secure, and efficient organization of information.

Storage Types Overview

Beacon utilizes varied storage systems, each serving a specific purpose:
– Global Database: A main repository for most application data.
– Case Reports Database: Reserved for sensitive patient data.
– Media Storage: Divided into general media and medical records.

Global Database: The Central Hub

Hosted on AWS RDS for PostgreSQL, the Global Database stores most of Beacon’s application data. It is essential for functions ranging from real-time alerts to post-response analyses. It’s scalable, fast, and reliable, ensuring consistent performance under varying loads.

Case Reports Database: The Security Hub

Patient data requires maximum security. Hence, the customer has a dedicated database on AWS RDS for PostgreSQL solely for patient records. This ensures the confidentiality of data, fortified security, and selective accessibility.

Media Storage: Dual Strategy

Beacon’s media storage strategy is twofold:
– Standard Media Storage: Hosted on AWS S3 for general images and media like chat attachments and map markers.
– Media Storage for Case Reports: Also on AWS S3, this storage is tailored exclusively for images from patient medical records. It has enhanced security features, such as unique access credentials and temporary download links.

Beacon’s storage approach emphasizes reliability, security, and efficiency. Each storage type plays its part, ensuring seamless operation and effective emergency coordination.

Backend: The Brain Behind Operations

The front end often takes center stage due to its direct user engagement. However, the crucial gears and levers operate in the background. Picture the backend as a ship’s engine, powering every motion. For Beacon, it’s the silent force ensuring everything from real-time alerts to in-depth post-response analyses operate flawlessly.

Core Component Overview

Beacon’s backend comprises specialized components. Here are a couple of key ones:
Controllers: Often referred to as the information gatekeepers, controllers process incoming requests, make sense of user commands, and ensure appropriate actions are taken. They handle everything from user logins to dispatching emergency alerts.
Realtime Services: In the realm of emergencies, timing is paramount. These services provide instant communication, be it sending out alerts or updating user locations, all powered by the WebSocket protocol.

Maps Integration: Navigating the Terrain

Given Beacon’s mission to efficiently coordinate emergency responses, the platform needed precise and reliable map integrations tailored for both dispatchers and field responders.

Mapping Choices: Balancing Cost and Quality

Mobile users often look to industry leaders like Google Maps for quality. However, for our web-based dispatchers, we sought a solution that combines affordability with precision.

Comparing the Cartographic Giants

– Google Map: Used in Beacon’s Android and iOS applications, Google Map excels in accuracy, especially in cities.

Beacon Emergency Dispatch Mobile Maps

– OpenStreetMap (OSM): Chosen for the web client aimed at dispatchers, OSM is a cost-free alternative to Google Maps.
– OpenTopoMap: Partnering with OSM for the web version, OpenTopoMap delivers key topographical insights, allowing dispatchers to switch between standard and topographical views.

Beacon Emergency Dispatch Web Map

Leveraging the synergy of OpenStreetMap and OpenTopoMap, we devised a cost-effective alternative to Google Maps for our dispatcher web clients. This strategy holds particular relevance as the web interfaces typically require a heightened engagement with map services, in contrast to the more streamlined map interactions on mobile devices used by field responders.

Map Driver: The Unifier

With diverse map services integrated into Beacon, the Map Driver is the unsung hero that ensures smooth navigation. It abstracts the intricacies of different map providers, offering a unified interface, whether you’re on Google Maps, OpenStreetMap, or OpenTopoMap.
Regardless of the underlying map source, it guarantees users a consistent experience, be it for location lookups, route plotting, or area highlighting. Besides enhancing user experience, the Map Driver also paves the way for flexibility in potential future shifts or additions in map providers. For a visual representation of how the Map Driver integrates into the broader mobile application architecture, refer to the following diagram.

Twilio Integration: Empowering Beacon’s Communication

Beacon integrates specialized third-party tools like Twilio to enhance its communication capabilities in challenging connectivity areas. Acting as a safeguard, Twilio directly supports Beacon’s communication layer, intervening when typical internet methods fall short. Here’s how Twilio supports Beacon:
– Reliable Alert System: In areas with inconsistent internet, Twilio ensures that Beacon dispatches vital alerts via SMS, keeping emergency responders informed even if other communication channels are unavailable.
– Enhanced Account Security: Through Twilio, OTPs for authentication are transmitted, being sent via SMS or email as needed, promoting both security and user convenience.
– Flexible SMS Communications: Beyond automated alerts, Twilio provides the ability for direct SMS communications between responders and dispatchers, proving invaluable when regular data connectivity is compromised.

Thanks to Twilio, Beacon’s communication remains resilient, adeptly handling the unpredictable challenges that emergency situations can present.

Docker: The Localized Solution for Global Challenges

In the intricate world of Beacon, addressing the needs of our customer’s clientele presents unique challenges. Some clients have individual requirements, sometimes steered by regional regulations or specific organizational mandates. A majority of the customer’s clients benefit from Beacon’s logical data center approach, where data is logically isolated yet physically co-located on our customer’s global server. This design ensures each client’s data remains distinct, providing a seamless experience without the overheads of multiple physical deployments.
Certain challenges go beyond the scope of logical segmentation. In areas with stringent data localization laws, there’s an imperative to keep data strictly within their borders. For clients in these jurisdictions, deploying a local instance of the backend server, instead of utilizing a global server, becomes crucial. Docker serves as the solution for easy deployment and smooth updates. When integrated into a Docker container, Beacon can be readily deployed on local servers in these areas. When Beacon undergoes a backend modification, the update process involves merely refreshing the Docker container, ensuring the regional version remains up-to-date without affecting any specific customizations.
By combining logical data centers and Docker-focused local deployments, global data management challenges can be adeptly navigated, ensuring each client’s unique requirements are met without compromise.

Conclusion: A Beacon of Technical Robustness

In our exploration of the Beacon Emergency Dispatch platform, we’ve harnessed Flutter for adaptive cross-platform mobile app development and crafted PWA applications for enhanced adaptability across different platforms. Beacon’s backend assures real-time responses, with expanded functionalities due to integrations with third-party services. These insights hint at the thoughtful application of technology behind Beacon, and they might provide compelling reasons to consider such expertise for any project you might need.

Ready to start the conversation?