Adventures in storing data for Wavefully
Adventures in storing data for Wavefully
This post recaps my recent struggle with building a database for my app, Wavefully. It isn’t a technical post about what databases are, or how to set up your own databases using tools like Realm, Core Data or Firebase. Those posts are coming, though!
You know when you hear parents say stuff like, “It’s a good thing you’re cute…” to their sassy kids? It’s like a thinly veiled frustration…but based in love? Well, coding feels like that. It’s torture when things are broken and confusing, and you’re surfing on rainbows when it all goes as planned.
My experience with Wavefully has been par for the course. This is my first true foray into development, period. I’ve hacked my way through some HTML and CSS over the years, but I’ve never considered myself a “coder.” You can imagine, then, that diving head-first into iOS development has been an ongoing learning experience full of anxiety, irritation, frustration and (thankfully, above all) elation.
Follow along with tips, tricks, tutorials and learnings from Wavefully’s development!
HOLD UP — What’s Wavefully?
In case you missed my last post on the subject, Wavefully is an app that I’m building. It’s a mindfulness app, with a wee bit of motivation baked in. The idea is simple, take a 10-second break to pause and breathe. At the end of the time, you’re left with an inspiring quote and a calm that transcends understanding. Okay…hopefully, you’re left with at least a smile. 😀
To my surprise, one of the most challenging tasks I’ve faced while building this app was actually adding the quotes to it. Quotes are hard-coded — users don’t add their own — so I needed to figure out how to store a bunch of quotes in the app.
A journey into databases.
Before we begin, I want to acknowledge that databases are confusing and daunting. I learned a bunch about them during this process and compiled those learnings into a silly but simple post. It’ll be published shortly!
I began by using a dictionary. In Swift, this is pretty much what it sounds like — a big ol’ digital book full of information. As the developer, I get to choose what the dictionary is named (in my case, Quotes), what kind of “chapters” it holds (single quotes), and what the contents of those “chapters” contain (the quoted text, the attribution, a randomized ID for the quote, and a way to tell if the quotes been seen by the user). This part was pretty easy! I hard-coded all of these quotes into the app and was able to easily grab a quote to show on the screen to the user. And then it hit me…
“But what if I run across a quote that I would love to add to the app?”
With my dictionary set-up, I’d have to open the project files on my computer and hard-code a new quote into the app. Then I’d have to export a version and send it to Apple for review. After a period of time (it could be an hour or a week), Apple might approve this new version of the app, which I can then publish to the App Store. Wavefully’s users could then open the App Store app on their phones and update the app…and boom! They finally have that one new quote!
Obviously, the amount of work that it takes to pull this off isn’t worth the reward of getting one new quote!
Instead, I started wondering:
“What if I could send quotes to the app at any time from a simple to use web dashboard that I could access from any device, anywhere in the world…without needing that whole Apple review process?”
To pull this off, I’d have to set up a database somewhere online and connect it to my app. Once connected, I’d have to figure out how to actually put quotes into the database, and I had no idea how to pull this off. So, I turned to Google. Overwhelmingly, the perspective I found said I’d need to create a second, totally new app 😱that I could use for writing quotes and adding them to a database. That app would create the quotes, and Wavefully would just show them. I could use any database for this, but most people recommended relying on AWS (Amazon Web Services).
After spending months on Wavefully, this news took the air out of my sails. I didn’t want to rely on another app for creating quotes! I didn’t want to build and maintain it! Above all, I hate typing on my phone. Spell check, auto-correct, and my fat fingers always mess up what I type. I’d hate for a user to load a quote and get a shock when my autocorrect changed “duck” to…well…you get my drift.
I turned to some developer friends for a second opinion. Generally, they agreed with Google… all but one.
Starting with SQL, ending with Firebase.
One friend described how he set up a simple server on AWS and used MySQL to add content to his app. He can add content from anywhere, and give permission to anyone he pleases. He had to write a custom API to connect his app to the server, and then the database, but that would still be easier than creating an entirely new app. This sounded great! It’s exactly what I needed!
AWS turned out to be a nightmare. For starters, here’s their home screen:
What’s a guy to choose?! Even with a series of well-documented tutorials, I was lost. It took me 2 weeks to get a server running and a database installed. Once I had it, I couldn’t figure out how to manually enter information into it! Suddenly, writing an API felt impossibly daunting. Again, I found myself defeated. I had wasted a ton of time and felt burnt out.
But there was one last idea up my sleeve: Google Firebase.
Firebase, my new love.
Firebase is Google’s answer to complicated databases. As with many things Google, it’s supposed to be one of the more accessible and simple options on the market. I thought I’d give it a try.
By the end of the month, I’d learned how to set up a form on an admin dashboard that allows me to add quotes directly to my database. Within the app, I figured out how to sync those quotes to a powerful database that I built into the source code, using a database tool called Realm.
HOT DOG! It works! When I first opened the app and saw a quote that I added through my portal, I teared up. I couldn’t — and still can’t — believe that I did that.
It took me over two months to figure out how to add quotes to a database and remotely load them into the app. Honestly, I’m not certain that I did it the “right” way…but it works.
That’s it! The app mostly functions as intended now. I have a few interface and interaction elements to add in, and then it’ll be ready for beta testing! If you want to join the beta, sign up here. I’d love to hear your thoughts. If you’re interested in following along with the development, I’ve made my Trello roadmap public.
More posts in this series:
It was difficult to find thorough, simple to follow documentation online for various steps of the process. So, I’m sharing my learnings here, with you. If my failures save you some time, then I’ll be over the moon! More importantly, if I can do any of this in a more efficient way, PLEASE comment!
More coming soon!
Follow our newsletter.
Sign up to learn more about the cool things that we’re finding online, inspiring quotes, articles and more!