AWS Logo
Menu
I built a Duolingo clone using an AI coding companion

I built a Duolingo clone using an AI coding companion

I built a Duolingo clone using Amazon Q Developer in my IDE and building it was faster than I expected. Here's how.

Veliswa Boya
Amazon Employee
Published Sep 28, 2024
Last Modified Nov 1, 2024
Editor's Note: This post has been updated as a contribution to the hackathon that AWS is running through the month of November. More details on how to participate at the end of this post.
I enjoy playing educational games and quizzes are my favorite go-to. Also, I speak four languages but I've always maintained that I'm not good at learning new languages. Duolingo fascinates me because it combines gamification and help with learning a new language.
I set out to build a Duolingo clone because I thought it'd be cool to have my own Duolingo-like app. I also was curious to see if an AI coding companion could really help me build my own app faster.

Prerequisites

To get started, you need an IDE with the Amazon Q Developer plugin. I already have it installed in my VS Code IDE and you can install the plugin in your IDE by following the steps detailed here.

How I got started

I started by creating a new directory then created an empty duolingo.py file. I have my IDE open and the Amazon Q chat open on one side of the editor. To get my initial code generation I typed /dev in the Amazon Q chat followed by the following description of what I wanted.
give me the starting python code for a duolingo-like application.
Amazon Q used this description to generate the following code.
At this point it's worth highlighting that the suggestions will differ with each new project, and that the suggestions you get will be different from the ones that your friends might get. Throughout the process you can ask for more information if anything is not clear; I'll add that this ability to ask questions helped me quickly feel comfortable while using Q to build this app.
I ran the code to start testing:
Ok, for now I want to focus on only two languages, Spanish and French, so I want to change the code to reflect this. I go back to Amazon Q Chat and with my entire code selected I type the following:
update selected code to only have Spanish and French
Q responded with a modified version of the DuolingoApp class and I pressed the Insert at cursor button to update my file with this new version.
Running this new version gave me an error AttributeError: 'DuolingoApp' object has no attribute 'languages' .
To troubleshoot I asked Q for help by right-clicking while inside the file then selecting Amazon Q, and lastly selecting Fix.
Q analyzed the code and suggested that I add the self.languages list to the init**** method. Q also provided the relevant code snippet**.** Again, I pressed the Insert at cursor button to accept this code.
The error was resolved and I could now run the code successfully.
Currently, the game is not ending as gracefully as I'd like ('Game over!' is hardly graceful lol).

I wanted to improve it so that the user has a better experience. For this I again right-clicked then selected Amazon Q, and then Refactor.
After reviewing the suggested code, I inserted it into my file to replace the current start method. This code now included a new method _play_again which provides a simple way to determine if the user wants to continue playing or not, and the __display_goodbye_message method which has a more graceful way of ending the game.
Here is how my final code looks.

Next steps

I had fun experimenting to see how Amazon Q Developer could help me build my own Duolingo clone. I also enjoyed interacting with the the app and learning new words from different languages. I look forward to building my next app using Amazon Q Developer and exploring even more features of Q Developer.
If you want to learn more, check out the Amazon Q Developer Dev Centre which contains lots of resources to help get you started. You can also get more Amazon Q Developer related content by checking out the dedicated Amazon Q space.
If you're ready to build your own game, AWS is running a hackathon through the month of November. From a simple tic tac toe game built with HTML/CSS/JS to a complex Unity game -- all skill levels and tech stacks are welcome. Join now on DevPost: https://awsdevchallenge.devpost.com!
 

Any opinions in this post are those of the individual author and may not reflect the opinions of AWS.

2 Comments