AWS-Powered Distance Calculator
This project is a web application designed to calculate the geographical distance between two points on the Earth's surface using their latitude and longitude coordinates. Built from scratch, it leverages serverless architecture with five key AWS services
Leveraging the power of AWS, this project showcases the creation of a serverless web application designed to calculate geographical distances between two points on the Earth's surface. The application is built using a selection of AWS services, each playing a crucial role in delivering a scalable, efficient, and user-friendly experience. The following sections outline the key steps taken to bring this application to life, demonstrating the seamless integration and functionality of AWS services in a real-world scenario.
AWS Amplify
AWS Amplify is a set of tools and services that enables developers to build scalable full-stack applications. In this project, Amplify is used to deploy and host the web application, providing a seamless integration with other AWS services. It simplifies the setup process, allowing for quick and efficient deployment of the frontend.
AWS Lambda
AWS Lambda is a serverless computing service that lets you run code without provisioning or managing servers. In this application, Lambda functions are used to execute the backend logic, specifically the distance calculation algorithm. This ensures that the application can handle requests efficiently, scaling automatically based on demand. Below is the code executed for the calculation of the distance between two geographical points.
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
This function utilizes the Haversine formula to calculate the great-circle distance between two points on the Earth's surface, given their latitude and longitude in degrees. The result is returned in kilometers.
AWS API Gateway
AWS API Gateway is a service that allows developers to create, publish, maintain, monitor, and secure APIs. In this project, API Gateway acts as the intermediary between the frontend and the backend, facilitating communication and data exchange between the user interface and the Lambda functions.
Amazon DynamoDB + AWS Identity and Access Management
-
Amazon DynamoDB:
A fast and flexible NoSQL database service that provides consistent, single-digit millisecond latency. In this application, DynamoDB stores user queries and results, ensuring quick data retrieval and efficient handling of varying loads.
-
AWS Identity and Access Management (IAM):
A service that helps control access to AWS resources. In this project, IAM is used to manage permissions, ensuring that only authorized users and services can access the DynamoDB tables and other resources.​
To ensure secure and controlled access to the DynamoDB table used in this application, an IAM policy is defined that specifies the allowed actions on the table. Below is the IAM policy JSON that needs to be attached to the IAM role assumed by the AWS Lambda function.
Connecting Amplify and API Gateway
This final step involves integrating the frontend hosted on AWS Amplify with the backend APIs exposed through AWS API Gateway. By connecting these two components, the web application becomes fully functional, allowing users to input coordinates and receive distance calculations seamlessly.
​
Now that you've seen how the application is built, feel free to explore the calculator on the web.
​