When AppTweak started we used Sinatra for our APIs but as time went by we were looking for a better solution to help us document our endpoints, both internal and external. Then we chose Grape.
Convergence of Robotics and Gen AI offers excellent opportunities for Entrepr...
Lightning Talk: From Sinatra to Grape.pdf
1. Copyright 2022 AppTweak S.A. All Rights Reserved
From Sinatra to Grape
How we are migrating
from Sinatra to Grape
and why?
2. Copyright 2022 AppTweak S.A. All Rights Reserved
Who am I?
- I've been with AppTweak since 2019
- Been using Ruby since around
2016. Before that, I was using C,
C++, PHP and other technologies.
- Have a few open-source projects,
the most used one being the
Mastodon/Twitter crossposter
(Rails + Sidekiq).
Renato "Lond" Cerqueira
3. Copyright 2022 AppTweak S.A. All Rights Reserved
#1 ASO Tool
for Apps & Games
Driven by Data Science
AppTweak fuels growth for the world’s most
popular apps and games by providing
actionable insights in a simple interface.
4. Copyright 2022 AppTweak S.A. All Rights Reserved
Recognized ASO Leader
ASO pioneer launched in 2014, trusted by 1,500+ mobile leaders in 70+ countries.
Tokyo
Bengaluru
Brussels
San Francisco
6. Copyright 2022 AppTweak S.A. All Rights Reserved
What did we need from Sinatra?
At Apptweak, we write endpoints for both internal and external use.
Documentation was a pain point, so we wanted to be able to use code annotations to
generate swagger output.
Our idea was that anything we wrote for parameter validation would output as
documentation.
We could not find anything like that for Sinatra.
7. Copyright 2022 AppTweak S.A. All Rights Reserved
What Grape offered?
Grape is designed with APIs in mind. It has parameter validation built-in with a lot of nice
DSLs.
It has a companion gem, Grape-swagger, which exports documentation based on the
parameter validation. It also allows for specific documentation overrides.
Grape is inspired by Sinatra. That means our devs will not have to get used to something
completely different.
9. Copyright 2022 AppTweak S.A. All Rights Reserved
Exploration tests and migration path
We did internal testing and confirmed that Grape did what we wanted it to do:
- It allowed us to validate our parameters
- It exported the parameters as swagger documentation
- The DSL was flexible enough that we could expand on it if needed
We would not, however, be able to convert all our endpoints at once:
- Most endpoints had no proper documentation, so they would have to be
documented as we migrated.
- Some endpoints had some documentation but it was written so long ago it was
most likely out-of-date.
10. Copyright 2022 AppTweak S.A. All Rights Reserved
Rack::Cascade to rescue
We decided to use Rack::Cascade to be able to migrate the endpoints in a timely manner.
We cascade the old Sinatra app and the new Grape API and we're then able to remove an
endpoint from Sinatra and re-create it in Grape for the migration.