Slappbooks: Accounting Application on a Serverless Architecture

Serverless application development has never been easier. With the introduction of the Sigma IDE by SLAppForge, Serverless application now takes much less time. The post intends to explain the full development process of a lambda function using the Sigma IDE and by the end, you will understand the advanced functionality provided by the IDE.

Slappbooks is an accounting application developed using the Sigma IDE. A live demo of Slappbooks is available at https://slappbooks.slappforge.com/

If you want to deploy Slappbooks backend lambda functions with just one click, follow this guide. If you want to explore the full code of the project, please navigate to this link.

To begin development, you’ll need to create an account with SLAppForge and provide your AWS credentials. You will be shown the following page upon successful login.

Main Project View

As you can see a lambda file is already open. Let’s first look at a simple lambda function that would store a transaction in an RDS database. The database schema can be obtained from this code snippet.

Navigate to projects pane and you will be displayed the following page.

Project Pane of Sigma IDE

You could rename your first lambda file to add-transaction.js. Just right click on the file and select rename. Again navigate to the Resources pane.

The first step is to deploy an API gateway that would listen to user requests. Traditionally, this required navigating to AWS API gateway and configuring properties. Now, you can achieve this by a simple drag and drop. From the Resources pane, drag API Gateway icon onto the event of the lambda function. Since we’re trying to trigger an event, this makes sense. right?

API Gateway Configuration

Since we’re developing a new API, enter the API name. Keep Edge optimized as the default option and add your resource path. For the add-transaction lambda we can use the resource path `/addTransaction`. Select the method as POST. Finally select your deployment stage and click the inject button.

With just a few clicks, we have configured an AWS API gateway.

Next we need to configure an RDS instance. Again click on RDS from the Resources pane and drag and drop to the function body. Since we are trying to develop a logic using RDS, it makes more sense to add it to the function body. Right? The following prompt would be displayed afterwards.

RDS Configuration

Select the RDS Engine as MySQL. Select the DB Engine version and DB Instance class. Add the instance identifier as slappbooksdb. Master Username as slappbooksuser and enter a password. Enter the database name as slappbooksdb. Database port 3306. Paste the DB initialization query from the this link.

Afterwards, select the operation as Begin Transaction since we're trying to define a transactional block. Click on the inject button. Now you're lambda function would look like the image given below.

Begin Transaction Block

Now we need to inject a query block within the transactional block. Now add the code required to insert a transaction. You’ll need to define a query block as follows.

Query Block

Enter your sql query required in the field query. Add the parameters that you need to insert into the query in the inserts.

For example you could use

Now you can start focusing on your logic. The completed lambda function would appear as given below.

Completed Lambda Function View

Follow the same steps in developing the other lambda functions. If you’d like to have a look at our code, please navigate to https://github.com/slappforge/slappbooks.

Slappbooks also has a reactjs based front-end application for viewing purposes. Please refer to https://github.com/slappforge/slappbooks-frontend if you’d like to deploy the front end as well.

Cheers!