How does FerretDB work?

In recent weeks, I have come across FerretDB on multiple occasions, and I thought why not just get a closer look on the topic. I took a particular interest in it (FerretDB) as it is a MongoDB implementation, on top of my favourite database PostgreSQL.

While I do have high-level thoughts on how I would go about building MongoDB on top of Postgres, I wanted to confirm, validate, and learn how the FerretDB team has been doing it.

FerretDB (previously MangoDB) was founded to become the de-facto open-source substitute to MongoDB. FerretDB is an open-source proxy, converting the MongoDB 5.0+ wire protocol queries to SQL – using PostgreSQL as a database engine.

At a high level, FerretDB is a proxy, which implements MongoDB Wire Protocol that MongoDB clients speak. After establishing the connection with MongoDB clients, it translates any query sent by MongoDB clients to the SQL queries Postgres understands.

In the recent release(0.5.0) of FerretDB, it is also possible to use it as a library rather than as a proxy. FerretDB as a library helps in reducing one network hop, which leads to better performance. It is only possible for applications that are built in Go since FerretDB is implemented in Go.

Below are some of the tweets from people on this article. If you find this article useful please share and tag me @shekhargulati

Continue reading “How does FerretDB work?”

Architecture of Open source systems #1: Umami: An open source Google Analytics Alternative

As I have gained experience building software I have realized that most important skill I can build is understanding existing code bases. You can learn about a new technology stack or framework much faster by reading existing code base that uses those technologies and trying to build an existing app in a step by step manner. Today, I wanted to learn how to build a web analytics service like Google Analytics. Google Analytics is the most widely used web analytics service on the web. I found a popular open source project umami.

Umami is a simple, fast, privacy-focused alternative to Google Analytics.

We will first start by understanding the project from outside in and then we will build the backend of umami in a step by step manner.

Tools Used

  • VS Code
  • Node.js
  • DBeaver for creating ER diagram and as database client – Link
  • Httpie
  • Git
  • MySQL

Project Details

  • Github Repo – https://github.com/mikecao/umami
  • 11,296 stars
  • 1,580 forks
  • 132 contributors
  • 47 releases on Github. Last 15 days ago
  • 1379 commits
  • The project is 1 year and 10 months old. First commit was made on 17th July 2020
  • Close to 10,000 lines of modern Javascript code(used Tokei). This includes both backend and frontend
  • MIT license

Technology Stack of Umami

  • Node.js 12+. Modern Javascript codebase.
  • Nextjs as backend web framework for REST APIs
  • Prisma as ORM
  • Postgres or MySQL as database
  • Reactjs as frontend framework

Next.js is a framework to build server-rendered React web applications. It takes building React based web applications to the next level. The main reasons you would want to use Next.js are:

  • Zero config but you can easily override defaults
  • Extensible
  • Server-side rendering
  • Build both dynamic and static websites with a single framework
  • Supports all modern browsers
  • Convention over configuration
  • Code splitting
  • SEO Optimized
Continue reading “Architecture of Open source systems #1: Umami: An open source Google Analytics Alternative”

10 Things I Learnt By Reading Retrofit Source Code

Welcome to the first post of X-things-I-learnt-reading-Y’s-source-code series. In this blog series, I will share what I learnt after reading source code of popular open-source projects. Each week I plan to spend at least couple of hours reading source code of an open-source project and then sharing it on my blog. I plan to cover aspects such as design patterns project use, coding practices , API design, how they solved particular problem with their design, or any other aspect that I found useful to share. The purpose of this series is to learn how good developers design and build software. Then, I can apply these learnings to my work. Continue reading “10 Things I Learnt By Reading Retrofit Source Code”