🔬 Project Overview
A lot of the people I love get letters they can't fully read. A bill from a medical billing company, a notice from the school, something from the county. The letter is in English, the deadline is real, and the usual fix is a photo sent to someone on WhatsApp with "¿qué dice esto?".
So I built CartaFácil: you open a link on your phone, take a photo of the letter, and a few seconds later you get a plain-Spanish explanation. Who sent it, what they decided, the date and the amount in big letters, what you have to do, what to bring, the phone number as a "tap to call" button, and (this one matters more than I expected) any free help the letter offers, like an interpreter or a payment plan.
The first real test wasn't a sample. It was a medical bill I had at home. It got the account number, the client number, the phone number and the payment link right. Then my mom tried it, and then a few friends, who found problems I never would have.
It's serverless, I built everything in the AWS console, and each letter costs a fraction of a cent.
This is a learning project, not legal, medical or financial advice. All the letters shown in this post are fake, from fictional organizations.
⚡ 1. TL;DR
A single-page app on AWS Amplify sends a photo of a letter to API Gateway and Lambda. Lambda checks a one-person code in DynamoDB and asks Amazon Nova 2 Lite on Bedrock for a structured Spanish explanation. The interesting part was everything the AI got almost right.
🔗 GitHub: github.com/sinai07/cartafacil-aws
🏷️ 2. Quick Metadata
| Field | Description |
|---|---|
| 💌 Project Name | CartaFácil – AI Letter Explainer |
| 🚧 Status | Working, tested by me, my mom and a few friends |
| 🎓 Difficulty | Beginner |
| 🧠 AI Model | Amazon Bedrock – Amazon Nova 2 Lite |
| ☁️ AWS Services | Lambda, DynamoDB, API Gateway (HTTP API), Amplify Hosting, Budgets |
| 📍 AWS Region | US East (N. Virginia) – us-east-1 |
| 🖥️ Tooling | AWS Management Console + CloudShell |
| 🐍 Language | Python 3.13 (boto3 only) + one HTML file |
| 🌎 Output | Plain-Spanish explanation of English letters |
| 💵 Cost | About 0.16 cents per text letter, roughly 0.3 cents with a photo |
📑 Table of Contents
- 💡 Why This Project Matters
- 🏗️ Architecture
- 📋 Prerequisites
- 🛠️ Step-by-Step
- 🧪 Testing
- 🩺 Troubleshooting
- 🧹 Cleanup
- 📚 Lessons Learned and Next Steps
- 💻 Complete Code
💡 3. Why This Project Matters
- 📬 The letters don't wait. Bills, school notices and medical statements come with real deadlines, and "I didn't understand it" doesn't stop a disconnection.
- 📲 Today the fix is a WhatsApp photo to a relative. It works, but it depends on someone being available, and it's not private.
- 🤝 The most useful line is often the easiest to miss. Free interpreters and payment plans are usually in the last paragraph.
- 💵 It costs almost nothing. A fraction of a cent per letter, with a hard cap per person.
⬆️ Back to top
🏗️ 4. Architecture
- A friend opens the link on their phone. Amplify Hosting serves one
index.html, and they type their code. - The page shrinks the photo in the browser and sends it with the code to an HTTP API in API Gateway (
POST /explain). API Gateway applies throttling and CORS. - API Gateway invokes the Lambda function (proxy integration).
- Lambda spends one use of the code in DynamoDB with a single conditional write. A fake or used-up code stops here and never reaches the AI.
- Lambda sends the photo and a strict system prompt to Amazon Nova 2 Lite through the Bedrock Converse API.
- The explanation comes back as fixed JSON, and the page turns it into cards.
CloudWatch keeps the logs (only token counts, not the letters), and a Budget sends an email if anything goes above USD 10.
⬆️ Back to top
📋 5. Prerequisites
- ☁️ An AWS account with Amazon Bedrock available in us-east-1
- 👤 An IAM user with admin permissions and billing access enabled (more on that in Step 0)
- 💰 An AWS Budget alert (Step 0)
- 📱 A phone to test with
⬆️ Back to top
🛠️ 6. Step-by-Step
💰 Step 0: A Budget Alert
The very first question I had was whether I needed the root user to create a budget. You don't. An IAM user with admin permissions can do it, as long as the root user has turned on "IAM user and role access to Billing information" once (Account settings). If the Budgets page says you don't have billing permissions, that's the switch.
I created a monthly cost budget of USD 10 with an email alert. A budget only warns you; it doesn't stop anything. The real spending cap in this app is the codes (Step 2).
⬆️ Back to top
⚙️ Step 1: The Lambda That Explains the Letter
The core is one Lambda function, letter-explainer-fn (Python 3.13, only boto3). It sends the letter to Nova 2 Lite with a system prompt that forces a fixed JSON shape: sender, decision, date, time, amount_due, reference_numbers, place, contact, what_to_do, requirements, how_to_comply, links, phone_numbers, help_available, if_you_dont_comply, urgency and key_terms.
The code and field names are in English; the explanation is in Spanish. The language is just an environment variable, OUTPUT_LANGUAGE, so another community (Portuguese, Haitian Creole) is a one-field change.
These rules in the prompt mattered most:
- Never invent anything. If a detail is not in the letter, write exactly: NOT_IN_LETTER - LINKS: include ONLY web addresses that are written in the letter, copied character by character. NEVER invent, complete or guess a link, even if you know the official site. - HELP: look carefully for any help the letter offers (free interpreter or translation, payment plan, financial assistance, deadline extension, accommodations)... I also gave the function the minimum permission it needs: an inline policy that can call only Nova 2 Lite.
{ "Version": "2012-10-17", "Statement": [{ "Sid": "InvokeNova2LiteOnly", "Effect": "Allow", "Action": "bedrock:InvokeModel", "Resource": [ "arn:aws:bedrock:*:*:inference-profile/us.amazon.nova-2-lite-v1:0", "arn:aws:bedrock:*::foundation-model/amazon.nova-2-lite-v1:0" ] }] } And I raised the timeout from the default 3 seconds to 30 seconds. A letter takes about 2 seconds, but the default would cut it off.
🔁 Three Rounds of "Almost Right"
I tested with two fake letters: a past-due water bill and a note from a school. Every round, the AI got the facts right, and every round I still found something a real person would miss.
- Round 1: It skipped the best line in the school letter: a free interpreter is available. So I added a field just for free help.
- Round 2: The school letter was perfect, but the water bill had no account number, the first thing they ask you when you call to pay. I added fields for the amount and the reference numbers.
- Round 3: It said the bill was due Friday, November 24. That day is a Tuesday. The letter never mentioned the weekday; the AI guessed it. Imagine thinking you have three more days and losing your water.
The fix for that last one was simple: the AI writes only the date, and the code adds the weekday:
def _fix_weekday(date_text): """LLMs are bad at calendar math (in testing, Nova called Tuesday Nov 24, 2026 a Friday). So the code computes the weekday from the original date in parentheses and writes it itself.""" ... parsed = datetime.strptime(original, fmt) weekday = _SPANISH_WEEKDAYS[parsed.weekday()] After that, both letters came back complete. Each one used about 1,150 input tokens and 400-500 output tokens.
A funny moment: I came back to the lab the next day, saw Spanish in the Lambda console and asked for everything to be in English. Then I remembered that explaining English letters in Spanish is the whole app. The code stayed in English; the explanation stayed in Spanish.
⬆️ Back to top
🔑 Step 2: One Code per Person, 4 Letters Each
Without a limit, anyone who found the URL could use the app as much as they wanted, and every letter costs money. So each person gets a code with 4 uses, stored in a DynamoDB table:
| code | friend | uses_left | active |
|---|---|---|---|
| CARTA-ANA | Ana | 4 | true |
The Lambda checks the code before calling Bedrock, with one atomic operation:
dynamodb.update_item( TableName=CODES_TABLE, Key={"code": {"S": code}}, UpdateExpression="SET uses_left = uses_left - :one", ConditionExpression="attribute_exists(code) AND active = :yes AND uses_left > :zero", ... ) DynamoDB subtracts the use only if the code exists, is active and still has uses left. Two letters sent in the same second can't both spend the last use. If Bedrock fails after the use is spent, the Lambda gives it back. And if a code gets shared in a group chat, I set active to false and nobody else is affected.
I didn't want to edit the Bedrock policy (its name says "Bedrock only"), so the role got a second inline policy, DynamoDBCodesOnly, with exactly one action: dynamodb:UpdateItem on this one table. One policy per job, named after what it allows.
Then I spent the four uses. The first letter left 3, the fourth left 0, the fifth got a 403, and a made-up code got a 403 without ever reaching Bedrock:
Both errors use the same message on purpose: "Invalid code, inactive, or no uses left." If the message said "this code doesn't exist", someone could try codes until they found real ones.
⬆️ Back to top
🚪 Step 3: API Gateway, the Front Door
APIs were the part I understood least going in, so here's the way it finally clicked for me. Think of a restaurant: the web page is the customer, the Lambda is the kitchen, and API Gateway is the waiter. The customer never walks into the kitchen; they give their order to the waiter, who brings back the answer.
I created an HTTP API, the simpler and cheaper type (REST APIs add things like caching and API keys that I didn't need), and set four things:
- 🛣️ One door only: the route
POST /explain. Anything else, like aGET, gets a404and never reaches the Lambda. - 🚀 Auto-deploy: every change goes live right away on the
$defaultstage. - 🚦 A speed limit: 2 requests per second, bursts of 5. Plenty for people, too little for a script trying to flood it.
- 🌐 CORS: the rule that tells the browser which websites may call the API. I left it open (
*) for testing and locked it in Step 4.
Two things tripped me up. After creating the API, the console opened the Routes page and I couldn't find the URL anywhere; it's on the API's main page, in the Stages table. And in the CORS screenshot below you can see "No headers are allowed": I typed content-type but never clicked Add. My tests still passed because curl ignores CORS, so I only caught it in Step 4.
Then I tested from CloudShell with curl, the same way the page would call it:
curl -s -X POST "$URL/explain" \ -H "Content-Type: application/json" \ -d '{"code":"TEST-7K2P","letter_text":"MAPLE RIDGE ELEMENTARY SCHOOL ..."}' \ | python3 -m json.tool --no-ensure-ascii | Test | Result |
|---|---|
| Real letter + valid code | 200 with the full explanation and "uses_left": 3 |
| Fake code | 403, rejected before Bedrock |
GET instead of POST | 404 Not Found, the Lambda never ran |
The response through API Gateway looks different from the Lambda console. There it was wrapped (statusCode, headers, and an escaped body); here it's clean JSON, because the HTTP API unwraps the proxy response into a real HTTP status, headers and body.
⬆️ Back to top
📱 Step 4: The Web Page
The page is a single index.html, no frameworks. The first version had an airmail-envelope design; I didn't like it. I wanted something that looks like the apps people already use, so the final one has soft lavender, mint and coral, rounded cards, emoji icons, and the "✨ Explicar mi carta" button pinned to the bottom like in a phone app.
To deploy it, I replaced <YOUR_API_ID> in index.html with my Invoke URL, zipped the file, and used Amplify > Deploy without Git.
Then I locked CORS: Access-Control-Allow-Origin changed from * to the exact Amplify URL (with https://, no trailing slash). That's when I saw the missing content-type header from Step 3. Without it, the browser would have blocked every request with a CORS error, even though all my curl tests had passed.
The moment of truth was my own medical bill, photographed with my phone. It read the account number, the client number, the phone number and the payment link correctly. The link was long and overflowed the button on my phone, so I fixed the CSS to wrap long links.
⬆️ Back to top
🧪 7. Testing
| Case | Expected | Result |
|---|---|---|
| Water bill (text, console) | Amount, deadline, account number, payment link, payment plan | ✅ after three prompt rounds |
| School letter (text, console) | Date, time, contact, reschedule phone, free interpreter | ✅ after round 2 |
| Weekday of a deadline | Correct weekday | ❌ model said Friday for a Tuesday → ✅ computed in code |
| Code with uses left | 200, uses go down by 1 | ✅ |
| Code with 0 uses | 403, no Bedrock call | ✅ |
| Fake code | 403, no Bedrock call | ✅ |
GET /explain | 404 from API Gateway | ✅ |
| Real photo of a real bill, on a phone | Correct numbers and link | ✅ (link overflowed the button, fixed in CSS) |
| Friends taking photos | Camera opens | ❌ with one button → ✅ with two buttons |
I configured throttling but didn't load-test it.
⬆️ Back to top
🩺 8. Troubleshooting
| Problem | Cause | Fix |
|---|---|---|
| Budgets says I don't have billing permissions | IAM access to billing is off by default | Root user: Account > "IAM user and role access to Billing information" > Activate |
| Couldn't find the Invoke URL | The console opens on Routes after creating the API | API main page > Stages table, or Deploy > Stages |
| CORS header missing after saving | Typed content-type but didn't click Add | Configure > add it as a chip > Save |
| Friends still saw the old page | Old version still deployed / cached | Amplify > Deploy updates with the new zip, then close and reopen the tab |
| Long payment link overflowed the button | No wrapping on long words | overflow-wrap: anywhere and min-width: 0 on the text |
| "I can't take a photo" | One button opened a chooser; some opened the link in an in-app browser | Separate camera and gallery buttons, in-app browser warning |
| Wrong weekday | The model did calendar math | Weekday computed with datetime |
⬆️ Back to top
🧹 9. Cleanup
I'm keeping the app running for my friends. If you build it to learn, delete everything in this order:
| Order | Resource | Where |
|---|---|---|
| 1 | Amplify app letter-explainer-web | Amplify > App settings > General > Delete app |
| 2 | HTTP API letter-explainer-api | API Gateway > APIs > Delete |
| 3 | Lambda letter-explainer-fn | Lambda > Functions > Actions > Delete |
| 4 | IAM role letter-explainer-fn-role-... (with both inline policies) | IAM > Roles > Delete |
| 5 | Log group /aws/lambda/letter-explainer-fn (not deleted with the function) | CloudWatch > Log groups > Delete |
| 6 | DynamoDB table letter-explainer-codes | DynamoDB > Tables > Delete |
| 7 | Budget letter-explainer-budget (optional) | Billing > Budgets > Delete |
⬆️ Back to top
📚 10. Lessons Learned and Next Steps
✅ Correct is not the same as useful. The model copied every fact right in the first round, but it didn't know that a free interpreter matters more to this audience than an account number. I had to tell it what the people using it care about.
📨 Test with more than one kind of letter. The school letter looked perfect; the water bill exposed the missing account number. Each type of letter stresses different fields.
🧮 Don't let the model do math. It invented a wrong weekday for a payment deadline. Anything that can be calculated (weekdays, totals, days left) belongs in code.
👩👧 Real users find real problems. I never would have guessed that "take or choose a photo" was confusing. My friends found it in a few hours.
📝 What I'd tell myself before starting: keep one notes file with every URL, ID and code from the start. I lost time looking for the Invoke URL and re-sending files.
| Limitation | Improvement |
|---|---|
| Links read from a photo can't be checked against text | Run Amazon Textract first and filter links against the extracted text |
| Name-based codes are easy to guess | Random suffix (CARTA-ANA-7K2P) |
| One page per letter | Multi-page letters, PDF upload |
| No history | Optional "save this explanation" for the person, with their consent |
| Spanish only | OUTPUT_LANGUAGE per code, so each person picks their language |
💬 What kind of letter would you try first? And if you've built something for your own family or community on AWS, I'd love to read about it in the comments.
⬆️ Back to top
💻 11. Complete Code
🔗 Everything is on GitHub: github.com/sinai07/cartafacil-aws
📄 Full Lambda code: lambda/lambda_function.py
📄 DynamoDB policy (iam/iam-policy-dynamodb.json):
{ "Version": "2012-10-17", "Statement": [ { "Sid": "SpendCodeUsesOnly", "Effect": "Allow", "Action": "dynamodb:UpdateItem", "Resource": "arn:aws:dynamodb:us-east-1:*:table/letter-explainer-codes" } ] } The web page (web/index.html) is in the repo. Replace <YOUR_API_ID> with your own Invoke URL id before deploying it.
⬆️ Back to top

























