AWS Builder Center
Weekend Creative Challenge: Tinai Poet

Weekend Creative Challenge: Tinai Poet

Modern situations, classical Tamil landscapes. A Sangam poetry engine on AWS Bedrock, Amplify, and DynamoDB — built in a day.

Vision & what the app does

Tamil is one of the world's longest continuously spoken languages, and among the very few with a literature that has never broken its thread. The Tolkāppiyam, its foundational grammar, does something no other ancient grammar attempts: alongside phonology and syntax, it codifies poetics — rules for how meaning is made, not merely how sentences are formed. The Sangam anthologies that follow it, the Ettuthokai and Pattuppāṭṭu, contain some two thousand poems by hundreds of named poets, many of them women. They were composed roughly two millennia ago, and they read as though they were written last week.
What makes them extraordinary is a discipline modern writing has mostly abandoned: you never name the emotion.
Sangam poetics divides all of human experience into two domains — akam, the interior life of love, and puram, the public life of war, kingship, and duty. Within akam, every situation belongs to one of five thinai: landscapes that carry meaning entirely by convention.
Each thinai comes with a fixed vocabulary — a flower, a bird, a time of day, a terrain, an occupation, a presiding deity. Kurinji, the mountains at midnight, is union. Mullai, the forest at evening among jasmine, is patient waiting. Marutham, the farmland at dawn, is the lovers' quarrel. Neithal, the seashore at sunset with blue water lilies, is separation. Palai, the parched wasteland at noon, is parting and hardship.
A poet writing neithal does not say she is grieving. The poet describes the shore, the lily, the fading light — and a reader who knows the convention feels the grief exactly. The emotion is carried entirely by the landscape. It is one of the most elegant compression schemes any literature has produced: a shared symbolic index, agreed between poet and reader, two thousand years before anyone used those words.
Tinai Poet takes a modern situation in plain language and reads it into one of those five landscapes.
Type "the streetlight outside my window has flickered every night since she left" and it returns a stanza in Tamil, with an English rendering beneath it:
மாலை நேரக் கரைமணல் ஓரத்தில், நெய்தல் மலர்கள் மலர்கின்றன, கடற்பறவைகள் கூவுகின்றன, மீனவர்கள் தங்கள் வலைகளை இழுத்துவருகின்றனர். என் ஜன்னலுக்கு முன் விளக்கு ஒன்று ஒளிர்ந்து, அணைந்து, மீண்டும் ஒளிர்கிறது— இன்றிரவு ஏதோ ஒரு புதிய வெளிச்சம் வரக்கூடும் என்பதுபோல்.நெய்தல் என வகைப்படுத்தப்பட்டது — கடற்கரை, பிரிவின் நிலம். ஆனால் துயரம் ஒருமுறைகூட சொல்லப்படவில்லை.
Classified as neithal — the shore, separation. The streetlight survives into the verse as a lamp. The grief is never mentioned once.
Building this in Tamil rather than only in English mattered to me. I'm from Madurai, a city that has been a seat of Tamil letters since the Sangam academies themselves, and the audience I most wanted to hand this to — my local AWS user group, the builders around me — reads the language. A poetry engine for Tamil poetics that could only speak English would have missed the point.
The app has three modes:
  • Create — your situation becomes a poem, on a card tinted with that landscape's palette, with an expandable explanation of why it was classified that way.
  • Play — the engine runs backwards. You get a stanza with the landscape hidden and guess which of the five it is. The reveal tells you which image gave it away — "the water lily and the sunset told you this was neithal." Streak counter included.
  • Gallery — recent poems from everyone who has used it.
Create teaches the convention by showing you output. Play teaches it by making you read. Same engine, inverted.




How I built it

The decision that shaped everything

The five thinai are hardcoded in a data file. The model never recalls a flower, a deity, or a landscape association from its own memory. It only picks an index and writes imagery from data I hand it.
This was the first thing I built and the one I'd defend hardest. Ask a general-purpose LLM about Sangam poetics and it will produce something plausible and subtly wrong — a flower attached to the wrong landscape, an invented deity. On a cultural tradition this old, being subtly wrong is worse than being obviously wrong, because nobody catches it.
So the model does two narrow jobs: classify the situation, and write imagery from supplied facts. The scholarship lives in code.

Two calls, not one

Create mode makes two Bedrock calls rather than one.
Call A classifies the situation into one of five thinai, returns strict JSON, runs at temperature 0.2, and is rejected and retried if the returned key isn't one of the five valid landscapes.
Call B takes the retrieved landscape data and writes the stanza at temperature 0.8.
Splitting them means a bad stanza can never corrupt the classification, and it lets the UI show the reasoning separately — "your situation is neithal, and here's why" is the part that makes the app feel like it understood you rather than pattern-matched you.

The build, and the two walls I hit

I gave myself a single day and a strict rule: bank a passing submission early, then treat everything after as upside. Phase order was Bedrock verification, then the thinai data file, then the backend, then a deployed Create screen — and I stopped there deliberately to confirm I had something submittable before building Play and Gallery.
That discipline saved the project, because both walls I hit were infrastructure, not code.
Wall one: Bedrock model access. Every  InvokeModel  call returned  ValidationException: Operation not allowed  despite  AdministratorAccess  and the model being listed as available in the region. The cause was an account-level model-access form that only exists in the console — no CLI path.
The genuinely useful finding here:  aws bedrock get-use-case-for-model-access  returns  ResourceNotFoundException: You have not filled out the request form  even on accounts where Converse calls succeed. I confirmed this on two separate accounts. That API is not a reliable signal of whether you can actually invoke a model. Don't debug against it — just try a real Converse call.
Wall two: Lambda Function URLs returning 403.  AuthType: NONE , resource policy configured exactly per the docs, deleted and recreated clean, waited through propagation. Still 403. The tell was that the account's Lambda concurrency limit was capped at 10 instead of the default 1000 — a new-account guardrail that doesn't surface through any IAM or Organizations API you can query.
Rather than reach for API Gateway, I moved the compute into Amplify Hosting's SSR runtime, which runs on managed Lambda behind Amplify's own CloudFront distribution. No public Function URL, no API Gateway, no Cognito. The handler logic ported over almost unchanged.

