The making of Replicator
At Babbel, we use AWS Lambda a lot. Lambda supports many runtime environments and one of them is Ruby. When our team was about to create the first Lambda function written in Ruby, I thought it would be awesome to structure the project that it looks and feels like a Ruby project. Lambda itself does not insist on any project structure. You only specify which method to call and where it is located, the rest is up to you. Ruby does not have strict rules as well, but there are conventions that would make sense to follow. These conventions are supported (even encouraged sometimes) by tools and accepted by the community. They make Ruby-based projects feel like home… or at least place where you know how to navigate and find things 🙂
After a few hours of experimentation, a project structure was born that satisfied expectations. It was a bunch of files and directories, but everything had its meaning and place. The results looked good enough to share them with other engineers at Babbel. We decided to make one more step and create a tool that will help to bootstrap projects based on this structure, so people do not have to repeat our journey and could focus more on the problem they need to solve.
At its core Replicator is a tool that helps engineers and saves their time. You run one command and everything is ready to go:
> replicator init --function-name hello_world ... The project has been successfully bootstrapped. Run following command to install all necessary dependencies: script/setup Check README.md file for other useful instructions. --- Engage! 🖖
At this stage, you might wonder what is in the box. Right? Bootstrapped projects include:
- Core modules and classes of the Lambda function according to common Ruby styles and conventions
- Acceptance and unit tests for generated code
- Scripts to automate routine processes like testing, linting, preparation for deployment, etc
- Nice README and contribution guides
- Everything necessary to work with the Lambda function on the local machine
The Lambda function is ready to be packaged and deployed.
What makes Replicator possible?
If I have seen further it is by standing on the shoulders of Giants.
Replicator relies a lot on following amazing projects:
All of them helped to build Replicator itself and everything it generates. Kudos to everyone who was and currently is involved in these projects!
Every good project starts with an idea. After the idea comes a name. The name is important because it defines style, sets the voice and direction. Have you ever tried to come up with a good name? That is right! It is difficult.
There are only two hard things in Computer Science: cache invalidation and naming things.
As the tool was supposed to bootstrap projects based on a predefined skeleton, names like builder, generator, etc. were considered. However, all of them are plain, flavorless, and boring. Seeking for inspiration I looked at Star Trek as a potential source and remembered the replicator.
In Star Trek a replicator is a machine that can create things.
That was it! “…a machine that can create things.”
Our tool was going to be also about creating things. As replicators from Star Trek, the tool should be able to reproduce the same structure every time you ask it. So the name fit perfectly and it was bringing some style and familiar background.
Soon you will discover how the name influenced the tool even more than originally expected 😉
The final touch
replicator init command was ready, it seemed like the project is done. However, I was not able to get off a feeling that something is missing. Something like a cherry on top of a cake. Something that will distinguish Replicator from other tools and adds individuality.
As the name sets already the main theme of the project, it was necessary just to ask the right questions to find inspiration. In Star Trek replicators were used a lot by many different characters, but there was one person that engaged my creativity. One of the greatest characters and a true leader – Jean-Luc Picard, the captain of the starship USS Enterprise (NCC-1701-D). His famous phrase “Tea. Earl Grey. Hot.” was exactly what I was looking for 🙂 From this point it was obvious that Replicator is missing
Every time you run
replicator tea, it prints a random quote of captain Picard and an ASCII-graphics of a cup of tea.
> replicator tea (((( )))) _ .---. There is a way out of every box, a solution to every puzzle; ( |`---'| it is just a matter of finding it. \| | : .___, : -- Jean-Luc Picard `-----'
Only inspiring and positive quotes made it to the final list. I was very excited about results and spent a few more minutes to add one final touch – an option
> replicator tea --cold _ .---. ( |`---'| Things are only impossible until they are not. \| | : .___, : -- Jean-Luc Picard `-----'
I truly believe that software engineering is a creative activity. It is never boring and even tools that are supposed to move files from one place to another could have style, personality, and make people smile 🙂