TODO app architecture using AWS and serverless
Tags: aws, architecture, app, serverless
Published: 2022-01-11 11:46:16

In this article I´m going to go through how the architecture could look like for a ToDo app using AWS. This is the first part where the focus is the architecture in AWS and in the second part the idea is to built this.

So let´s get started and please feel free to comment your thoughts on this, suggestions if you have any and questions.

Note that this is one way of building this and there is a lot of ways of drawing this architecture.

This architecture will be based on a serverless architecture so we will only pay per usage and nothing is managed by us.

### What services will we be using?

**Amazon API Gateway**
In our app we will be using a REST HTTPS which we will use Amazon API for. The API will be used when we create, update and delete items in our ToDo list. Amazon API Gateway is a fully managed service that makes it easy for developers to create, publish, maintain, monitor, and secure APIs at any scale.

You could also if you like to cache responses in the API layer through Amazon API Gateway.

**AWS Lambda**
As for our backend we will be using AWS Lambda. AWS Lambda is a serverless, event-driven compute service that lets you run code for virtually any type of application or backend service without provisioning or managing servers.

**Amazon DynamoDB**
For our database we will be using Amazon DynamoDB. Amazon DynamoDB is a fully managed, serverless, key-value NoSQL database designed to run high-performance applications at any scale. 

One great benefit that we could take advantage of is the DynamoDB Accelerator (DAX). DAX is an in-memory cache that delivers fast read performance for your tables at scale by enabling you to use a fully managed in-memory cache. This is of course maybe not needed in the beginning, but at the time you start getting high read throughput and if the data does not change that often this is a way to handle the high read throughput issue.

**Amazon Cognito**
For our authentication we will be using Amazon Cognito. Amazon Cognito lets you add user sign-up, sign-in, and access control to your web and mobile apps quickly and easily. Amazon Cognito supports multi-factor authentication and encryption of data-at-rest and in-transit.

### How would the architecture look like?
**Authentication**
For the authentication we will use Amazon Cognito. The user will be prompted with a login screen and we will generate a user for the user. We will also use these credentials to verify the authentication when using Amazon API Gateway.

![Authentication](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/80ljgc193tnhjdnewff5.jpg)

**Backend**
As for our backend we will be using AWS Lambda which our Amazon API Gateway will invoke.

![AWS Lambda](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3sjhp2xwta8g8nlb34ad.jpg)

**Database**
For our database we are using DynamoDB. As I mentioned in the beginning we could take advantage of DynamoDB Accelerator (DAX) but that is not necessary in the beginning so you could skip that if you want to.

DynamoDB with DAX
![DynamoDB with DAX](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/baae4ro1rthnxhhbv3eo.png)
 

DynamoDB without DAX
![DynamoDB without DAX](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ujok2k45l40doxbptz6q.png)

**Final view of the architecture**
![ToDo architecture](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8mxdty93u8qg3x85v3do.png)

### So what have we built here?

- A serverless architecture
- Using Amazon Cognito for authentication and authorization
- Opportunity to cache reads on DynamoDB using DAX
- Opportunity to cache REST requests at the API Gateway level