<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>Coder Legion - Recent posts tagged buildtolearn</title>
<link>https://coderlegion.com/tag/buildtolearn</link>
<description>Powered by Question2Answer</description>
<item>
<title>The Build-to-Learn Framework: How a Near-Disaster Taught Me to Learn in Public</title>
<link>https://coderlegion.com/13321/the-build-to-learn-framework-how-a-near-disaster-taught-me-to-learn-in-public</link>
<description>&lt;p&gt;I almost created an infinite loop that would have cost me thousands in AWS bills.&lt;/p&gt;
&lt;p&gt;And I'm grateful it almost happened.&lt;/p&gt;
&lt;hr&gt;
&lt;h3 id=&quot;the-setup&quot;&gt;The Setup&lt;/h3&gt;
&lt;p&gt;When I decided to pursue the &lt;strong&gt;AWS Certified Generative AI Developer&lt;/strong&gt; certification, I made myself a promise: I wouldn't just study for an exam. I would build real systems, make real mistakes, and share everything publicly—including the wrong turns.&lt;/p&gt;
&lt;p&gt;The AWS Skill Builder course has these &quot;Bonus Assignments&quot; scattered throughout. Most people skip them or treat them as quick checkboxes.&lt;/p&gt;
&lt;p&gt;I saw something different: each one was an invitation to build something &lt;strong&gt;production-ready&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;My first assignment: an automated insurance claim processing pipeline using Amazon Bedrock.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://raw.githubusercontent.com/rivadaviam/aws-genai-cert-learning-journey/main/labs/lab-01-claims-doc-processing/diagrams/generated-diagrams/insurance-claim-processing-architecture-lab01.png&quot; alt=&quot;Architecture Diagram&quot;&gt;&lt;br&gt;
&lt;em&gt;User uploads to S3 → Lambda orchestrates 3-step Bedrock pipeline → Results saved to output bucket&lt;/em&gt;&lt;/p&gt;
&lt;hr&gt;
&lt;h3 id=&quot;the-near-disaster&quot;&gt;The Near-Disaster&lt;/h3&gt;
&lt;p&gt;My initial architecture was elegant. One S3 bucket, two prefixes:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;/input&lt;/code&gt; for uploaded documents&lt;/li&gt;
&lt;li&gt;&lt;code&gt;/output&lt;/code&gt; for processed results&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Clean. Simple. &lt;strong&gt;Catastrophic.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Here's what happens with that design:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;1. Document lands in /input
2. Lambda triggers, processes document
3. Result written to /output (same bucket)
4. S3 event triggers Lambda again
5. Lambda processes the output file...
6. → Infinite loop. Infinite cost.
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I caught this because I was writing an &lt;strong&gt;Architecture Decision Record&lt;/strong&gt;—ADR-002—explaining my bucket strategy.&lt;/p&gt;
&lt;p&gt;The act of documenting forced me to think through the consequences. Mid-sentence, I realized what would happen in production.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-markdown&quot;&gt;# ADR-002: Separate S3 Buckets for Input and Output

## Decision
Use separate S3 buckets for input and output

## Consequences
- Prevents infinite loop scenarios
- Better security isolation
- Different lifecycle policies per bucket
- Slight increase in bucket management complexity

