Protecting The Oceans
WildAid is a conservation group whose Marine Program preserves the oceans by helping local agencies enforce regulations. The program aims to build effective, well-enforced marine protected areas by deploying new technologies.
For this year’s MongoDB.live conference, we wanted to go beyond our usual demos to showcase our new features in the context of a real-world application. Meanwhile, WildAid needed an application with features that are a core part of MongoDB’s unified data foundation. It was a great match. We set out to build a real-world application using MongoDB which allowed us to do something good at the same time. The resulting application is open source, so anyone can get it and see exactly how a real-world application uses MongoDB.
We started to hold regular meetings with WildAid volunteers to build an application that would serve their needs. One of the biggest needs for officers is safety. “The job of a fisheries officer is challenging,” said Bob Farrell, a former fisheries enforcement officer and currently an enforcement consultant for WildAid, when asked to describe his job. “We literally jump from one boat to another and we don’t always know what will happen when we get on the fishing boat. Safety is a big concern for us.”
With this in mind, we started designing O-FISH (Officer Fishery Information Sharing Hub), a mobile app that would let officers access existing information about a vessel before boarding it.
From Soggy Paper to Mobile Data
“After boarding,” Bob told us, “I collect information to make sure they are operating by the rules.
As I collect all the information on things like proper licensing, verifying the catch; I usually have to write things down on a piece of paper. I might even make notes on the back of my hand.”
A sample paper form
Hearing this, we decided to modernize this paper-based system and help officers write boarding reports directly on a mobile app.
Early design for mobile app “notes” page
A big hurdle for entering and accessing data in a mobile app while at sea is that officers who inspect ships often do not have service. With MongoDB Realm, we did not have to add a lot of code to handle offline workflows – MongoDB Realm syncs data from mobile devices to an Atlas cluster and back automatically, as soon as a device comes back online.
A fully functional offline mode also allows officers to access the entire database of records when needed. This allows officers to assess the risk they are taking as they approach a vessel for boarding. Overall the mobile app we designed at this point takes care of digitizing and synchronizing individual records for officer use – allowing officers to work offline when needed.
On top of the mobile application, the O-FISH project also has a Realm serverless web application which seamlessly visualizes and extracts information from the data stored in Atlas. The web application allows users to search for exactly what they want to see, delivering relevant results using Atlas Search. Under the hood, Atlas Search uses Lucene’s powerful fulltext search combined with faceting, fuzzy matching, highlighting, and relevance scoring that can include numbers and geospatial data.
Atlas Search allows users of the application to explore data, MongoDB Chats turns that data into beautiful and informative visualizations. Embedding these Charts into our web application is particularly easy with the new Charts SDK which gives us the ability to control the size, theme, filters, and refresh behavior. Charts also makes it easy to change visualizations, which are automatically updated in the application.
All the application’s features use the same data in a single Atlas cluster. Having a unified data platform saves the developers time as there were fewer parts to create and maintain. It also saves WildAid money and time – time that they can now spend making an impact.
However, it’s not only the data that is unified – security is as well. Realm authorization means that users only see the data they’re supposed to, no matter what part of the application they are using. For example, the same chart in the O-FISH web app will show different data for different users depending on which data they are allowed to view.
Using the Realm serverless platform eliminated the need for a web server. We made heavy use of functions and triggers to power the O-FISH web application’s functionality. For example, when an officer attaches a photo to a record, Realm synchronizes it to Atlas. The photo ends up inside the Atlas database, which is not optimal.
So we wrote a trigger that fires whenever a record is inserted into Atlas. The trigger calls a function to upload data in the “picture” field to an S3 bucket. Then the trigger updates the Atlas document removing the photo, and storing the S3 link to retrieve the photo in the “pictureURL” field.
The app we built is open-source and you can build the entire O-FISH application — the web and mobile applications, the Realm synchronization and serverless web functionality as well as the database — all for free, complete with sample data. By building and looking at the code, you can see how the features that power MongoDB’s unified data foundation all work together in a real-world setting.
If you want to help protect our oceans, join us. Whatever your experience level, you can be a part of the community: visit our Code For Good site (http://developer.mongodb.com/code-for-good), connect with other developers, and help protect our oceans by contributing to the open source O-FISH project (https://wildaid.github.io/).