Host and deploy your Shopify application
Tags: webdev, shopify, devops, paas
Published: 2022-02-01 16:49:23

Creating a Shopify app from scratch has many aspects which can cause complexity. In this article we will cover a brief description of all these requirements and delve deeper into the hosting and deployment of your Shopify app.

## Shopify Application 
Shopify apps extend the existing functionality of Shopify and are created by third-party developers. Developers build apps to solve merchant problems at scale and expand the features of Shopify stores. Merchants use apps to help build their business, integrate with external services and add features to simplify their Shopify admin.

As a developer creating a Shopify app there are many aspects/layers you need to take care of: 
- Find a problem faced by many Shopify merchants, which your app will solve
- Understand Shopify as a platform 
- Build the front-end - using popular frameworks such as React
- Build the back-end - using languages and frameworks like NodeJS, Ruby on Rails, PHP
- Manage API calls - Shopify’s REST API or GraphQL can be used to communicate with the Shopify system to update and fetch data
- Create a database - many Shopify apps will have to store customer data and you’ll want it to be efficient at retrieving data so PostgreSQL (RDMS) or MongoDB (NoSQL) will be good options
- Learn about the basics of security - to avoid leaking customer data
- Host and deploy your app - once the app is ready, it will be hosted on a public web server so it’s accessible to merchants
- Marketing - selling your newly created app to merchants
- Customer support - handle support for the first customers directly
- Maintenance - fixing small bugs or deploying new features 


## Guides on how to create an app
If it’s your first time creating a Shopify app, you will find many resources from Shopify and certified Shopify developers covering the technology stack you need and the steps to follow to get your app running locally. 

Some of our favourite resources are: 
- [Shopify Getting Started Guide](https://shopify.dev/apps/getting-started ) 
- [Shopify, Building an app in one week](https://www.shopify.ie/partners/blog/building-a-shopify-app-in-one-week )
- [Jan's video on how to make a Shopify app](https://www.youtube.com/watch?v=A8YCxBTgsbI )

Following these resources you will learn about the front-end, back-end, API calls you need to make with the Shopify system and how Shopify works as a platform. This is all great, but you’ll find there is one very important piece of the puzzle missing, deployment and hosting. Once your app is ready and you want to move from local hosting to a public web server, there are many things which will be important to keep in mind as you scale, and Northflank is here to help.

Shopify apps have specific characteristics: 
- Development versions, staging and production environments
- Traffic peaks during sales, peak hours and events such as Black Friday
- Storing product, sales information, shop metadata and customer information in databases

Having a deployment platform which is reliable, allows CI/CD from Git, supports vertical and horizontal scaling, is price competitive and offers support with onboarding will be key for success. 

## Deployment features

### Development versions and application rollbacks - CI/CD from Git

Your application is likely to be in constant change, therefore having staging and production versions is something you will be familiar with. Pipelines allow you to manage the process of building, deploying and promoting images in different stages and versions. Northflank also gives you the flexibility to set up rules for deployment of the branches you decide on. Read more about pipelines in [our documentation](https://northflank.com/docs/v1/application/application/getting-started/set-up-a-pipeline).  

Continuous Integration and Continuous Delivery from your selected Git provider allows you to rollout new code as it's ready to deploy and rollback to previous builds of your application in seconds. This means that if there is an issue with a new commit, like a bug or security issue, you can quickly rollback to a known working commit, giving you time to fix your issue whilst keeping your users happy.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/t8iq0wuxy78gcdwnna2b.png)

### Multiple sources - Highly reliable networking

Your Shopify app communicates with merchants (your direct client), merchants’ customers and the Shopify platform. Globally accessible load-balancers and DNS are essential and allow traffic to be distributed amongst your running applications. Northflank can handle millions of requests without breaking a sweat ensuring your business and your merchant businesses keep operating, even under peak load. 

Requests and load can be increased by many actions like merchants loading your admin dashboard, webhooks that need to be received and processed as a result of updating Shopify stores (inventory updates, new orders, updated SKUs) and users requesting your application via product pages and checkout experience on Shopify stores.

### Traffic peaks - Horizontal and vertical scaling 

In certain situations there can be high demand and therefore high traffic, for example in seasonal periods like Black Friday, when customers are running sales or when a store becomes popular via social media. 

With Nothflank you can auto-scale either by number of containers (horizontally) or by size of the container (CPU/memory also known as vertically). Triggers can be requests per minute or min/max resource consumption per container. Of course, you can also scale your applications manually.

### Database persistence - DBaaS 

Many Shopify applications have to store SKUs, store metadata, order details, images, video and other information for the Shopify App. You can choose one or multiple datastores such as MongoDB, Redis, MySQL, PostgreSQL and Minio, so you always have the right tool for the job. Your users want the Shopify app to be fast and handle requests quickly, therefore having a high performance database with low latency to your backend APIs is very important. In the same way as with services, addons can scale horizontally, with multiple read replicas, and vertically, by adding more compute. A common requirement for Shopify apps is image storage, usually with an S3 compatible API, MinIO would be a good option here. Northflank also offers staging databases and the ability to fork a database from a backup. Read more about addons in [our documentation](https://northflank.com/docs/v1/application/databases-and-persistence/stateful-workloads-on-northflank).


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mdy11w83n3n9dxr9q0vd.png)

### Environments and secrets

Securely inject your environment variables into your code and inherit values from addons. If you have a couple of services you can simply inherit the variables, for example a Shopify API key, Twitter key and other variables from a single source of truth. You are able to quickly link connection details from your databases into a secret group to make secure and fast connections between your code and database without manually copying connection details. 

### Zero downtime - Health checks

Health checks are set up to test the backend logic of your app by sending requests to containers in order to check their health. By conducting health checks you can ensure that requests are only sent to healthy containers, assist with rolling out new versions to prevent downtime and auto recover containers when they get in a broken state. Your users need the app to run 24/24 without downtime because when your Shopify app is down your customers could be losing money. [More information on health checks here](https://northflank.com/docs/v1/application/observe/configure-health-checks). 

### Observability - Logs and metrics

At Northflank we provide access to logs and metrics from builds, services, addons and job runs to analyse builds to make sure the code is performant and operating without errors. Logs and metrics are invaluable in helping you and your developers pinpoint production issues enabling you to fix and deploy changes in rapid time. [This page covers more details on logs](https://northflank.com/docs/v1/application/observe/view-logs-and-metrics). 


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/d700h2ucv1fc949pcwf1.png)


### Simplicity - Comprehensive UI, API and CLI 

Shopify App creators are sometimes solo-founders or small teams, you want to spend your time growing your business and helping your customers. You have little time to spare and you want your app to be running through traffic spikes and for updates to hit production in rapid time. Northflank's web interface is fast, with real-time updates, and is accessible on mobile devices. Otherwise, you can also interact with Northflank through our CLI client, API, or native JavaScript client. Going from zero-to-hero will be a fast straightforward experience, and we will also be available to support your onboarding and migration.