
Weekend Creative Challenge: How I Built an AI That Roasts Your Code (Using AWS Serverless)
A walkthrough of building a serverless AI application using AWS Lambda, Amazon Bedrock Nova Lite, and React. Learn how to deploy Flask APIs to Lambda, handle cross-region Bedrock calls, and integrate with Amplify for a production-ready full-stack app.
Every project idea needs honest feedback. Mine needed roasting.
Every builder needs the feedback nobody wants to give. You pitch your project
idea, and everyone says "sounds great!" They're being supportive. They're being
kind. And then you spend three weeks building something that was obviously
doomed from the start.
I wanted honest feedback before I wrote hundreds of lines of code, so I built
Roast My Project: an AI that tells you exactly what's wrong with your idea, in
seven brutally honest personalities, powered by Amazon Bedrock.
What the app does
Type a project description, pick a roast style, hit the button. Roast My
Project does the rest:

- Decides which AI personality to invoke: • Professor 🧑🏫 (academic snark) • Senior Dev 🧑💻 (world-weary) • Savage 🔥 (no mercy) • Tech Bro 🤖 (startup buzzwords) • Boomer 👴 (old school) • Investor 🎓 (business focused) • Sleepy 😴 (completely unimpressed)
- Analyzes your project using Amazon Bedrock Nova Lite
- Returns structured feedback: roast score (0-100), innovation/feasibility/ technical ratings, weaknesses, improvements, and a final verdict
- Battle Mode: Compare two projects head-to-head and declare a winner
- Saves to DynamoDB: Optional history of every roast you've endured



The point isn't just "AI writes mean things." It's that the roast is grounded
in real technical analysis, delivered with personality, and gives you actionable
feedback before you commit to building.
The Architecture

