My Merch Store is a cloud application solution that integrates and consumes web application services. The solution consists of a client application that allows user input and consumes at least three different web services:
- One web service written by the developer
- At least one web service written by a classmate
- At least one publicly available web service
The client application interacts with a service application through a set of APIs, such as RESTful API and SOAP. The service application retrieves data from an object store, transmits it back to the client, and then receives updated data from the client. Authentication and authorization are required for accessing the service application, which is hosted on a public cloud platform. The solution can be coded using any programming language.
The inventory management system of the application is built as a serverless API with a React client application. The API is built using Python and deployed as an AWS Lambda function. The AWS API Gateway is used to expose the API endpoints, and the data is stored in an Amazon DynamoDB table.
The Lambda function is responsible for handling all API requests and responses. The code is separated into functions that handle various HTTP methods, such as GET, POST, PUT, and DELETE. These functions interact with the DynamoDB table to retrieve or modify data. The DynamoDB table schema is designed to store information about products, such as name, description, price, and quantity. The product ID is used as the primary key for the table, and all other data is stored as attributes.
The API Gateway is responsible for routing requests to the Lambda function and managing authentication and authorization. The API Gateway is configured to require an access token obtained by logging into the Cognito-hosted UI to access the API endpoints. This ensures that only authorized users can interact with the API.
To ensure secure access to the API, authentication and authorization are implemented using Amazon Cognito. An authorizer is set up in API Gateway that authenticates users using access tokens obtained by logging into the Cognito-hosted UI.
Amazon Cognito is a service managed by AWS that provides user authentication and authorization for web and mobile applications. With Amazon Cognito, you can easily add user sign-up, sign-in, and access control to your web and mobile apps. You can use Amazon Cognito to secure your APIs, authenticate users to your web and mobile apps, and store user data.
The authorization process is initiated by sending a POST request to the Cognito-hosted UI with the user's credentials. If the credentials are valid, Cognito returns an access token, which is then included in subsequent requests to the API Gateway. The API Gateway verifies the token with Cognito to ensure that the user is authorized to access the requested resource.
The API supports several methods, such as GET, GET by ID, POST, PUT item(s) by ID, and DELETE by ID. Error handling and exception handling are implemented in the Lambda function to ensure that the system is resilient to potential errors.
The API follows the RESTful design pattern, which is a standard for building web APIs. This design pattern is based on the HTTP protocol, which provides a standardized way to communicate between client and server. In RESTful design, each resource is identified by a unique URL, and the HTTP methods are used to perform actions on that resource.
The API is designed to be easily scalable and extensible. New endpoints can be added as needed to support additional functionality, and the underlying database schema can be modified as the needs of the system change.
The client application is built using React with client-side routing. The "shop" page fetches data from the GET method of the API todisplay a list of available products. The user can add products to their cart, which is stored in the browser's local storage. The "cart" page displays the contents of the user's cart and allows them to adjust quantities or remove items. When the user is ready to checkout, they are taken to a form where they can enter their shipping information and submit their order.
To run the application locally, you'll need to have Node.js and npm installed. Clone the repository and navigate to the root directory in your terminal. Run the following commands to install the necessary dependencies and start the application:
npm install
npm start
This will start the development server and open the application in your browser at http://localhost:3000.
This project is licensed under the MIT License - see the LICENSE file for details.




