Building beyond one app
Accumoo needed a backend. I decided to build one that could support future Mohojo Werks applications, as well.
The idea is one account across multiple applications, with application-specific authorization and data. Shared authentication gives me a common foundation, while each application keeps its own business rules. Accumoo uses this backend for its iOS and watchOS apps (and, one day, Android), including synchronization Sync (synchronization) sends changes from your device to Mohojo Werks’ servers and brings those changes to your other devices when they sync. This keeps your Accumoo data up to date across devices. across devices.
I’ve written about why I chose to build my own backend. In this first post, I want to bring those decisions together: what the business needs, why Rails works for me, and why I chose to take on the responsibility of maintaining the backend.
Owning the backend means owning the work that comes with it. Hosting, email, security, testing, and maintenance are all part of that decision.
What the business needs
I need the backend to support 3 things:
- Shared authentication, application-specific authorization. Users should be able to reuse their Mohojo Werks account as more applications become available. The backend still needs to enforce access and business rules separately for each application.
- Different clients, consistent business rules. Accumoo’s iOS and watchOS apps have different interfaces, and Android is planned. I want these clients to use the same backend, with server-side validation and authorization enforced regardless of which client makes the request.
- Multi-device synchronization. Progress recorded on one device needs to reach the user’s other devices, even when they aren’t all online at the same time. Accumoo saves changes locally first; the backend gives the devices a place to exchange accepted changes when they connect.
The next decision was how much of this I wanted to build and maintain myself.
Why I decided to own the backend
I wanted control over the application logic and the API contracts my clients depend on. I can define the behavior, test it, and change it as the applications evolve.
I control when I deploy the backend, but users decide when to update their apps. I need to introduce changes while preserving the contracts that older supported clients still use. Owning the API gives me control over how I handle this compatibility.
Building the backend myself still leaves room for managed services. The infrastructure can come from providers I choose, while the application logic stays in a codebase I control.
The tradeoff is the ongoing work. When the backend needs a fix, a security update, or a change to support a client, I’m responsible for getting it done. My next decision was which framework would make this practical to build and maintain.
Why Rails works for me
Familiarity. Rails is what I do for a living. I knew I could get up and running quickly using it.
Rails brings simplicity and rapid development to the table. Other frameworks can meet these requirements, too. Rails gives me an established way to organize the work through convention over configuration. It makes many of the routine decisions about naming, structure, and how components fit together, so I can spend more time building application behavior. I still need to design the application, but I don’t have to make every structural decision from scratch.
Testing is another reason. With RSpec, I can test individual operations and exercise the API through requests, including failure cases. Rails has a mature ecosystem with established tooling and documentation. This matters for a backend I intend to maintain across multiple applications.
Rails provides the application framework. I still need to choose a database, email delivery, and hosting providers, and decide how to organize the application’s behavior.
Room to grow
I keep application-agnostic code, such as shared authentication and common data models, separate from application-specific code. Adding another Mohojo Werks app should let me reuse the common pieces while keeping its business rules separate from Accumoo’s.
Within an application, I use a command-driven approach to organize individual operations. The aim is to keep changes focused and testable as I add features, rather than make every controller responsible for more business logic.
As usage grows, performance still needs to be measured. Keeping the code organized makes it easier to isolate bottlenecks and change the parts that need attention.
What comes next
This first installment covers the decisions behind the backend. The following posts will explore how I organize application-specific behavior, handle shared authentication and authorization, evolve API contracts, and support multi-device synchronization.
Next, I’ll look at how one account works across applications while keeping authorization and data application-specific. Database, email, and hosting choices will be covered in the separate infrastructure series.