## Why This Choice
Following AWS best practices prevents production issues.
The slight complexity increase is worth avoiding infinite loops.
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;That ADR saved me real money. But more importantly, it taught me something:&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;&lt;strong&gt;Documentation isn't overhead. It's thinking made visible.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;hr&gt;
&lt;h3 id=&quot;the-build-to-learn-framework&quot;&gt;The Build-to-Learn Framework&lt;/h3&gt;
&lt;p&gt;That near-miss crystallized into a methodology I now follow for every lab: build real things, document every decision, and share the messy middle.&lt;/p&gt;
&lt;p&gt;Not tutorials. Not sandboxes. Production-grade systems with real constraints — the kind where a wrong architecture choice costs actual money. For every significant decision, I write an Architecture Decision Record capturing the &lt;em&gt;why&lt;/em&gt;, not just the &lt;em&gt;what&lt;/em&gt;. And when I share the work, I don't polish away the wrong turns. The trade-offs, the moments of doubt, the diagrams I scrapped at midnight — those are the parts that actually help someone else learn.&lt;/p&gt;
&lt;hr&gt;
&lt;h3 id=&quot;the-implementation&quot;&gt;The Implementation&lt;/h3&gt;
&lt;p&gt;Instead of one monolithic prompt, I designed a &lt;strong&gt;three-step AI pipeline&lt;/strong&gt; where each step uses the optimal model:&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;&lt;th&gt;Step &lt;/th&gt;&lt;th&gt;Model &lt;/th&gt;&lt;th&gt;Why&lt;/th&gt;&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;Document Understanding &lt;/td&gt;&lt;td&gt;Claude 3.5 Sonnet &lt;/td&gt;&lt;td&gt;Complex reasoning needed&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Information Extraction &lt;/td&gt;&lt;td&gt;Claude 3.5 Sonnet &lt;/td&gt;&lt;td&gt;Precision for structured JSON&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Summary Generation &lt;/td&gt;&lt;td&gt;Claude 3 Haiku &lt;/td&gt;&lt;td&gt;Cost-efficient for simple output&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;h4 id=&quot;step-1-document-understanding&quot;&gt;Step 1: Document Understanding&lt;/h4&gt;
&lt;pre&gt;&lt;code class=&quot;language-python&quot;&gt;def process_document_understanding(document_text, model_id, template_manager):
    &quot;&quot;&quot;Analyze and understand the document structure and content.&quot;&quot;&quot;
    prompt = template_manager.get_prompt(
        &quot;document_understanding&quot;,
        document_text=document_text
    )

    return invoke_bedrock_model(
        model_id,
        prompt,
        temperature=0.1,  # Low temperature for accuracy
        max_tokens=2000
    )
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Why this step?&lt;/strong&gt; Complex documents need context before extraction. Understanding the document type (auto claim vs. health expense) improves downstream accuracy.&lt;/p&gt;
&lt;h4 id=&quot;step-2-information-extraction&quot;&gt;Step 2: Information Extraction&lt;/h4&gt;
&lt;pre&gt;&lt;code class=&quot;language-python&quot;&gt;def extract_information(document_text, model_id, template_manager):
    &quot;&quot;&quot;Extract structured information from the document.&quot;&quot;&quot;
    prompt = template_manager.get_prompt(
        &quot;extract_info&quot;,
        document_text=document_text
    )

    result = invoke_bedrock_model(
        model_id,
        prompt,
        temperature=0.0,  # Zero temperature for deterministic output
        max_tokens=1500
    )
    return result
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Key insight:&lt;/strong&gt; Using &lt;code&gt;temperature=0.0&lt;/code&gt; ensures consistent, deterministic extraction. This matters when downstream systems depend on specific JSON fields.&lt;/p&gt;
&lt;h4 id=&quot;step-3-summary-generation&quot;&gt;Step 3: Summary Generation&lt;/h4&gt;
&lt;pre&gt;&lt;code class=&quot;language-python&quot;&gt;def generate_summary(extracted_info, model_id, template_manager):
    &quot;&quot;&quot;Generate a concise summary of the claim.&quot;&quot;&quot;
    prompt = template_manager.get_prompt(
        &quot;generate_summary&quot;,
        extracted_info=extracted_info
    )

    return invoke_bedrock_model(
        model_id,
        prompt,
        temperature=0.7,  # Higher temperature for natural language
        max_tokens=500
    )
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Why Haiku here?&lt;/strong&gt; The heavy lifting is done. We're just formatting extracted data into prose. Claude 3 Haiku does this well at &lt;strong&gt;~10x lower cost&lt;/strong&gt; than Sonnet.&lt;/p&gt;
&lt;p&gt;This decision is captured in ADR-005:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-markdown&quot;&gt;# ADR-005: Use Claude 3 Haiku for Summary Generation

## Decision
Use Claude 3 Haiku for summary generation (not Sonnet)

## Rationale
- Summaries are the final step - context is already extracted
- Haiku is ~10x cheaper than Sonnet
- Quality is sufficient for 2-3 sentence summaries
- Maintains on-demand throughput support

