Inspiration

While text-to-SQL AI tools are impressive, SQL remains the top in-demand skill for the majority of tech roles. The US Bureau of Labor Statistics forecasts an 9% growth in jobs for database admins and architects between 2022 and 2033, much faster than the average for all occupations.

QueryHunt is a SQL game that uses modern AI technology to create an engaging and interactive playing and learning experience. The inspiration for this project came from the original SQL Murder Mystery game created by Joon Park and Cathy He.

What it does

The game begins with an LLM (Claude 3.5 Sonnet) generating a unique murder mystery story and inserting the game data into the tables. The objective is to explore the data by running various SQL queries to identify the correct murderer. Users can view the schema and execute queries in an SQL editor. The LLM provides relevant hints based on the user's previous queries. Once a user identifies the correct murderer, they are added to the leaderboard along with the time it took to solve the mystery. The user can easily share their victory on their X feed.

How we built it

QueryHunt is built using multiple AWS services, such as Bedrock, RDS, S3, and Elastic Beanstalk. Amazon Q Developer has played crucial role in documenting the code, and debugging.

Below is a high-level overview of each technology and its role in the project:

AWS RDS: Used for storing AI-generated temporary game data. The following tables are utilized in the game:

  • Victim
  • Suspects
  • Evidence
  • Alibis
  • CrimeScene
  • Murderer (admin-only)
  • Leaderboard

AWS Bedrock: Enables generative AI capabilities, such as story generation, query generation, self-correction, and hint generation.

AWS S3: Stores the game assets such as favicon, logo and schema image.

AWS ElasticBeanstalk: App deployment and hosting.

Llama-Index: Handles the main LLM workflow orchestration. The workflow steps are as follows:

  1. Generate story
  2. Generate data based on the story (outputs SQL INSERT queries)
  3. Validate queries (includes data cleaning and syntax checks)
  4. Self-correct (optional step if validation fails, repeated up to 3 times)
  5. Execute queries (insert data into RDS tables for the game)

For more information, refer to the Llama-Index workflow diagram.

Streamlit: Serves as the UI of the app, using the custom component Streamlit-Ace for the SQL Editor.

Challenges we ran into

  • Configuring deployment on AWS Elastic Beanstalk was a bit challenging, as it was my first time using this service. Specifically, the default deployment attempted to use launch configurations, which are not supported for new accounts. Instead, I had to configure the deployment to use launch templates.

  • Parsing the model's response into SQL queries was challenging at times, as the model occasionally added extra characters that failed the validation step.

Accomplishments that we're proud of

I’m very proud of building this app in a relatively short time with no prior experience with AWS Bedrock or Elastic Beanstalk. Additionaly, I put a lot of effort into designing a Llama-Index workflow with multiple LLM calls, validation and self-correction. I'm pleased that it works as expected during the ideation!

What we learned

I learned how to integrate multiple AWS services into a single application. I explored using AI models through AWS Bedrock, which was a positive and straightforward experience. Additionally, I learned how to deploy and host Streamlit apps on AWS Elastic Beanstalk. While I had some prior experience with Llama-Index, I decided to explore their new workflow features and apply them to this project. It was challenging at times, but overall, it was a very rewarding learning experience.

What's next for QueryHunt - SQL Murder Mystery Game

I already have multiple ideas for new features and improvements for the game, including:

  • Level of Difficulty: Store previous user games, and reference them to create progressively more difficult games. This way, users will never play the same game twice and will be continuously challenged.
  • User Authentication: Log in and sign up functionality.
  • AI-Generated Schema: Create a truly unique gaming experience for each user.

NOTE: To avoid incurring additional costs associated with hosting the app on AWS Elastic Beanstalk, the app will be hosted on the free Streamlit Community Cloud during the judging period.

Built With

Share this project:

Updates