I have wanted to build a social network for 8 years, but it was much harder to make software for the web back then. Also, 8 years ago, I was not even a software developer yet, so there is that. But now I am (thanks freeCodeCamp.org!), and we are living in the easiest time to be a software developer since Jeff Goldblum uploaded a virus to an alien mothership.
The time was kind to my idea of what a social network should be too. It aged well, and now it's time to uncork it. I am building Quid Sentio, a shareable personal journal. I am not calling it a social network site, but it is. Well, it will be. It's just the basics now but open in public beta in the hopes someone will care.
What I am building now is much more mature than what I envisioned back then. The core idea is the same -- keeping in touch with real friends, the closest friends and family-- but the foundation is much more robust these days. In the meantime, Path has come and gone, people saying they have quit Facebook have come and gone, data leaks and privacy abuses have come and stayed.
I want to build Quid Sentio upon the principle of privacy. Privacy as freedom from being observed. From being observed by non-friends, from being observed by companies, from being observed by people who bought your data in the deep web after a database leak.
The first two are just consequences of design and business choices. Adding a little bit of friction for adding friends -- so no one can spam-add all their contact list; keeping shared posts visible only by your direct friends -- so no virality or friends of friends stalking you. A subscription-based business model -- so no ads, no invasive tracking. The third level of privacy is not that simple.
Cybersecurity is one thing that gets harder and harder to do in software development. At the same time, services that do it better than me are more accessible. This is the first reason why I decided to build my project using other people's infrastructure.
The second reason is that I want to limit how many things I have to juggle in my mind while building it. I read in Sapiens that the Cognitive Revolution started 70,000 years ago. I am pretty sure it ended when I made 40. Some things look attractive from afar, but I can pass without them, and I am happy enough just hearing people talking about it. Things that fall into that bucket are Finnegans Wake, EVE Online, Dwarf Fortress, Vim, and Redux. Other things I cannot pass by without, and I have no idea how to do it myself.
The inevitable implication is that I had to find other people to do my job for me. I wanted to focus on building the UI, creating the application logic, designing the experience that would make my product unique. Not the devops, not the infra, not the data plumbing, none of those solved problems. I found people that do these better than I could possibly ever do in Netlify and FaunaDB. There is also other software taken for granted that are worthy, but not newsworthy at this point. Like Stripe and the plethora of open-source software that are the buried giants whose shoulders I am standing on while pretending to be in a mountain that I climbed all by myself.
Economics teaches you about comparative advantage. People in those companies have the advantage of being smart; I have the advantage of using their service's free tiers. Not sure I got that economics thing right, though.
Still, just like Panama hats from Ecuador, they are great things. They are powerful ideas, implemented, and popularized by great companies that I am using to build mine.
Netlify Build and Netlify Functions
Serverless is great for its smaller upfront costs (for low traffic, you are usually still in free tier range) and zero infrastructure management needs. Pay-as-you-go is a risk if you go too fast, but that’s not something I am expecting. With Netlify Functions encapsulating the not that simple AWS Lambda Functions, it has the extra bonus of keeping me away from the AWS Management Console interface.
I have a fast CRUD app deployed in my domain, with minimal cognitive overhead. Perfect for me.
I have a safe, reliable, and fast database, with minimal cognitive overhead. Perfect for me.
update: In the first version of this post I was using Userbase as authentication solution. Since then, I decided to concentrate more on FaunaDB tech, including user authentication that is built-in in FaunaDB.
Putting everything to work
Quid Sentio core entity is the journal entry. An entry can contain text, one emoji selected from 15 options, up to 12 activities selected from 132 options, and a mood number selected from a range from -100 to 100. This data looks like this for the user:
The entry data is pretty suitable for a JSON structure, as I have to fit all of these, with its inherent grouping, in one database item. All images are SVG that I keep in my codebase so I just need to store the emoji or activity name.
Another advantage is that I can -- and I will -- add more types of content that the user can add to an entry. Audio for voice records is next in line. Probably image, videos, maybe stickers too. The flexibility of adding more properties to an entry while keeping it backward-compatible comes much more naturally to NoSQL.
Quid Sentio is also social. The user creates an entry in their journal and can then choose with whom, among their friends, they want to share it. The user will also view all of their friends’ entries that were shared with them.
I keep the user’s list of friends as one of the profile properties that I keep in a "Users" collection in FaunaDB. After user authentication I can access it and then I can keep it in the state of my application. It is basically a list of userIds, so no big deal. The tricky thing is to make the request that returns only the entries from those friends who are authorized to be seen by the user.
This is where FQL shines. FQL is FaunaDB’s own query language, but I could use GraphQL (also supported by FaunaDB) with similar results. I can easily create a query from a Netlify Function that only brings the authorized entries without the need of writing a lot of code with the logic required to not expose unauthorized entries to the client. So it ends up being pretty fast and simple to get the user’s friends’ entries and show this:
I had many technical obstacles between me and the social network that I wanted to build. Then modern services started to arrive, one by one, and, with more ease than expected, I got it done. I create-react-apped an app, deployed with Netlify, wrote Netlify functions for the basic operations, integrated with Fauna's NoSQL serverless database, including its built-in user authentication, inserted a Stripe handled checkout page and voilà. The only thing in front of me now is my vision. And I have all my cognitive resources preserved to reach it. Or to be consumed trying to write smart comments on Hacker News. Only time will tell.