Getting started with serverless in under 5 minutes
Tags: serverless, backend, architecture, javascript
Published: 2021-03-31 13:56:04

---
title: Getting started with serverless in under 5 minutes
published: true
description: Building a simple serverless backend, without the faff. 5 minutes to production, and no DevOps knowledge required.
tags: serverless, backend, architecture, javascript
cover_image: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9u0obmbhwred74ix52ew.png
---

**TL;DR — Serverless can be simple, as long as you have the right tools in your hands**.
Most tools today are not the right tools, making serverless architecture too complicated and convoluted.
We believe there is a better way.
A practical section is at the bottom of this article.

-----

## The past and the future
Let’s start with a simple fact;

***Serverless is the future of the tech world***

You may assume that the inevitable future has landed on you unexpectedly, and start exploring the different tools that promise you the ultimate serverless vision — Low costs, no DevOps, usage-based pricing.

To your surprise, none of the serverless technologies on the market make your life simple. Quite the opposite;
1. You find yourself struggling to deploy a simple function, dealing with IaaS many limitations (in data size, run time, etc) and reading through hundreds of pages of docs and questions
2. “No DevOps” in reality meant even more DevOps than before; Managing a repository with various serverless functions and deploying each at the right time to the right place becomes a complex task for DevOps magicians
3. Changing your mindset towards a serverless-based thinking feels extremely uncomfortable and makes you question your choices, your career, and your life in general.
4. Even after building several serverless functions, you discover that making them communicate with each other is a separate soap opera. How on earth are you going to orchestrate that?
5. Debugging. Oh my god. Some say that debugging serverless projects is more painful than it was used as a torture measure by the Mossad. We cannot confirm or deny such claims.

### Why is serverless bad today?
To answer that question, let’s look at a picture of how your serverless stack may look like today:
![Serverless architecture today, on a famous IaaS provider](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/t10str2s3bv9636ym8pw.png)
Looking at that picture, what do you see?
All of these are functions. Can you say which one calls which? Which does what? And why? Who created it, and when?
**NO.**

How about this one:
![Serverless functions as a visual flow](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dlbe95857ac3wr2sepoh.png)

This looks like something anyone can understand; coders and non-coders alike.

You understand where everything starts, what every single function does, and where it all ends (from left to right). This is actually how we think.
“A will call B, and if that succeeds — we will do C”.
So who says coding cannot be done the same way? Who says serverless cannot be done similarly, just the way we picture it?


### The product process
All software products go through the same process:
* Planning (using a whiteboard or paper)
* Architecting (same as #1, or using Google Draw and such)
* Implementing (A code editor, various helper scripts and infrastructures, logs sink)
* Debugging (Same as #3 + different solutions for errors, monitoring, etc)
* Deploying (Deployment scripts, code editors, SaaS solutions, monitoring techniques, logs sink, etc)
This is true for new features, bugfixes, refactorings, upgrades and everything else. The same cycle, involving at least 8 different tools, each fulfilling a different purpose, and each billing you at the end of the month.

It doesn’t have to be this way.

## In practice — serverless made simple
No more beating around the bush. We want to be able to plan, code, execute and debug all in one place. We want it to be simple, visual, intuitive and cheap.

### Getting started
Let’s start by signing up at [STATEWIZE.com](https://statewize.com) for a free account.

### Planning
We can think of every single thing we develop as a “flow”. Let’s create a new flow, and add some “states” to it. Each “state” is a logical piece which performs an action (if you are from a technical background — this is one “serverless” function).
![Creating new states and connecting them to each other](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/omnjy4kl2bbgkzrjhqs8.gif)

You can connect states to one another in order to create a flow — where one action would call the next one as soon as it’s done.

Any connection originating at the green 🟩 box will be executed only if the current state succeeded. The red 🟥 box is the opposite — for failures.

### Implementing
Since each of the states “does a thing” — we can tell it what it should do. This can be a pre-made action (such as “Make an API call somewhere”), or a custom serverless function we can code **right there in the browser**:
![Fully-featured code editor in the browser](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ax5f2df81l7lvxlepxoo.png)

### Executing & Debugging
Once your flow is complete, you can execute it and see it running in real time:
![Fully-featured code editor in the browser](https://miro.medium.com/max/1400/1*xA8cURDiajfcL5SdzMMXDw.gif)

Looking at this, you can understand **exactly** what happened when, in which order and why.
You also don’t need to worry about logs — every output of every single state is available to you immediately, so you no longer have situations where you are “blind” due to a lack of logs or context data.

Hours which you usually spent on debugging can now be spent sunbathing or watching telly, since this kind of **visual debugging** allows you instantly spot any issues or bugs without the headache.

### Integrating
Using the dead-simple STATEWIZE SDK allows you to integrate this serverless flow into your existing project in just a few lines of code:

{% gist https://gist.github.com/justlev/bf4b1e95b3547be515f67c6344ee9ee1.js %}

It’s done, your serverless flows are up and running in a matter of minutes, and your existing projects can easily invoke them as and when required.

-----

Technology does not need to be exclusive, difficult or cumbersome. Things which can be simple — should be simple. For your life, for your business, for everything. This is the mission which drives us, this is why we do what we do.
Technology done right — means resilience, reliability, stability and calm. Let’s aim for that. 🌅

![STATEWIZE as an ecosystem for everything combined](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9u0obmbhwred74ix52ew.png)