AWS Builder Center
Weekend Creative Challenge: Story Dice

Weekend Creative Challenge: Story Dice

Story Dice is a whimsical, serverless web application that uses Amazon Bedrock's generative AI to turn randomized dice rolls Place, Object, Trait, and Twist into engaging, 200-word flash fiction stories instantly.

Building the Future of Agentic AI | Full Stack Developer | Cloud Enthusiast
Vision & What the App Does
Story Dice is an interactive, whimsical story generation tool designed to spark spontaneous creativity for writers, game masters, educators, and anyone seeking playful inspiration.
Traditional tabletop story dice rely on physical cubes with icons to trigger ideas. Story Dice brings this tactile experience into the digital realm using cloud-native generative AI. The core experience is intuitive:
  1. Interactive Dice Rolling: The user clicks to roll four distinct, color-coded virtual dice across four thematic categories: Place, Object, Trait, and Twist.
  1. Generative Story Weaving: Once the dice combinations are locked in, the application sends the prompt parameters to Amazon Bedrock (powered by Amazon Nova Micro), synthesizing a cohesive, creative 150–200 word flash fiction story in real time.
  1. Storybook Gallery: Users can save their favorite generated narratives to a persistent storybook library backed by Amazon DynamoDB, allowing them to revisit past creative prompts whenever inspiration is needed.
The application turns unpredictable random prompts into engaging stories, demonstrating how AI can act as a playful creative partner rather than a purely functional tool.



AWS Services Used & Architecture Overview

The entire application is built on a 100% serverless, cloud-native architecture optimized for zero idle cost, low latency, and full compatibility with the AWS Free Tier.

Services Breakdown:

  • Amazon Bedrock ( amazon.nova-micro-v1:0 ): Serves as the generative AI intelligence layer, transforming randomized prompt combinations into narrative prose.
  • AWS Lambda (Python 3.12): Houses microservice handlers for modular execution ( /roll ,  /generate ,  /save ,  /stories ) without requiring dedicated server infrastructure.
  • Amazon API Gateway (HTTP API): Acts as the low-latency API proxy, exposing REST endpoints with integrated Cross-Origin Resource Sharing (CORS) configurations.
  • Amazon DynamoDB: Stores persistent user-saved stories in a schema-less NoSQL table ( StoryDiceStories ).
  • AWS Amplify Hosting: Manages continuous deployment and global static hosting for the client application directly from GitHub.
  • AWS SAM (Serverless Application Model): Defines the entire cloud infrastructure as code (IaC) within a repeatable  template.yaml .



How I Built It

The application was built from the ground up to follow modern cloud engineering and serverless development practices.

Development Process

  1. Infrastructure as Code (IaC): Defined all Lambda functions, IAM policies for Bedrock runtime execution, DynamoDB schemas, and API Gateway stages inside an AWS SAM template ( template.yaml ).
  1. Backend Engineering: Wrote modular Python 3.12 handlers utilizing the  boto3  SDK. The  /generate  handler constructs a contextual system prompt and calls the Amazon Bedrock Converse / Invoke API using the cost-efficient Nova Micro model.
  1. Frontend Engineering: Developed a responsive, zero-dependency client with HTML5, modern CSS animations for rolling dice, and modular JavaScript interacting with the API Gateway endpoints.
  1. Cloud Deployment: Executed SAM builds and deployments using AWS CloudShell, then linked the repository directly to AWS Amplify Hosting with custom artifact routing.

Key Architectural Decisions & Challenges Overcome

  • CORS Configuration: Enabling cross-origin communication between the Amplify hosting domain and the API Gateway endpoints required custom response header mappings ( Access-Control-Allow-Origin: * ) across all Lambda handlers.
  • Free Tier Cost Optimization: Selected Amazon Nova Micro on Bedrock to achieve near-instant inference speeds with minimal token overhead, ensuring the app remains well within Free Tier allocations.



What I Learned

Building Story Dice for this weekend challenge offered valuable practical takeaways:
  • Rapid infrastructure provisioning using AWS SAM and CloudShell streamlines serverless application bootstrapping.
  • Prompt construction for generative text generation requires careful parameter tuning (temperature, max tokens) to produce consistent flash fiction.
  • Structuring micro-handlers independently improves application fault tolerance and simplifies cloud debugging.



Links & Repository

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