The bug that only appeared in production

After migrating,  USE_BEDROCK=true  was set in the Amplify console and the app still ran in fallback mode.
Two separate causes, stacked:
  1. The build role lacked  ssm:GetParametersByPath , so Amplify's own environment variables weren't readable at build time. This had actually been broken since early in the project and stayed invisible because the other variables happened to have matching hardcoded defaults.
  1. More surprising: Amplify Hosting's WEB_COMPUTE runtime never forwarded environment variables into the deployed function's process environment at all. I confirmed this empirically rather than by inference — a temporary debug route dumped  Object.keys(process.env)  from the live function and returned only AWS-reserved keys. None of the app variables were present.
The fix was to stop depending on runtime  process.env  and bake the values in at build time via  next.config.ts 's  env  block, using the same static-replacement mechanism that powers  NEXT_PUBLIC_* . Build-time access works; runtime doesn't. Sidestep it.
This one cost me the most time and is the finding I'd most want another builder to have.



AWS services used

AWS Service
Purpose
AWS Amplify Hosting
Hosts the Next.js frontend and serves the app over CloudFront
Amplify SSR compute (managed AWS Lambda)
Runs the API route handler — classification, generation, persistence. Replaced a standalone Lambda Function URL after 403 guardrails on a new account
Amazon Bedrock (Amazon Nova Pro)
Both inference calls: situation classification and stanza generation
Amazon DynamoDB
Single-table store for generated poems and play-mode streak scores
AWS IAM
Scoped execution role — Bedrock invoke on one model, DynamoDB read/write on one table, trusted only by amplify.amazonaws.com



Architecture

Browser (mobile-first Next.js SPA)
|
| POST /api/tinai { mode, ... }
v
Amplify Hosting ── CloudFront distribution
|
v
Amplify SSR compute (managed Lambda)
| |
| |
v v
Amazon Bedrock Amazon DynamoDB
Nova Pro TinaiPoet (single table)
- call A: classify PK: POEM#<uuid> -> poem records
- call B: write stanza PK: SCORE#<uuid> -> streak records
|
v
thinai.js (hardcoded, in-code)
5 landscapes x { flower, bird, time,
terrain, deity, occupation, palette,
giveawayImages }
Data flow, Create mode: situation → classify (Bedrock, temp 0.2, strict JSON, one retry on invalid key) → local lookup in  thinai.js  → generate stanza from supplied imagery (Bedrock, temp 0.8) → persist to DynamoDB → return poem, landscape, palette, and reasoning.
Data flow, Play mode: random landscape + random seed situation → single generation call → return stanza, hidden answer, and the giveaway image → user guesses → score written to DynamoDB against a browser-generated session UUID.
One table, four access patterns, no auth service. There is no login — session identity is a  crypto.randomUUID()  held in React state, which is the right amount of identity for a poetry toy.



What I learned

Infrastructure guardrails are invisible until they aren't. New AWS accounts carry anti-abuse restrictions — concurrency capped at 10, anonymous Function URLs blocked, Bedrock gated behind a console-only form — and almost none of them surface through an API you can query. I spent more of this build reading  AccessDenied  messages carefully than writing code. The skill isn't knowing the guardrails; it's recognising the shape of a guardrail failure versus a genuine misconfiguration, and not burning an hour re-checking a policy that was correct the first time.
Don't trust a status API over a real call.  get-use-case-for-model-access  told me I had no model access on an account where generation demonstrably worked. A real Converse call is the only ground truth.
Grounding beats prompting. Every time I was tempted to let the model handle more of the cultural knowledge, the output got worse in ways that were hard to see. Hardcoding the five landscapes turned a system that could plausibly hallucinate a two-thousand-year-old tradition into one that structurally cannot. The retrieval layer here isn't a vector database — it's a data file — and that was the right tool.
Bank the passing version early. Deploying Create mode and stopping to confirm it worked, before building anything else, meant that every infrastructure wall afterwards was an inconvenience rather than a crisis. Two of the three walls I hit would have been project-ending if I'd found them at hour eleven instead of hour four.
Build the fallback you hope not to need. I added a deterministic, template-based generation path behind a feature flag purely as insurance against Bedrock staying blocked. For several hours it was the only thing making the app demoable. It's not what shipped in the end — but the version of this project that has no fallback is the version that never got published.
Verify against production, not the dev server. A stale dev server on port 3000 produced a genuine guess/reveal mismatch in Play mode that didn't exist in the built app. Later, a cached browser tab made me believe a deployed feature hadn't shipped at all. Both cost real time. Test the artifact you're actually shipping.



Try it

The repository includes the full  thinai.js  data file, both prompts, the validator, and a  DECISIONS.md  recording every non-obvious choice made during the build — including the Amplify WEB_COMPUTE environment variable workaround, which took the longest to find and is the thing most likely to save someone else an afternoon.
Run it locally with your own Bedrock credentials, or flip  USE_BEDROCK=false  to use the deterministic fallback path and see the app work with no model calls at all.
Type a situation — a real one works better than a made-up one, and a specific concrete detail works best of all. Then switch to Play mode and see if you can read the landscape back out of the verse.
If you get five in a row, you've learned something a Tamil poet knew two thousand years ago.
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