Skip to content

Shubham27052/microservice-contactform

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Contactform Microservice using AWS Serverless

A Microservice built to take customer details, using Aws Serverless offerings such as Lambda, API Gateway and DynamoDB. The microservice architecture can replicated and used anywhere where user contact and message needs to be taken.

The project has 4 main parts:

  1. Frontend: Contact Form
  2. API Gateway: to build an API
  3. Lambda Function: handles application logic
  4. DynamoDB: Database to store contact details

Tech Stack

Client: HTML, CSS, Javascript

Server: API Gateway, Lambda (python), DynamoDB

gif

How it works

Frontend

  • The frontend is made with HTML, CSS AND Javascript.
  • In script.js, the fetch api is used to make a post request API call to the api gateway.
  • If the status code in the response is 200, the form filled successfully prompt pops up.
  • If not then error is shown.

API Gateway

  • Used the AWS API Gateway to create an API that would allow the frontend to communicate with the lambda function.
  • A /contact resource was created and POST method was added. This was then integrated with the lambda function

smc

Lambda

  • The file lambda.py contains the code used for the function.
  • The event recieved from the api is used by the event handler to extract the necessary data.
  • A timestamp is used to give each item a unique key in the dynamodb table
  • The aws sdk for python, boto3 i used to save the data in dynamodb using the 'put_item' function.
  • The event handler returns a response witha status code, appropriate headers for CORS, and success message.

DynamoDB

  • A DynamoDB table is created in the aws account.
  • The following screenshot showns how the table looks like after data has been added by the lambda function. App Screenshot