AWS Builder Center
Weekend Showcase Challenge: Length Converter

Weekend Showcase Challenge: Length Converter

This serverless web application provides real-time length conversions between meters, kilometers, centimeters, feet, and miles. The frontend features a responsive interface built with HTML, CSS, and JavaScript that instantly triggers conversions as the user types, utilizing a 150-millisecond debounce mechanism to optimize API calls. The core mathematical logic and unit standardization are handled by a Python backend running on AWS Lambda, which is securely exposed to the web via an API Gateway HTTP API.

The vision for this weekend project was to construct a lightweight, highly responsive utility that eliminates the friction of daily measurement translations. The resulting application is a Serverless Length Converter designed to translate numerical values seamlessly between several standard units of measurement. Specifically, the application accurately handles conversions across meters, kilometers, centimeters, feet, and miles. The primary problem this application solves is removing the need for manual mathematical calculations by providing an intuitive graphical interface that operates dynamically in real-time. As a user types a numerical value into the input field, the application immediately triggers the conversion process without requiring manual page reloads or dedicated submit buttons. This uninterrupted user experience ensures that whether someone is attempting to understand driving distances in miles versus kilometers, or measuring architectural dimensions in feet versus centimeters, they receive an instantaneous output directly on their screen alongside a transparent notification indicating that the process was handled by AWS Lambda via API Gateway.

The Building Process: Key Decisions and Challenges

Constructing this application required bridging a clean frontend user interface with a robust, cloud-hosted calculation engine. The frontend environment was built utilizing foundational web technologies, specifically HTML, Cascading Style Sheets (CSS), and JavaScript, ensuring a rapid load time and minimal footprint. To guarantee a modern aesthetic, the interface incorporates the Roboto font family from Google Fonts and features a responsive, card-based layout capped with a distinct blue application bar. A key design decision was utilizing a symmetrical two-column grid for the 'From' and 'To' dropdown selectors, which makes the configuration highly intuitive.
A significant engineering challenge was ensuring the backend API was not overwhelmed by excessive requests during rapid user input. To effectively mitigate this, a debounce mechanism was implemented directly in the frontend JavaScript. Specifically, a  setTimeout  function delays the API call by 150 milliseconds, clearing and resetting the timer if the user continues typing. On the backend side, a Python script handles the mathematical logic. Rather than writing complex conditional matrices for every possible combination, the backend standardizes the workflow by first converting any input value into a universal base unit of meters. The script utilizes a dictionary of conversion factors where meters equal 1.0, kilometers equal 1000.0, centimeters equal 0.01, feet equal 0.3048, and miles equal 1609.34.

AWS Architecture: Services and Overview

The technical architecture of this application relies entirely on a scalable serverless model deployed within the Amazon Web Services (AWS) ecosystem. The backend computation is executed by AWS Lambda, utilizing the Python 3.12 runtime environment. Exposing this serverless Lambda function to the public web is securely managed by API Gateway, configured specifically as an HTTP API. This API Gateway instance creates the strict contract that allows the frontend interface to execute a GET request to the  /convert  endpoint, passing the numerical value, the origin unit, and the target unit as standard query string parameters.
To orchestrate this cloud deployment, the AWS Command Line Interface (CLI) was utilized heavily. The structured deployment process involved first generating a custom IAM execution role tailored for the Lambda function, granting it the permissions required to operate by attaching the  AWSLambdaBasicExecutionRole  policy. Once the Python source code was zipped into a standard deployment package, the Lambda function was created, and the HTTP API was configured with Cross-Origin Resource Sharing (CORS) explicitly allowing all origins. Finally, the dynamic API endpoint URL is injected into a dedicated  config.js  file, which accurately sets the  window.API_BASE_URL  variable consumed by the frontend application.

Summer Reflections: What I Learned

Throughout the summer, tackling architectural projects like this length converter has fundamentally shifted my understanding of cloud engineering and serverless application design. Building this specific architecture solidified my practical comprehension of how stateless backend functions operate in a modern cloud environment. By meticulously packaging Python code and deploying it directly via the AWS Command Line Interface, I gained critical, hands-on experience navigating IAM roles and assigning the correct security policies for cloud resources without relying on external deployment frameworks.
Furthermore, configuring the API Gateway illuminated the core mechanics of routing web requests securely to underlying compute services while managing CORS configurations to facilitate cross-domain frontend communication. Structuring the JSON responses properly from the backend—ensuring standard HTTP status codes and structured body payloads—reinforced essential best practices for professional API contract design.


App Preview

You can review the complete source code, deployment scripts, and the live application structure by visiting my repository:  [Link to App/Repo] 
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article