Building a Shopify App with Ruby on Rails in a day

Jack Culpan
4 min readMay 6, 2022

The first (and sometimes the hardest) part is the idea: I was browsing Twitter last night and stumbled upon a few tweets from some big players in the Shopify ecommerce space. The idea was unique, somewhat validated, and something technically possible for me to build…

Here’s the tweet from @pauljauregui with a reply from @soundslikecanoe which provided enough validation for me to get stuck in on an MVP build. After reading it, I did some @ShopifyDevs API docs digging to see how technically difficult this would be…

Here we can see that the API response includes the position of the variant within the product, along with the inventory_quantity.

I’ll start by using the inventory_quantity to determine the variant ordering and then will look at adding the sell-through rate later on.

Now for the fun part — the building! First I’ll create an app on my @ShopifyPartners dashboard and will add the applicable App URLs.

I’ll be using Ruby + @rails for this build for two key reasons:

1) It’s what I know best, meaning I can write code fast

2) I can reuse code from past projects

The two points allow for a very fast MVP. I don’t want to build something for weeks for it to have no traction.

I’m using @kirplatonov‘s Shopify sample app as the template to get started. It’s clean, it works, and again I’ve used it before.

For the front end, I’ll also be using @kirplatonov+@_DanGamble et al’s Polaris View Components. Really easy to use, looks great, and makes the app feel at home within the @Shopify admin panel.

The @rails app is now up and running! I’ve built a fairly basic homepage which describes what the app does to the merchant and how to use it. Below I’ve placed a search form that allows the merchant to find the product they’d like to apply the variant ordering functionality to

Now to add the variant ordering functionality. The ‘update’ button above will be used to activate a background worker to carry out the heavy lifting. Here an API call returns the variants and sorts them by inventory quantity (largest first for now) creating the new ordering.

A quick test of the logic to make sure it’s all working before putting it into the background worker. I’ll be using Redis + Sidekiq for this, as it also allows for cron based scheduling later down the line (meaning we can run this command daily for example).

All looking good from the @Shopify Admin page too! Now it’s time to push to @Heroku and start filling out the @ShopifyPartners App Listing.

The app is now live on @heroku! This means I’ve got my app’s URL so I can fill out the GDPR webhook endpoints which Shopify requires. Next up is the @ShopifyPartners app listing.

The listing is submitted! I made a logo on @canva, took some screenshots of the app to use for the listing, and wrote up the benefits of the app. Now it’s time for the @ShopifyPartners team to do their thing.

Thanks for following along!

P.S. I am currently looking for Shopify App development opportunities.

You can get in touch with me on Twitter.

--

--