The goal of this tutorial is to vibe-code a simple web application.
Refer to What is Vibe-coding? and Uses of Vibe-coding slides
Build an app that lets me upload an image and crops that image to 200 x 200 and then lets me download it
What did that do?
cooper.jpg
into your appAUDIENCE QUESTION: Did it work?
I find it often resizes before it crops - sometimes explaining that’s what it’s doing - I can ask it to not do that:
Don't resize the image before cropping
Scroll to the bottom and highlight an event handler
In the “Ask Gemini” pop-up:
What does this code do?
The explanation may only make sense if you’re familiar with coding in the JavaScript language.
Ask the agent to make some changes to the app, like:
Allow me to select the cropped region of the image
Add the image filename as a watermark to the image
Change the title of the app to "Image Cropper 2000"
With Gemini, we can even add a feature to our app that uses Gemini AI:
Add a button to generate a caption for the image using Gemini
Under the Share button, you can:
.html
fileIt’s a good idea to test if this will work for other users
I’m going to open the share link in an Incognito window, where I won’t be logged into my Google account
Uploading, cropping, and downloading an image works well
But it fails to generate a caption!
We can try asking why:
Why does the caption generation fail when used by a user who isn't logged into Google?
The reason is that it can only make a call to Gemini when the user is logged into Google in their browser
Dangerously, the code likely contains apiKey = ""
that you could fill in with an API key
That might not be obvious unless you’re familiar with how web apps work
This highlights the security risks of releasing apps when you don’t know what the code is actually doing!
The same warning goes for not being sure of the correctness
Refer to Scaling up AI-Assisted Coding slide
In this tutorial, we’ve seen how vibe-coding is a powerful tool for rapid prototyping and simple, low-stakes apps.
However, we’ve also seen the risks to security and correctness if you don’t know what the code is actually doing.
This recurring theme of great power requiring great responsibility is something we’ve seen multiple times throughout the course - and is one of the most important ideas to keep in mind as you learn and use even more AI tools in the future!