## Trade-off
Slight quality reduction for significant cost savings
&lt;/code&gt;&lt;/pre&gt;
&lt;hr&gt;
&lt;h3 id=&quot;model-selection-the-certification-question&quot;&gt;Model Selection: The Certification Question&lt;/h3&gt;
&lt;p&gt;If you're preparing for AIP-C01, model selection is a core exam topic — and this project gave me a real-world taste of the trade-offs involved.&lt;/p&gt;
&lt;p&gt;One decision surprised me. Claude 3.5 Sonnet v2 is newer and, on paper, &quot;better&quot; than v1. But when I dug into availability, I discovered that on-demand throughput isn't guaranteed in all regions and might require Provisioned Throughput. For a learning project that other developers will clone and deploy in their own accounts, availability matters more than marginal quality improvements. So I chose v1 — a stable, widely available model that anyone can spin up without provisioning headaches. It was a small decision, but exactly the kind of reasoning the certification expects you to articulate.&lt;/p&gt;
&lt;hr&gt;
&lt;h3 id=&quot;the-infrastructure&quot;&gt;The Infrastructure&lt;/h3&gt;
&lt;p&gt;The entire stack is defined in Terraform, which means anyone can deploy it with a single &lt;code&gt;terraform apply&lt;/code&gt;. Here's the Lambda at the heart of it:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-hcl&quot;&gt;resource &quot;aws_lambda_function&quot; &quot;processor&quot; {
  function_name = &quot;${var.project_name}-processor&quot;
  runtime       = &quot;python3.12&quot;
  handler       = &quot;lambda_handler.handler&quot;
  timeout       = 300   # 5 minutes
  memory_size   = 512   # MB

  environment {
    variables = {
      OUTPUT_BUCKET               = aws_s3_bucket.output.id
      BEDROCK_MODEL_UNDERSTANDING = &quot;anthropic.claude-3-5-sonnet-20240620-v1:0&quot;
      BEDROCK_MODEL_EXTRACTION    = &quot;anthropic.claude-3-5-sonnet-20240620-v1:0&quot;
      BEDROCK_MODEL_SUMMARY       = &quot;anthropic.claude-3-haiku-20240307-v1:0&quot;
    }
  }
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The numbers tell a story. A typical run — three sequential Bedrock calls — takes 30 to 90 seconds, but I set the timeout to 5 minutes to absorb cold starts, larger documents, and network latency. Memory sits at 512 MB: enough headroom for boto3 and JSON processing without overpaying for capacity the function will never touch. Both values came from testing, not guessing — another benefit of building before theorizing.&lt;/p&gt;
&lt;hr&gt;
&lt;h3 id=&quot;what-i-learned-beyond-the-tech-&quot;&gt;What I Learned (Beyond the Tech)&lt;/h3&gt;
&lt;p&gt;The biggest surprise wasn't technical — it was how much the act of &lt;em&gt;writing things down&lt;/em&gt; changed my engineering decisions. ADRs forced me to justify every choice, and several times I reversed course mid-sentence because explaining a decision out loud revealed the flaw in it. Documentation isn't a chore you do after the code works; it's a design tool you use while the code is still taking shape.&lt;/p&gt;
&lt;p&gt;Building locally first saved me real money, too. The system supports running the full pipeline on your own machine (&lt;code&gt;python main.py --input claim.txt --output result.json&lt;/code&gt;), so I processed dozens of test documents before a single Lambda invocation or Bedrock API call ever hit my AWS bill.&lt;/p&gt;
&lt;p&gt;And here's what connected everything back to the certification: every core topic from the Skill Builder course — model selection criteria, prompt engineering, cost optimization, security best practices, serverless patterns — showed up organically in this one project. I didn't have to memorize them. I had to &lt;em&gt;use&lt;/em&gt; them, and that made them stick.&lt;/p&gt;
&lt;hr&gt;
&lt;h3 id=&quot;what-s-next&quot;&gt;What's Next&lt;/h3&gt;
&lt;p&gt;This is just the beginning. I'm continuing to build through the AWS GenAI certification curriculum, turning each challenge into a production-ready implementation. More labs are coming — each one following the same Build-to-Learn principles: production-ready code you can actually deploy, every decision documented with ADRs, and the messy middle shared so you learn from my mistakes too.&lt;/p&gt;
&lt;p&gt;Want to follow along? Star the repo or &lt;a rel=&quot;nofollow&quot; href=&quot;https://www.linkedin.com/in/martin-rivadavia/&quot;&gt;connect with me on LinkedIn&lt;/a&gt; to get notified when the next lab drops.&lt;/p&gt;
&lt;hr&gt;
&lt;h3 id=&quot;try-it-yourself&quot;&gt;Try It Yourself&lt;/h3&gt;
&lt;p&gt;The entire project is open source. Clone it, read the ADRs, poke around the Terraform — and if you find a flaw in my implementation, &lt;a rel=&quot;nofollow&quot; href=&quot;https://github.com/rivadaviam/aws-genai-cert-learning-journey/issues&quot;&gt;open an issue&lt;/a&gt;. If you have a better approach, propose it.&lt;/p&gt;
&lt;p&gt;{% github rivadaviam/aws-genai-cert-learning-journey %}&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;# Clone and explore
git clone https://github.com/rivadaviam/aws-genai-cert-learning-journey.git
cd labs/lab-01-claims-doc-processing

# Read the full guide
cat README.md

# Deploy with Terraform
cd infra/terraform
terraform init &amp;amp;&amp;amp; terraform apply
&lt;/code&gt;&lt;/pre&gt;
&lt;hr&gt;
&lt;h3 id=&quot;the-invitation&quot;&gt;The Invitation&lt;/h3&gt;
&lt;p&gt;If you're preparing for a certification, don't just study. Build something real. Document your decisions. Share your journey. And if you build something using this framework, tell me about it — I want to see what you create.&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;Certifications prove you can learn.&lt;br&gt;
Projects prove you can build.&lt;br&gt;
Documentation proves you can teach.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;The Build-to-Learn Framework asks: why not do all three?&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;hr&gt;
&lt;p&gt;&lt;em&gt;Have questions? &lt;a rel=&quot;nofollow&quot; href=&quot;https://www.linkedin.com/in/martin-rivadavia/&quot;&gt;Connect with me on LinkedIn&lt;/a&gt; or drop a comment below.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Build. Document. Share. Repeat.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;code&gt;#BuildToLearn&lt;/code&gt; &lt;code&gt;#AWSCommunity&lt;/code&gt; &lt;code&gt;#LearnInPublic&lt;/code&gt;&lt;/p&gt;
</description>
<category>Articles</category>
<guid isPermaLink="true">https://coderlegion.com/13321/the-build-to-learn-framework-how-a-near-disaster-taught-me-to-learn-in-public</guid>
<pubDate>Sun, 22 Mar 2026 14:49:03 +0000</pubDate>
</item>
</channel>
</rss>