top of page
Search

Small Business App - Back End (AWS Amplify)

Writer's picture: Kunal PatilKunal Patil

Updated: Apr 20, 2021

Welcome to part 2 of my series where I write about the small business app I made. This post is about how I configured the back-end with AWS Amplify.



In this post I will cover:

- GraphQL

- User Pools and Authentication

- Data Storage

- Lamba Functions


GraphQL

GraphQL is a query language for APIs and a runtime for fulfilling those queries with your existing data.


So what can GraphQL do?

- Provide a complete and understandable description of the data in your API.

- Give clients the power to ask for exactly what they need with queries.

- Make it easier to evolve APIs over time and enable powerful developer tools.


Amplify Tools & Services

The Amplify API provides a managed GraphQL service with AWS AppSync. AppSync provides instructions to set up the API from your command line. It also makes it easy to view or modify the API from the web and instantly deploy changes:


User Pool Authentication

Authentication is required to allow certain permissions to certain users. But before we can grant permissions, we need to set up a registration system for users to create their accounts.


Registration System

The Amplify Framework uses Amazon Cognito as the main authentication provider. Amazon Cognito is a robust user directory service that handles user registration, authentication, account recovery & other operations. When a new user account is created, they are added to the user pool:

Establishing Permissions

The user pool console shows information about users, including usernames, emails, phone numbers, account verification status, and involved groups. The console is where groups are created and users can be added. Different permissions can be established for each group. Here is an example of an Admin group for an app where only Admins can process customer orders. This is helpful if we want the Admins, or the business owners, to have a choice of accepting or declining a customer's order. Each groups rules can be declared in the schema.


Data Sources

I used DynamoDB and AWS Lambda for this web app's data resources. Generating the schema automatically creates query and mutation script files with functions to create the objects defined in the schema. For my web app, I want all users to be able to create products and orders so all rules are set to public.


DynamoDB

- Product: This table contains information on the custom product created by the customer and has attributes regarding its features. For my bakery app, the products have attributes related to size, shape, flavor, extra features, description, and allergies.

- ProductOrder: This table links products, users, and orders.

- Order: This table contains information of order pick up date and times, order total, and basic customer information.

AWS Lambda

- CreateOrder: This function is where new ProductOrder and Order objects are created. It is hooked to these tables via their table name ENUM values.

- ProcessPayment: This function processes payment information upon checkout. It is hooked to the Stripe API via the Stripe key.


29 views0 comments

Recent Posts

See All

Comments


Post: Blog2_Post

©2021 by Today I Learned. Proudly created with Wix.com

bottom of page