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.

Need to view a demo?

Need to Deploy the Serverless sample using Sigma?

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.

Need to develop the application step by step?

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.

Sigma Main Lambda Function page

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 the following code snippet.

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

Project pane

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 and 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. Next, click on the inject button. Now you’re lambda function would look like the image given below.

Insert Transactional Block

Query Development

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.

Insert Query Block

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