π§ Navigation:
π΅ Home | Vision LLM Theory | Frontend | Deployment | CDK Stacks | Runtime | S3 Files | Lambda Analyzers | Prompting System | Analyzer Wizard | Pricing Calculator
Broad Agentic Document Generative Extraction & Recognition System
BADGERS transforms document processing through vision-enabled AI and deep layout analysis. Unlike traditional text extraction tools, BADGERS understands document structure and meaning by recognizing visual hierarchies, reading patterns, and contextual relationships between elements.
Traditional document processing tools extract text but lose context. They can't distinguish a header from body text, understand table relationships, or recognize that a diagram explains the adjacent paragraph. BADGERS solves this by:
- ποΈ Preserving semantic structure - Maintains document hierarchy and element relationships
- ποΈ Understanding visual context - Recognizes how layout conveys meaning
- π Processing diverse content - Handles 21+ element types from handwriting to equations
- π€ Automating complex workflows - Orchestrates multiple specialized analyzers via an AI agent
Use cases: research acceleration, compliance automation, content management, accessibility remediation.
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β AgentCore Runtime β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β PDF Analysis Agent (Strands) β β
β β - Claude Sonnet 4.5 with Extended Thinking β β
β β - Session state management β β
β β - MCP tool orchestration β β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β AgentCore Gateway β
β - MCP Protocol (2025-03-26) β
β - Cognito JWT Authentication β
β - Semantic tool search β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
ββββββββββββββββββββΌβββββββββββββββββββ
β β β
βΌ βΌ βΌ
βββββββββββββββ βββββββββββββββ βββββββββββββββ
β Lambda β β Lambda β β Lambda β
β Analyzer β β Analyzer β β Analyzer β
β (29 tools) β β β β β
βββββββββββββββ βββββββββββββββ βββββββββββββββ
β β β
ββββββββββββββββββββΌβββββββββββββββββββ
βΌ
βββββββββββββββ
β Bedrock β
β Claude β
βββββββββββββββ
- π User submits a document with analysis instructions
- π§ Strands Agent (running in AgentCore Runtime) interprets the request
- π§ Agent selects tools from 29 specialized analyzers via MCP Gateway
- β‘ Lambda analyzers (29 functions) process document elements using Claude vision models
- π Results aggregate with preserved structure and semantic relationships
| Component | Technology |
|---|---|
| π€ Agent Framework | Strands Agents |
| π Agent Hosting | Amazon Bedrock AgentCore Runtime |
| πͺ Tool Gateway | Amazon Bedrock AgentCore Gateway (MCP Protocol) |
| π§ Foundation Model | Claude Sonnet 4.5 (via Amazon Bedrock) |
| β‘ Compute | AWS Lambda (29 analyzer functions) |
| π¦ Storage | Amazon S3 (configs, prompts, outputs) |
| π Auth | Amazon Cognito (OAuth 2.0 client credentials) |
| ποΈ IaC | AWS CDK (Python) |
| π Observability | CloudWatch Logs, X-Ray |
| π Cost Tracking | Bedrock Application Inference Profiles |
| Analyzer | Purpose |
|---|---|
πΈ pdf_to_images_converter |
Convert PDF pages to images |
π·οΈ classify_pdf_content |
Classify document content type |
π full_text_analyzer |
Extract all text content |
π table_analyzer |
Extract and structure tables |
π charts_analyzer |
Analyze charts and graphs |
π diagram_analyzer |
Process diagrams and flowcharts |
π layout_analyzer |
Document structure analysis |
βΏ accessibility_analyzer |
Generate accessibility metadata |
π₯ decision_tree_analyzer |
Medical/clinical document analysis |
π¬ scientific_analyzer |
Scientific paper analysis |
βοΈ handwriting_analyzer |
Handwritten text recognition |
π» code_block_analyzer |
Extract code snippets |
ποΈ metadata_generic_analyzer |
Generic metadata extraction |
ποΈ metadata_mads_analyzer |
MADS metadata format extraction |
ποΈ metadata_mods_analyzer |
MODS metadata format extraction |
π keyword_topic_analyzer |
Extract keywords and topics |
π§ remediation_analyzer |
Analyze remediation requirements |
π page_analyzer |
Single page content analysis |
π§± elements_analyzer |
Document element detection |
π§± robust_elements_analyzer |
Enhanced element detection with fallbacks |
ποΈ general_visual_analysis_analyzer |
General-purpose visual content analysis |
βοΈ editorial_analyzer |
Editorial content and markup analysis |
πΊοΈ war_map_analyzer |
Historical war map analysis |
π edu_transcript_analyzer |
Educational transcript analysis |
π correlation_analyzer |
Correlate multi-analyzer results per page |
πΌοΈ image_enhancer |
Image enhancement and preprocessing |
- βοΈ AWS CLI configured with credentials
- π¦ AWS CDK v2 (
npm install -g aws-cdk) - π³ Docker (running)
- π Python 3.12+
- β‘ uv
cd deployment
./deploy_from_scratch.shThis deploys 10 CloudFormation stacks:
- π¦ S3 (config + output buckets)
- π Cognito (OAuth authentication)
- π€ IAM (execution roles)
- π³ ECR (container registry)
- β‘ Lambda (29 analyzer functions)
- πͺ Gateway (MCP endpoint)
- π§ Memory (session persistence)
- π Inference Profiles (cost tracking)
- π Runtime (Strands agent container)
- π§© Custom Analyzers (optional, wizard-created)
See deployment/DEPLOYMENT_README.md for step-by-step instructions.
cd deployment
./destroy.shβββ deployment/
β βββ app.py # CDK app entry point
β βββ stacks/ # CDK stack definitions
β βββ lambdas/code/ # Analyzer Lambda functions
β βββ runtime/ # AgentCore Runtime container
β βββ s3_files/ # Prompts, schemas, manifests
β βββ badgers-foundation/ # Shared analyzer framework
βββ frontend/
β βββ main.py # Multi-page Gradio app entry point
β βββ pages/ # UI modules (chat, wizard, editor, etc.)
βββ pyproject.toml
MIT
BADGERS uses Lambda layers shared across analyzer functions:
ποΈ Foundation Layer (layer.zip)
- Built via
deployment/lambdas/build_foundation_layer.sh - Contains the analyzer framework (7 Python modules)
- Includes dependencies: boto3, botocore
- Includes core system prompts used by all analyzers
layer/python/
βββ foundation/
β βββ analyzer_foundation.py # π― Main orchestration class
β βββ bedrock_client.py # π Bedrock API with retry/fallback
β βββ configuration_manager.py # βοΈ Config loading/validation
β βββ image_processor.py # πΌοΈ Image optimization
β βββ message_chain_builder.py # π¬ Claude message formatting
β βββ prompt_loader.py # π Prompt file loading (local/S3)
β βββ response_processor.py # π€ Response extraction
βββ config/
β βββ config.py
βββ prompts/core_system_prompts/
βββ *.xml
π Poppler Layer (poppler-layer.zip)
- PDF rendering library for
pdf_to_images_converter - Built via
deployment/lambdas/build_poppler_layer.sh
Each analyzer follows the same pattern using AnalyzerFoundation:
# Lambda handler (simplified)
def lambda_handler(event, context):
# 1οΈβ£ Load config from S3 manifest
config = load_manifest_from_s3(bucket, "full_text_analyzer")
# 2οΈβ£ Initialize foundation with S3-aware prompt loader
analyzer = AnalyzerFoundation(...)
# 3οΈβ£ Run analysis pipeline
result = analyzer.analyze(image_data)
# 4οΈβ£ Save result to S3 and return
save_result_to_s3(result, session_id)
return {"result": result}The analyze() method orchestrates:
- πΌοΈ Image processing - Resize/optimize for Claude's vision API
- π Prompt loading - Combine wrapper + analyzer prompts from S3
- π¬ Message building - Format for Bedrock Converse API
- π€ Model invocation - Call Claude with retry/fallback logic
- β Response processing - Extract and validate result
Prompts are modular XML files composed at runtime:
s3://config-bucket/
βββ core_system_prompts/
β βββ prompt_system_wrapper.xml # π Main template with placeholders
β βββ core_rules/rules.xml # π Shared rules for all analyzers
β βββ error_handling/*.xml # β οΈ Error response templates
βββ prompts/{analyzer_name}/
β βββ {analyzer}_job_role.xml # π€ Role definition
β βββ {analyzer}_context.xml # π Domain context
β βββ {analyzer}_rules.xml # π Analyzer-specific rules
β βββ {analyzer}_tasks.xml # β
Task instructions
β βββ {analyzer}_format.xml # π Output format spec
βββ wrappers/
βββ prompt_system_wrapper.xml
The PromptLoader composes the final system prompt:
<!-- prompt_system_wrapper.xml -->
<system_prompt>
{core_rules} <!-- π Injected from core_rules/rules.xml -->
{composed_prompt} <!-- π§© Injected from analyzer prompt files -->
{error_handler_general}
{error_handler_not_found}
</system_prompt>Placeholders like [[PIXEL_WIDTH]] and [[PIXEL_HEIGHT]] are replaced with actual image dimensions at runtime.
Each analyzer has a manifest file in S3:
// s3://config-bucket/manifests/full_text_analyzer.json
{
"tool": {
"name": "analyze_full_text_tool",
"description": "Extracts text content maintaining reading order...",
"inputSchema": {
"type": "object",
"properties": {
"image_path": { "type": "string" },
"session_id": { "type": "string" },
"audit_mode": { "type": "boolean" }
},
"required": ["image_path", "session_id"]
}
},
"analyzer": {
"name": "full_text_analyzer",
"enhancement_eligible": true,
"model_selections": {
"primary": "global.anthropic.claude-sonnet-4-5-20250929-v1:0",
"fallback_list": [
"us.anthropic.claude-haiku-4-5-20251001-v1:0",
"us.amazon.nova-premier-v1:0"
]
},
"max_retries": 3,
"prompt_files": [
"full_text_job_role.xml",
"full_text_context.xml",
"full_text_rules.xml",
"full_text_tasks_extraction.xml",
"full_text_format.xml"
],
"max_examples": 0,
"analysis_text": "full text content",
"expected_output_tokens": 6000,
"output_extension": "xml"
}
}Key configuration features:
- π Model fallback chain - Primary model with ordered fallbacks
- π Retry logic - Configurable retry count per analyzer
- π§© Prompt composition - List of XML files to combine
- π Tool schema - MCP-compatible input schema for Gateway
- πΌοΈ Enhancement eligible - Flag indicating analyzer benefits from image preprocessing (used by
image_enhancertool)
Global settings (from environment or defaults):
{
"max_tokens": 8000,
"temperature": 0.1,
"max_image_size": 20971520, # 20MB
"max_dimension": 2048,
"jpeg_quality": 85,
"throttle_delay": 1.0,
"aws_region": "us-west-2"
}BADGERS uses Application Inference Profiles to enable cost allocation and usage monitoring. The system maps model IDs to profile ARNs at runtime:
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Inference Profile Flow β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β
β 1. CDK deploys InferenceProfilesStack β
β ββ> Creates ApplicationInferenceProfile for each model β
β β’ badgers-claude-sonnet-{id} (Global) β
β β’ badgers-claude-haiku-{id} (Global) β
β β’ badgers-claude-opus-{id} (Global) β
β β’ badgers-nova-premier-{id} (US) β
β β
β 2. Runtime receives profile ARNs as environment variables β
β ββ> CLAUDE_SONNET_PROFILE_ARN, CLAUDE_HAIKU_PROFILE_ARN, etc. β
β β
β 3. At invocation, bedrock_client.py maps model_id β profile ARN β
β ββ> "global.anthropic.claude-sonnet-4-5-*" β $CLAUDE_SONNET_PROFILE_ARN β
β β
β 4. Bedrock invoked with profile ARN (enables cost tracking) β
β ββ> Falls back to model ID if no profile configured β
β β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Model ID to environment variable mapping:
| Model Pattern | Environment Variable |
|---|---|
*claude-sonnet-4-5* |
CLAUDE_SONNET_PROFILE_ARN |
*claude-haiku-4-5* |
CLAUDE_HAIKU_PROFILE_ARN |
*claude-opus-4-6* |
CLAUDE_OPUS_PROFILE_ARN |
*nova-premier* |
NOVA_PREMIER_PROFILE_ARN |
Option 1: Use the Wizard (Recommended)
cd frontend
uv run python main.pyThe Analyzer Creation Wizard is available as a tab in the multi-page Gradio app.
Option 2: Manual Creation
- π Create prompt files in
deployment/s3_files/prompts/{analyzer_name}/ - π Create manifest in
deployment/s3_files/manifests/{analyzer_name}.json - π Create schema in
deployment/s3_files/schemas/{analyzer_name}.json - β‘ Create Lambda code in
deployment/lambdas/code/{analyzer_name}/lambda_handler.py - π Register in
deployment/stacks/lambda_stack.py - π Redeploy:
cdk deploy badgers-lambda badgers-gateway
Customers are responsible for making their own independent assessment of the information in this Guidance. This Guidance: (a) is for informational purposes only, (b) represents AWS current product offerings and practices, which are subject to change without notice, and (c) does not create any commitments or assurances from AWS and its affiliates, suppliers or licensors. AWS products or services are provided "as is" without warranties, representations, or conditions of any kind, whether express or implied. AWS responsibilities and liabilities to its customers are controlled by AWS agreements, and this Guidance is not part of, nor does it modify, any agreement between AWS and its customers.
- Randall Potter
- Amazon Bedrock Developer Experience - Foundation model choice and customization
- Anthropic's Claude in Amazon Bedrock - Claude Opus 4.6, Sonnet 4.5, Haiku 4.5 hybrid reasoning models
- Claude Sonnet 4.5 in Amazon Bedrock - Most intelligent model for coding and complex agents
- Claude Opus 4.6 in Amazon Bedrock - Tool search, extended thinking, and agent capabilities
- Amazon Nova Foundation Models - Nova Micro, Lite, Pro, Premier - frontier intelligence
- Using Amazon Nova in AI Agents - Nova as foundation model for agents
- Amazon Bedrock AgentCore Overview - Build, deploy, and operate agents at scale
- AgentCore Gateway Guide - Set up unified tool connectivity
- AgentCore Gateway Blog - Transforming enterprise AI agent tool development
- AgentCore Runtime - Secure serverless hosting for AI agents
- Lambda Layers Overview - Managing dependencies with layers
- Python Lambda Layers - Working with layers for Python functions
- Adding Layers to Functions - Layer configuration and management
- OAuth 2.0 Grants - Authorization code, implicit, and client credentials
- M2M Authorization - Scopes, resource servers, and machine-to-machine auth
- M2M Security Best Practices - Monitor, optimize, and secure M2M authorization
- CloudWatch + X-Ray Integration - Enhanced application monitoring
- Cross-Account Tracing - Distributed tracing across accounts
- AWS Observability Best Practices - Logs, metrics, and traces
- S3 as Data Lake Storage - Central storage platform best practices
- S3 Performance Optimization - Design patterns for optimal performance
- Amazon Kiro Overview - Agentic IDE for spec-driven development
- Kiro with AWS Builder ID - Sign in and get started with Kiro
- Nova Act IDE Extension - Accelerate AI agent development in Kiro
- Production-Ready AI Agents at Scale - Kiro as part of the agent development ecosystem