DEV Community


Rewriting the entire company software.

daniellunsc profile image Daniel Luna ・4 min read

Working on a startup in Brazil isn't easy in general. Besides the no dress-code and flexible worktime, one of the challenges is to make cheap and fast mistakes as possible. Here I tell you my journey of 6 months since I was the unique software developer to becoming the CTO of my company at the age of 21.

I work at Probono, a small lawtech trying to facilitate access to justice in Brazil. We are operating since September/2017 and I was the unique software developer.

Since that, we experienced 2 architectures that matches the company experience:

  • MVC(Web2Py)
  • REST(Web2PY at Back-end, React at Front-end)

I was mentored by a senior software engineer who was our CTO, and I learned Databases, REST, MVC, but there is one thing I didn't learn from him: Good Pratices.

I was receveing issues and issues from our CEO(a Lawyer) to build new things, and I was doing in the way I could. We keep our engineering process like this: CEO tell the issue, I build it. No test case, no discussions about it, and who works on software engineering knows that the client can't explain right what he need.

So what happened ? We had to rewrite it on the end of 2018 due to two important points:

  1. Our Back-end was extremely slow and messy, it was about 30-50 seconds to process a POST request. We reused the Back-end from MVC so it was impossible to implement new features or evolve the code. We had to rewrite it from zero thinking in REST patterns to make it right.

  2. Our Front-end was 2x messy than our Back-end. Like our Back-end, impossible to evolve fast and help us to test new features.

So we decided to hire a new developer to boost our development time and decided to use Flask + Docker and React to our new software. But wait, it was taking to long to write controllers, models and SQLAlchemy wasn't working as expected.

We lost 2 month on it. It already was February and we even did not had a prototype. Our CTO was missing and we didn't knew if our database model rewrite was right, our pipeline was fine, and we didn't even have tests!

So me and the other dev decided to move forward using the tools we know best: Node.JS and React. We spent around 1-2 week searching frameworks to our Back-end, while trying the simple Node, Express and Sequelize. But remember we didn't knew if our database model was right!

We built prototypes using Nest.js and loopback4 (and I fell in love with it) and the basic Express + Sequelize. But one thing wasn't working as expected, we couldn't make the relationships work right with our model. I can't remember exactly, but I think we wanted to show both sides of a relation in a endpoint. Like:

*/person show all the person data, but also the clients that are linked to person.
*/client show all the client data, but also the person that are linked.

Starting from that dificulty, we notice our development was slow due the need of writing the database querying relationships in the controller. It was a mess!

It was almost middle of April when our CTO decided to show up and quit the company. And I as the older developer with the best knowledge about how everything works, became the new CTO.

I didn't know anything about managing teams or projects, I didn't know the best pratices while designing a database, Backend, pipeline or infrasctructure(We were spending around U$ 500,00 using Microsoft Azure.)

ps: 1 USD = 4.11 BRL

So we hired a new Front-end, while the other dev was assigned to Back-end. It already was beginning of May, and WE EVEN DID NOT HAD A PROTOTYPE. I remember one day we were talking about the new features to implement, and the old features to rewrite, I noticed where we were wrong: trying to build a new product using the base of the older.

So we decided to just remake the old software. We weren't going to implement new features, just fix the criticals bugs and rewrite it as much organized and clean we can. While both we're writing the core, I was taking some mentorship about databases and best designs due to our problem. Here are the core design we used in the new version vs the old design.

Old database, yes, the main table was 'chats'

New Database, with the right names

I simplified the models just to make it quick.

That mentorship was breaking changes to me, for the first time I was learning
why organization matters in the database and how it could speed or slow or software.

After the redesign of our database, we just need to choose which framework to use on it. NestJs was typescript, typecheckings is good, but was slowing down due to the team lack of knowledge, Flask was good, but we didn't had a good experience with SqlAlchemy. Loopback4 was AWESOME, but too obscure.

So we found our new and favorite backend: Sails.js.
With sails it was easy to design tables, migrate and build our API. We just had to keep the good pratices of endpoints and relationships. (I think we did our best).

Our rewrite took along 1 month, and in the end of may we were shipping our first release to beta test and 1 week after, we shutdown our old and strange software. We redesigned our software after it, redesigned our pipeline, and it got 1000x easier to implement new features, now we are implementing tests on it and preparing to ship our new app.

Writing this I noticed a lot of mistakes i've made and the expertise I won due to them. And I would love to hear from you advices for the entire situation I described here, is there something i could do to do it better? I'm here to learn!

If you read until here, really thank you for the interest! Lets talk!

Discussion (0)

Editor guide