
Weekend Creative Challenge: PlotTwist
An interactive branching storytelling app where every decision changes what happens next. Built with React and TypeScript, with a deterministic procedural story engine and deployed on AWS Amplify Hosting.
Vision & What the App Does
What if reading a story was not only about following what the author had already decided?
What if every choice you made changed what happened next?
That idea became PlotTwist, an interactive branching storytelling application where the reader becomes part of the story.
The idea behind PlotTwist is simple:
Every Choice Creates a Different Story.
Users begin by creating their own adventure. They can choose from six genres:
- Fantasy
- Science Fiction
- Mystery
- Adventure
- Horror
- Comedy
They can then create their own main character or let PlotTwist surprise them, choose a setting, select a story length, and decide how intense they want the plot twists to be.
There are two story lengths:
- Quick Adventure, with 3 chapters
- Standard Adventure, with 5 chapters
Once the adventure begins, PlotTwist presents the first chapter followed by exactly three choices.
The reader selects one choice, and that decision affects what happens in later chapters.
For example, a player might decide to investigate a suspicious room, trust a stranger, search for a hidden object, or take a safer path. These decisions can set internal story flags such as finding an important key, trusting another character, or discovering a secret location.
Later chapters react to those earlier decisions.
At the end of the adventure, PlotTwist creates a final resolution based on the path the reader took.
The result is a small interactive storytelling experience where replaying the same genre can lead to a different journey.


How I Built It
I built PlotTwist using React, TypeScript, Vite, Vitest, and AWS Amplify Hosting.
My original plan was actually very different.
I initially designed PlotTwist as a generative AI application using Amazon Bedrock, AWS Lambda, and Amazon API Gateway.
I built the serverless backend, integrated the Amazon Bedrock Converse API, added request validation, implemented structured story responses, and tested several models.
Then I hit an unexpected challenge.
My AWS account had a daily Bedrock model token quota of zero for the text models available to me. I tested Amazon Nova Lite, Amazon Nova Micro, and AI21 Jamba 1.5 Mini. The requests successfully reached Amazon Bedrock, but model inference could not continue because of the account-level daily quota.
Since this was a weekend challenge with a limited submission window, waiting for a quota increase was not a good option.
So I changed the architecture.
Instead of abandoning the idea, I asked myself what the real purpose of PlotTwist was.
It was not simply to call an AI model.
The real goal was to create a fun experience where the player's choices genuinely affect the story.
I therefore redesigned PlotTwist around a procedural branching story engine written entirely in TypeScript.
The original Bedrock implementation was moved into an experimental section of the repository, while the production application became fully client-side.
The story engine is organised into separate modules for:
- Genres
- Openings
- Story events
- Branching choices
- Plot twists
- Endings
- Seeded randomisation
- Story generation
Each genre has its own story components.
PlotTwist also uses deterministic seeded randomisation. Every new adventure receives a unique seed, but the same seed, story configuration, and choice history will always produce the same result.
This is important because it allows the story to remain consistent even after refreshing the browser.
The engine also tracks the effects of user decisions through story flags.
A choice can produce effects such as:
foundKey = truetrustedStranger = truecontrolRoomVisited = true
Future events and endings can check those flags before deciding what happens next.
This makes the choices meaningful rather than simply decorative buttons.
Testing and Reliability
Because PlotTwist depends heavily on branching logic and state changes, I added automated tests using Vitest.
The final application currently has 11 passing tests across two test suites.
The tests cover:
- Identical seeds producing identical story results
- Different seeds generating different adventures
- User choices changing story flags
- Exactly three choices appearing in every non-final chapter
- Correct 3-chapter story progression
- Correct 5-chapter story progression
- Final chapters ending without additional choices
- Story state persistence
- Full progression through a standard five-chapter adventure
I also tested the production build using TypeScript and Vite.
The final production build completed successfully with more than 1,500 modules transformed and no TypeScript compilation errors.
I also added browser storage so an active story can survive an accidental refresh.
Once an adventure is complete, users can view the full story, copy it to the clipboard, start a new adventure, or share it using the browser's Web Share API when supported.
AWS Services Used / Architecture Overview
The production version of PlotTwist is deployed using AWS Amplify Hosting.
The architecture is intentionally simple:

AWS Amplify Hosting builds and hosts the production web application.
My GitHub repository is connected directly to Amplify, so changes pushed to the repository can be built and deployed through AWS.
The procedural story engine runs directly inside the browser. This means the final application does not require a database, API credentials, or a server-side story generation service.
Keeping the final architecture small made the app easier to test, faster to deploy, and more reliable during the challenge.
What I Learned
The biggest lesson from this project was that the first architecture does not always need to be the final architecture.
I started this challenge expecting Amazon Bedrock to be the centre of the application.
Technically, I built the integration and reached the Bedrock service successfully. But an account-level quota restriction meant that approach was not reliable enough for a time-sensitive challenge.
Instead of stopping, I changed the implementation while keeping the original product idea.
That taught me several things.
First, I learned more about deterministic pseudo-random generation and how seeds can be used to make procedurally generated experiences reproducible.
Second, I learned how important state management is in interactive storytelling. A choice should have consequences, and those consequences need to survive across multiple chapters.
Third, I learned an important AWS lesson: test service quotas and account limits early, especially when building something under a short deadline.
An architecture can be technically correct while still being affected by account-specific service limits.
Finally, I learned that simplifying an architecture does not automatically make a product less interesting.
Removing the production AI dependency actually pushed me to think more deeply about branching logic, reusable story structures, deterministic behaviour, testing, and reliability.
The result is a working creative application that can be played immediately without external API dependencies.
Try PlotTwist
You can try the live application here:
Choose your world, make your decision, and see where the story takes you.
Every Choice Creates a Different Story.
Enjoyed reading this content? Let the author know!
Your likes, comments, shares, and saves help creators reach more builders.
Loading recommendations
Loading article