How I removed two databases in one pull request

I would like to thanks my coworkers at Octo for their precious feedbacks

My first project right after school was called KISS which means

Keep it simple, stupid

Three years and a few IT projects later, I thought that I got it right and applied the following rules:

Yet a few weeks ago, I learned that you can always remove useless things. You just don’t know it yet.

Story time

I wanted to create an API above the drugs data set (freely provided by the French government as CSV files). I knew that I needed a script to parse and store the data and a web API to expose them. The code is on github and the application is live. When I start a web application, I have 2 main choices to make:

After a while I needed “full text” search, so I added elasticsearch, simply because I knew how to use it. It requires a few (ugly) scripts to automate its synchronization with couchbase.

And suddenly came the epiphany! Or to be more precise, I asked for a review and after detailing the context, my colleague simply asked: “why don’t you remove couchbase?”. He was spot on: the dataset fits in memory and it is readonly. It was replaced with a simple import to load the JSON in memory ready to be queried by the application. But it got me thinking, couldn’t I remove the second database too? And I learned that there are indeed multiple libraries to search into local documents: I just used lunr and could therefore remove both databases.

The application is now more simple and reliable:

Nonetheless, after the refactor, the application was a bit slower even if everything was done in memory. Having said that, response time is still below 20 milliseconds, so the advantages brought by this removal still exceed the loss of a few milliseconds.

This resulted in a pull request with twice as many deleted lines as added lines and my takeaway would be:

Following KISS principles is more difficult than it seems: you can always question yourself but you should more likely seek for feedback from your peers. And, instead of choosing a database straight away, I would now choose a place to store my data.

Happy coding!