Santa's Little Helper

Santa's Little Helper
Photo by hue12 photography / Unsplash


It is approaching the end of the year. My family's birthdays, anniversaries, and of course Christmas are heavily concentrated to September on. That means the annual nagging of family members for birthday and Christmas lists has just begun.

To streamline this, I decided to build an app. The concept would be simple: allow an individual to create a list of ideas and links. Other family members should see the list and can buy things off of it. All family members, except the person receiving the gift, can see it was already purchased to prevent getting duplicates.

Building it

DISCLOSURE: I am a MongoDB employee. All views and opinions expressed are my own.

Now having used MongoDB Realm App Services (previously MongoDB Stitch) regularly, this sounds like a slam dunk in terms of offered functionality. It provides the username/password authentication engine, it provides free app hosting, and it has a rules engine that will make the business logic trivial for who can see and edit what. On top of that, for the scale of this app and my family, the MongoDB Atlas M0 Free Tier will work just fine, meaning this will be free.

I also decided it would be good to play with Blazor a bit more. It will compile down to just Web Assembly and JavaScript so I can publish it entirely in the free hosting without needing a server.

The prereqs were simple:

  • I spun up a MongoDB Atlas cluster.
  • Next I created a Realm app.
  • Turn on web hosting in the Realm app
  • Within the Realm App I turned on email/password authentication and manually created a test user
  • I created rules for a collection and sants.lists collection

The rules were simple. In the gifts collection, if it is your gift, you can insert docs and modify any field except purchasedBy (meaning you will not know if it was purchased). We do this with setting the rule's "Apply When" to { "ownerId": "" } which simply means every document in the gifts collection should have an ownerId field and it's value must be that of the logged in user's ID. Since Realm handles auth for you, this is simple and cannot be spoofed.

The next rule says others can modify only the purchasedBy field for gifts, meaning people can sign out that they bought it, but cannot do anything else to items on other people's lists.

Login Screen

That's all I needed to do in the back end. Now I just needed to shift to the Blazor work.

Realm does not have an SDK for Blazor. Rather than building my own, I just wrote a JS Interop function to act as a shim of sorts. That will relay all calls from the Blazor C# code to the normal Realm JavaScript SDK and pass it back. Blazor automatically serializes/de-serializes the objects to C# classes when you do this so it isn't that much of a hack.

I built a simple UI, wrote all my CRUD operations in Realm functions which the shim function calls, and that was about it.

Last step is to run dotnet publish -c Release and upload the contents of the wwwroot directory to Realm hosting.

How's it work

The GitHub repo is available here.

It was about this point my sister let me know an app called Elfster exists. But that really isn't the point, is it? Learning and building is the point. The completed app is just a byproduct.

Login Screen

List or Event Management

Handle Your Gifts

View Other People's Gifts