DEV Community

Daniel Mayo
Daniel Mayo

Posted on

Building a Social Platform with FastAPI & Neo4j: Lessons from a Side Project

Firstly let me introduce the side project I'm working on. I'll keep it brief, because I want to get to the tech part of the discussion.

So, I see the direction that social media has been going lately and I don't like what I see. I won't go into details, but I know I'm not the only one.

Anyway, I thought it would be an interesting experiment / hobby project to try to create one myself from scratch.

So let's dive into how I'm building it, the decisions and challenges along the way.

1. AI-driven development

There's a lot of split opinions on how good AI is at coding. Or rather, I should say LLMs.

But right from the get go ChatGPT has been my trusty development partner. It came up with the initial name and concept, and helped me get started with the most basic version. Honestly I would have been too lazy / busy to start this project otherwise.

I will henceforth refer to ChatGPT and I as "we" 😁

Copilot is my second side kick. I'm a bit of a contrarian and I use Zed as my editor these days, which comes with copilot integration. I just don't like VSCode 🤷‍♂️

2. Database: Neo4j

First decision that I made was to use Neo4j for the database.

Why not just use a relational database I hear you cry?

Well, first of all a disclaimer: I work for Neo4j.

Secondly, a graph database is tailor made for storing and querying social connections. Not that I have any users to connect at the moment 😂

Thirdly, why not? For me it's more fun and easier to use. I do have an appreciation for Postgres, but I just find Neo4j more fun and freeing to work with.

Oh and there's a free managed version you can spin up very easily (that I helped build). This was the biggest thing for me on this project: cheap and easy.

Anyway, I'm not really here to promote Neo4j. That's just what I'm using. On to the next choice.

3. Backend: FastAPI

Since I'm working a lot with Python these days and I find it quite pleasant and easy to use, it was quite natural for ChatGPT to suggest a Python backend, specifically FastAPI.

I've not used it before, only Flask (which I'm not the biggest fan of).

ChatGPT created the initial version along with Poetry for dependency management and I gave it a spin.

I was instantly impressed. This is a very nice framework to use for getting started with. You can get something up and running super fast, while also supporting async requests, background tasks, and websockets for scalability.

Sold!

Why not Node.js or something like that? Well, I've used it before and honestly I wasn't a fan. I prefer JS/TS on the front-end. Just my preference.

I could have also used Go or Java or something else, but that sounds much less fun for getting started quickly on a new project.

4. Frontend: vanilla JS

So, at this point I have a working API that stores data in Neo4j. A headless social network if you will.

Now I could create an Android/iOS client, but that's not my thing. So web app it is.

I ask ChatGPT to knock up a quick front-end. We decide to avoid any heavy dependencies at the moment, so vanilla JS it is. No React etc.

We decide to use Tailwind for CSS styling. No Bootstrap, no component lib. A very natural and solid choice for quick iteration.

No Vite build or whatever. Just pure untransformed static files. The lack of build time or ceremony is very refreshing!

The first version looks terrible of course. But it works!

5. Auth

Okay, so it's time to add login capabilities.

I don't want to roll my own, I don't want anything heavy. I want easy, and free.

I decide to integrate Auth0 with Google OIDC as the one initial login method for now.

Not as easy as I'd hoped, but eventually after a lot of back and forth I got it to work.

6. Deployment Pt. 1: Render

We arrived on using Render.io to deploy to the world. It was quick, easy, and best of all free to get started.

It was pretty great for testing at first.

But there's a catch: it suspends when not in use and the cold start times can be 50 seconds plus!

I mean I don't blame them. You can upgrade to solve that problem.

But it bugged me enough that I wanted to look at other options. Which led me to...

7. Deployment Pt. 2: D.O.

I switched to Digital Oceans App Platform. For a relatively low monthly fee, it solved what I was looking for.

Compared to Render it was an absolute pain to set up.

Eventually I got it working though and now it's set up it's easy to use. I just git push to deploy.

8. Custom Domain

Okay, so I wanted a custom domain now. I wanted to use a .social TLD.

Of course my working title up until this point was already taken: ripple.social

However, rpl.social was free. ChatGPT encouraged me to search for existing Trademarks. This was a pain, but eventually I found a clash. No go.

Next up: ChatGPT suggested relay.social

Not bad I guess. But taken. Next it suggested RelayHub.social and RelayChat.social

Neither were amazing but they were free. I went with the latter. Only after registering did I realise it sounds like Internet Relay Chat (IRC!)

Oh well, it's not great but it'll do for now.

Naming things is really hard!!

9. Analytics: Swetrix

Now, I have no users. No big surprise 😂

I'm trying to get some, but without some kind of analytics I wouldn't know whether anyone is visiting or dropping off.

I wanted something cheap while being GDPR compliant and privacy respecting. Swetrix ticked this box and is pleasantly simple to use. It tracks stats anonymously, without cookies or PII.

As a bonus it comes with anonymous error reporting as well. Nice.

10: Current Status

Now that's where I am now. The app is very feature light, and very much a work in progress. Rather than focussing any more on making the design look less terrible, add features or polish, I thought I'd try to look for some users and get some feedback.

As Reid Hoffman said: "If you are not embarrassed by the first version of your product, you've launched too late."

Thanks for reading, well if you make it this far I'm impressed.

I'd love to hear about your own side projects.

What would you have done differently to me if you were in my shoes? Any tips or suggestions?

Any thoughts or questions about what I did?

Top comments (0)