Skip to content

aws-samples/sample-strands-agents-chat

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

34 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

πŸ€– Strands Agents Chat

A full-stack AI chat application powered by Amazon Bedrock, Strands Agents, and Bedrock AgentCore

AWS Python React TypeScript


πŸ“Έ Screenshots

Chat Interface Mobile View
Feature View Settings View

✨ Features

This is a sample application that serves as a base implementation for chat applications utilizing Strands Agents.

πŸ—οΈ Simple Architecture - Clean, maintainable codebase with serverless scalability

🎨 Rich UI/UX - Polished chat interface with intuitive user experience

πŸ”§ Extensible with Strands Agents - Ready for customization with MCP, A2A, Multi Agents, Bedrock AgentCore, and more

πŸ“± Responsive Design - Optimized for both desktop and mobile usage


πŸ›οΈ Architecture

System Architecture

πŸ› οΈ Built-in Tools

Tool Description Technology
πŸ’¬ Multi-modal Chat Support for images, videos, and documents Amazon Bedrock
🧠 Deep Reasoning Advanced AI reasoning for complex problem solving Amazon Bedrock
🎨 Image Generation AI-powered image creation Nova Canvas MCP
πŸ“š AWS Documentation Search Search and access AWS documentation AWS Documentation MCP
πŸ” Web Search Real-time web search capabilities Tavily API
πŸ’» CodeInterpreter Execute and analyze code in real-time Bedrock AgentCore
🌐 Web Browser Browse web pages and analyze content Bedrock AgentCore

πŸš€ Deployment Guide

Step 1: (Optional) Create Tavily API Key Secret

Click to expand Tavily API setup instructions
  1. Open AWS Secrets Manager
  2. Click "Store a new secret"
  3. Select "Other type of secret"
  4. Choose "Plaintext" and paste your Tavily API Key
  5. Create the secret and copy the Secret ARN

Step 2: (Required) Configure Parameters

# Navigate to CDK directory
cd cdk

# Install dependencies
npm ci

# Copy the parameter template
cp parameter.template.ts parameter.ts

# Edit parameter.ts with your configuration
# Note: If tavilyApiKeySecretArn is null, web search tool will be disabled

Step 3: (Required) Deploy with CDK

# Bootstrap CDK (run once per AWS account/region)
npx cdk bootstrap

# Deploy all stacks
npx cdk deploy --all --require-approval never

πŸŽ‰ Access your application using the WebUrl from the deployment output!


πŸ’» Development

Frontend Development

For frontend development, you can run the development server locally while connecting to your deployed backend:

# Navigate to web directory
cd web

# Install dependencies
npm ci

# Start development server
npm run dev

The development server will:

  • πŸš€ Start at http://localhost:5173
  • πŸ”— Automatically import necessary values from the StrandsChat stack output
  • πŸ”„ Enable hot reload for rapid development

Pre-commit Checks

Before committing your changes, ensure code quality by running the pre-check script:

# Run pre-commit checks
./pre_check.sh

This script will validate your code formatting, run tests, and ensure everything is ready for commit.


βš™οΈ Customization

πŸ›‘οΈ WAF Configuration (Access Restrictions)

The WAF settings are defined in cdk/lib/waf-stack.ts. Customize this file to modify security rules.

Default behavior: Allows access from all IP addresses and countries

IP Restriction Example:

// Add IP allowlist in waf-stack.ts
const ipSet = new wafv2.CfnIPSet(this, 'AllowedIPs', {
  addresses: ['192.168.1.0/24', '10.0.0.0/8'],
  ipAddressVersion: 'IPV4',
  scope: 'CLOUDFRONT'
});

GEO Restriction Example:

// Add country-based access control in waf-stack.ts
// Add geoMatchStatement to your WAF rule's statement
const geoRule = new wafv2.CfnWebACL.RuleProperty({
  name: 'GeoRestriction',
  priority: 1,
  statement: {
    geoMatchStatement: {
      countryCodes: ['US', 'JP', 'CA'], // Allow only these countries
    },
  },
  action: {
    allow: {},
  },
  visibilityConfig: {
    sampledRequestsEnabled: true,
    cloudWatchMetricsEnabled: true,
    metricName: 'GeoRestriction',
  },
});

Country Codes: Use ISO 3166-1 alpha-2 country codes (e.g., 'US' for United States, 'JP' for Japan)

πŸ” Disable Cognito Signup

If you want to disable the Cognito signup functionality and restrict user registration:

Backend Configuration:

  1. Open cdk/lib/strands-chat-stack.ts
  2. Find the UserPool configuration
  3. Change selfSignUpEnabled from true to false
// In strands-chat-stack.ts
const userPool = new UserPool(this, 'UserPool', {
  selfSignUpEnabled: false, // Change from true to false
  // ... other configurations
});

Frontend Configuration:

  1. Open web/src/components/AuthWithUserPool.tsx
  2. Add the hideSignup={true} option to the <Authenticator> component
// In AuthWithUserPool.tsx
<Authenticator hideSignup={true}>
  {/* ... existing content */}
</Authenticator>

Note: After making these changes, redeploy the CDK stack for backend changes to take effect.


πŸ—οΈ Technology Stack

Layer Technology Purpose
Frontend React 19 + TypeScript + Tailwind CSS Modern, responsive UI
Backend Python 3.13 + FastAPI + Strands Agents AI-powered API
Infrastructure AWS CDK + Lambda + DynamoDB + S3 Serverless architecture
AI/ML Amazon Bedrock + Claude Advanced language models
Authentication AWS Cognito Secure user management

πŸ“ Project Structure

β”œβ”€β”€ 🐍 api/           # Python FastAPI backend
β”œβ”€β”€ ☁️ cdk/           # AWS CDK infrastructure
β”œβ”€β”€ βš›οΈ web/           # React frontend application
└── πŸ“– README.md      # Project documentation

Security

See CONTRIBUTING for more information.

License

This library is licensed under the MIT-0 License. See the LICENSE file.

About

A full-stack AI chat application powered by Amazon Bedrock and Strands Agents

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Releases

No releases published

Contributors 3

  •  
  •  
  •