AWS Builder Center
Weekend Showcase Challenge: Color Picker

Weekend Showcase Challenge: Color Picker

The "Color Picker" is a lightweight, responsive web application that allows users to select a color and instantly see its RGB and HSL values computed by a backend service.

The "Color Picker" is a lightweight, responsive web application that allows users to select a color and instantly see its RGB and HSL values computed by a backend service. The problem it solves is simple but universal: designers and developers frequently need to translate a single hex code into various formats for styling, graphics, or programmatic usage. Instead of relying on bloated, ad-filled websites for simple color conversions, this tool provides an elegant, instantly responsive interface.
When a user selects a color via the native HTML color input, the application captures the hex value and offloads the mathematical conversion to a cloud environment. The interface is designed to be visually engaging, utilizing a sleek glassmorphism aesthetic overlaying a vibrant background. By bridging a simple frontend UI with a cloud-native backend, the project demonstrates how quickly micro-utilities can be spun up, decoupled, and scaled.

How I Built It

The project is split into a streamlined frontend and a serverless backend. The frontend is contained entirely within a single  index.html  file, designed with a modern frosted-glass card effect. I utilized the 'Quicksand' font and styled the main container with a  backdrop-filter: blur(18px)  over a dynamic linear gradient background transitioning from purple ( #7f5af0 ) to pink ( #ff6ac1 ) to orange ( #ffb86c ). The UI centers around a color swatch box, styled with a 150px height, a 20px border radius, and an inset box shadow to give the selected color physical depth.
To ensure the backend wasn't overwhelmed by rapid-fire API requests as a user dragged the native color slider, I implemented a debounce mechanism in the JavaScript logic. The event listener attached to the color input clears and resets a 150-millisecond timeout before triggering the data fetch.
On the backend, I wrote a Python script to handle the core color conversions. A significant part of the development process was translating the mathematical formulas for RGB and HSL conversions into clean Python code. The backend first attempts to extract the hex string from the query string parameters, stripping any leading  #  character. It validates that the string is exactly six characters long, returning a  400  status code with an error message if it is not.
The most complex logic resides in the  _rgb_to_hsl  function. This required normalizing the base-16 integer RGB values by dividing them by 255.0, finding the maximum and minimum values, and calculating the hue, saturation, and lightness based on the deltas between these extremes. If the string contains invalid characters that cannot be parsed into integers, the application safely catches the  ValueError  and returns a formatted JSON error.


 GitHub REPO 

AWS Services Overview

The application relies on a completely serverless cloud architecture to process user inputs.
  • AWS Lambda: This service runs the core Python 3.12 backend logic that converts the incoming hex string into formatted RGB and HSL data.
  • API Gateway (HTTP API): This acts as the front door, exposing the Lambda function to the public web over HTTP. It is explicitly configured with Cross-Origin Resource Sharing (CORS) to allow all origins ( AllowOrigins="*" ) and permit  GET  and  OPTIONS  methods.
  • Amazon S3: This service is used to optionally host the static frontend page, though the application can easily be run locally using a simple Python HTTP server.
The architectural flow is straightforward. The  index.html  file sends the selected hex value to a  GET /color?hex=<rrggbb>  endpoint. The API Gateway receives this request and routes it to the Lambda function. The function processes the data and returns a successful 200 HTTP response containing a JSON payload, formatted exactly as  {"hex": "#38BDF8", "rgb": "rgb(56, 189, 248)", "hsl": "hsl(199, 93%, 60%)"} . On the client side, the frontend script dynamically reads a  config.js  file that contains the deployed API Gateway URL, overriding a default empty string with the live endpoint to route the request successfully.

Conclusion

This summer was a deep dive into Infrastructure as Code (IaC) principles and command-line cloud deployments. Moving beyond just writing application code, I learned how to piece together disparate AWS services entirely through the AWS CLI.
Navigating IAM (Identity and Access Management) was a major learning curve. I had to manually create an execution role using a trust policy document that allowed the Lambda service to assume the role, and then attach the  AWSLambdaBasicExecutionRole  policy before the function could execute. This reinforced the cloud principle of least privilege. Furthermore, I learned how to explicitly grant the API Gateway permission to invoke the Lambda function using resource-based policies ( lambda:InvokeFunction ).
The most satisfying part of the journey was seeing the pieces connect seamlessly in the terminal. Using bash scripts to extract the dynamic API endpoint and inject it directly into the  config.js  file meant the frontend instantly knew where to route traffic after deployment. It transformed my understanding of deployment pipelines, proving that deploying full-stack web applications can be automated, predictable, and remarkably fast.
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