Everything runs serverless: no EC2 instances, no containers, no servers idling
overnight. Pay-per-request for everything.
Why Each Aws Service
AWS Amplify
Purpose: Host React frontend
Why: Zero-config deploys from GitHub, automatic HTTPS, built-in CDN,
environment variables
AWS Lambda
Purpose: Run Flask backend
Why: No servers to manage, pay-per-request, scales automatically from zero
Lambda Function URL
Purpose: Public HTTPS endpoint
Why: Simpler than API Gateway for this use case, built-in CORS,
no additional config
Amazon Bedrock
Purpose: AI inference platform
Why: Managed service, no model hosting, pay-per-token pricing
Amazon Bedrock Nova Lite
Purpose: The actual LLM
Why: Lower-cost model, fast inference, good at structured JSON output
Amazon DynamoDB
Purpose: Store roast history
Why: Serverless database, pay-per-request, no capacity planning
Three Critical Design Decisions
DECISION 1: Choosing Amazon Bedrock Nova Lite
───────────────────────────────────────────────────────────────
I needed an AI model that could handle three things well:
• Fast: Users expect a roast in seconds, not minutes
• Affordable: Every roast triggers an inference request
• Reliable with structured output: JSON parsing errors would directly
affect the user experience
Amazon Bedrock Nova Lite checked all three boxes.
Because Nova Lite is designed as a lower-cost model, it was a good fit for an
application where every roast generates an inference request.
During testing, Nova Lite consistently produced clean, structured responses
once the prompt was properly tuned. The biggest challenge wasn't simply
calling the model — it was getting seven completely different personalities
to consistently sound different while still returning predictable JSON.
The prompt engineering took several iterations, but once the prompts were
dialed in, Nova Lite delivered exactly what the application needed.
DECISION 2: Flask → Lambda with Mangum
───────────────────────────────────────────────────────────────
I originally built the backend as a Flask API because I wanted something
simple that I could develop and test locally.
Everything worked perfectly on localhost.
Then I deployed it to AWS Lambda.
The first invocation failed with:
ASGI 'lifespan' protocol appears unsupportedThe problem was a mismatch between the frameworks.
Flask is a WSGI application, while Mangum expects an ASGI application.
I needed a translator between the two.
The solution was using WsgiToAsgi from asgiref and disabling ASGI lifespan
handling with:
lifespan="off"THE WORKING CODE:
from mangum import Mangum
from asgiref.wsgi import WsgiToAsgi
from main import app
# Convert Flask (WSGI) to ASGI for Lambda
asgi_app = WsgiToAsgi(app)
# Lambda handler
handler = Mangum(asgi_app, lifespan="off")That one configuration change turned a non-functional Lambda deployment into
a working serverless API.
The error message itself didn't make the underlying problem obvious, which
made this one of the more frustrating deployment issues.
DECISION 3: Cross-Region Architecture
───────────────────────────────────────────────────────────────
One of the most important architecture decisions was where to run each AWS
service.
My application infrastructure was deployed in:
ap-south-1 (Mumbai)But Nova Lite wasn't available to me in that region.
I had two choices:
Option 1 → Move the entire application to us-east-1
Option 2 → Keep the application in Mumbai and call Bedrock in us-east-1I chose the second option.
The final architecture became:
Frontend
↓
AWS Amplify
↓
Lambda + Function URL
ap-south-1
├──→ DynamoDB
│ ap-south-1
│
└──→ Amazon Bedrock
us-east-1IN THE LAMBDA CODE:
# Bedrock client
bedrock_runtime = boto3.client(
service_name='bedrock-runtime',
region_name='us-east-1'
)
# DynamoDB client
dynamodb = boto3.resource(
'dynamodb',
region_name='ap-south-1'
)This meant every roast request made a cross-region call to Virginia and back.
That added some network latency, but the actual AI inference was still the
dominant part of the request time.
For this project, the trade-off was worth it because keeping Lambda and
DynamoDB in Mumbai gave me a simple regional architecture while still
allowing access to Nova Lite.
Production problems and how I fixed them
PROBLEM 1: Lambda Worked in Tests, Failed in Production
───────────────────────────────────────────────────────────────
WHAT HAPPENED:
My Lambda function appeared to work perfectly during testing.
Unit tests passed.
Direct AWS Lambda CLI invocations worked.
But when the real application sent requests from the browser, the response
contained empty data.
The frustrating part?
Everything looked green.
THE BUG:
My test events didn't match the actual HTTP request structure used by the
deployed application.
I was testing with simplified payloads such as:
{
"description": "...",
"style": "savage"
}But the production request was coming through the Lambda Function URL as an
HTTP request.
My backend was trying to read values directly from the Lambda event instead
of parsing the HTTP request body.
THE FIX:
Instead of:
description = event.get('description')I changed the backend to parse the actual HTTP request:
data = request.get_json()
description = data.get('description')
style = data.get('style')This matched how the production frontend was actually communicating with
the Flask API.
LESSON LEARNED:
Automated tests validate your assumptions, not necessarily reality.
Five minutes testing the real deployed application in a browser exposed
something that hours of successful test runs didn't.
Test against the actual deployment early.
PROBLEM 2: Works on Localhost, 404 in Production
───────────────────────────────────────────────────────────────
WHAT HAPPENED:
Everything worked perfectly when running locally:
npm run devThe React application could call:
/api/roastThe Vite development server handled the request correctly.
Then I deployed the frontend to AWS Amplify.
Every API request returned:
404 Not FoundTHE BUG:
During local development, Vite was acting as a development server and
proxying API requests to my Flask backend.
My React code looked like:
const res = await fetch('/api/roast', {
method: "POST",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify({
description,
style
}),
});Locally, this worked because the Vite development environment knew where
to send /api/* requests.
But AWS Amplify was hosting the compiled React application.
There was no:
/api/roastroute on Amplify.
The browser was effectively requesting:
https://main.d2862doc3pfj7.amplifyapp.com/api/roastAnd that route didn't exist.
THE FIX:
I introduced an environment variable for the backend URL.
const API_URL = import.meta.env.VITE_API_URL || '';
const res = await fetch(`${API_URL}/api/roast`, {
method: "POST",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify({
description,
style
}),
});Then I configured the environment variable in Amplify:
VITE_API_URL=https://3632q2ni62dajybb7v4im456bu0hkrnu.lambda-url.ap-south-1.on.awsNow the production frontend knows exactly where the backend lives.
LESSON LEARNED:
Local development environments can hide architecture problems.
Vite's development proxy made the frontend and backend feel like they were
running under the same domain.
In production, they were completely separate services.
The lesson:
Localhost architecture ≠ Production architecturePROBLEM 3: Nova Lite Returned Markdown-Wrapped JSON
───────────────────────────────────────────────────────────────
WHAT HAPPENED:
My backend expected the AI to return valid JSON.
Instead, Nova Lite sometimes returned:
```json
{
"roast_score": 75,
"roast": "Your idea is..."
}
```My Python code then tried:
json.loads(ai_response)And failed.
The problem was the markdown code fences:
```json
...
```THE BUG:
I had asked the model for JSON.
The model was trying to be helpful by formatting the JSON as a markdown
code block.
For a human, that looks nice.
For json.loads(), those backticks are invalid.
THE FIX:
I made the system prompt much more explicit:
system_prompt = f"""
You are RoastBot, an AI comedian who roasts software projects.
Analyze the project and return ONLY valid JSON.
DO NOT use markdown.
DO NOT use backticks.
DO NOT use code fences.
DO NOT add explanations outside the JSON.
Return exactly this structure:
{{
"roast_score": <integer 1-100>,
"roast": "<one-liner>",
"innovation": <integer 1-10>,
...
}}
"""I also added defensive cleanup in the backend:
ai_response = response_body[
'output'
]['message']['content'][0]['text']
# Strip markdown just in case
cleaned = (
ai_response
.replace("```json", "")
.replace("```", "")
.strip()
)
result = json.loads(cleaned)LESSON LEARNED:
LLMs are probabilistic systems.
Even when you explicitly request structured output, you should never blindly
trust the response.
Prompt for the structure.
Validate the structure.
Handle unexpected formatting.
Defensive parsing is part of building reliable AI applications.
Lessons Learned
LESSON 1: Prompt Engineering Is 80–90% of the Work
───────────────────────────────────────────────────────────────
Getting Nova Lite to produce a "savage" roast is completely different from
getting a "sleepy and unimpressed" roast.
The seven personalities needed seven distinct instructions.
I spent more time iterating on prompts than writing the Flask API.
Each personality required multiple rounds of testing to get the tone right.
The breakthrough came when I stopped giving the model vague instructions such
as:
"Be sarcastic."Instead, I gave it concrete examples.
For example:
STYLES = {
"savage": """
You are a RUTHLESS comedian roasting this project.
Examples:
"This code is so bad, even PHP developers are judging you."
"Your database schema looks like a spider web designed by a
drunk spider."
""",
"sleepy": """
You are SO bored you can barely keep your eyes open.
Examples:
"Meh... seen this exact project 47 times this week... *yawn*"
"Oh wow, another todo app. How... original... *snore*."
"""
}The lesson was simple:
Don't just tell the model what to do.
Show it what the desired output looks like.
LESSON 2: Lambda Cold Starts Are Real — But Workable
───────────────────────────────────────────────────────────────
Lambda cold starts were another thing I noticed during testing.
When the function had been idle for several minutes, the first request could
take noticeably longer.
Subsequent requests were much faster.
For Roast My Project, this wasn't a major problem because the AI inference
itself took significantly longer than the Lambda startup.
WHAT I DID:
• Minimized the Lambda deployment package
• Removed unnecessary dependencies
• Used Lambda Function URL instead of adding API Gateway
• Added rotating loading messages to improve perceived performance
For example:
"Analyzing your architectural choices..."
"Judging your variable names..."
"Questioning your database design..."
"Preparing the roast..."I didn't implement Provisioned Concurrency.
For a side project, keeping infrastructure simple and paying only when the
function is used made more sense than optimizing for a problem that wasn't
actually the application's bottleneck.
LESSON 3: Cross-Region Calls Add Latency — But Inference Is the Real Bottleneck
───────────────────────────────────────────────────────────────
Because Lambda and DynamoDB were running in ap-south-1 while Bedrock was
running in us-east-1, there was additional network latency.
The important thing was understanding where the actual time was being spent.
The rough pattern looked like:
Lambda → DynamoDB
Same region
~50ms
Lambda → Bedrock
Cross-region
~100–200ms
Bedrock inference
~3–7 secondsThe cross-region network call was measurable.
But it wasn't the bottleneck.
The AI inference itself dominated the request time.
For an application where users already expect to wait several seconds for
AI-generated feedback, the additional network latency was acceptable.
That made the cross-region architecture a reasonable trade-off for this
project.
Final Thoughts
I built Roast My Project because I was tired of hearing:
"That's a great idea!"Sometimes what you actually need is:
"Here's why this won't work."Building this project taught me that the hardest part of an AI application
isn't necessarily calling the model.
It's everything around it.
The frontend has to communicate with the backend.
The backend has to survive deployment.
The AI has to return predictable data.
The infrastructure has to handle real requests.
And the entire system has to work outside of localhost.
I also learned that the first architecture you imagine isn't always the
architecture you end up deploying.
Some of the most valuable lessons came from things that broke:
• A WSGI application running through an ASGI adapter
• A local API route that didn't exist in production
• Test payloads that didn't match real HTTP requests
• An LLM returning perfectly readable JSON that my parser couldn't read
Those failures were part of building the application.
And that's exactly why I built Roast My Project in the first place.
Every builder has built something they probably shouldn't have.
The roast you get BEFORE writing hundreds of lines of code can be worth far
more than the validation you receive AFTER you've already spent the weekend
building it.
So before you start building your next project...
Maybe get it roasted first.
Enjoyed reading this content? Let the author know!
Your likes, comments, shares, and saves help creators reach more builders.
Loading recommendations
Loading article