Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 13 additions & 11 deletions 02-use-cases/video-games-sales-assistant/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
> [!IMPORTANT]
> **🚀 Ready-to-Deploy Agent Web Application**: Use this reference solution to build other agent-powered web applications across different industries. Extend the agent capabilities by adding custom tools for specific industry workflows and adapt it to various business domains.

This solution provides a Generative AI application reference that allows users to interact with data through a natural language interface. The solution leverages **[Amazon Bedrock AgentCore](https://aws.amazon.com/bedrock/agentcore/)**, a managed service that enables you to deploy, run, and scale custom agent applications, along with the **[Strands Agents SDK](https://strandsagents.com/)** to build an agent that connects to a PostgreSQL database, providing data analysis capabilities through a web application interface.
This solution provides a Generative AI application reference that allows users to interact with data through a natural language interface. The solution leverages **[Amazon Bedrock AgentCore](https://aws.amazon.com/bedrock/agentcore/)**, a managed service that enables you to deploy, run, and scale custom agent applications, along with the **[Strands Agents SDK](https://strandsagents.com/)** to build an agent that connects to a PostgreSQL database, providing data analysis capabilities through a Next.js web application built with **[AWS Amplify Gen 2](https://docs.amplify.aws/)**.

<div align="center">
<img src="./images/data-analyst-assistant-agentcore-strands-agents-sdk.gif" alt="Conversational Data Analyst Assistant Solution with Amazon Bedrock AgentCore">
Expand Down Expand Up @@ -49,16 +49,18 @@ The AgentCore infrastructure handles all storage complexity and provides efficie
- **VPC with Public and Private Subnets**: Network isolation and security for database resources
- **Amazon Aurora Serverless v2 PostgreSQL**: Stores the video game sales data with RDS Data API integration
- **Amazon DynamoDB**: Stores raw query results for data analysis audit trails
- **AWS Secrets Manager**: Secure storage for database credentials
- **AWS Secrets Manager**: Secure storage for database credentials (admin and read-only)
- **Amazon S3**: Import bucket for loading data into Aurora PostgreSQL
- **SSM Parameter Store**: Configuration management for AgentCore runtime parameters

All configuration values (database ARNs, secret ARNs, model ID, etc.) are passed directly as environment variables to the AgentCore Runtime — no SSM Parameter Store required.

### Amplify Deployment for the Front-End Application

- **React Web Application**: Delivers the user interface for the assistant
- Uses Amazon Cognito for user authentication and permissions management
- The application invokes the Amazon Bedrock AgentCore for interacting with the assistant
- For chart generation, the application directly invokes the Claude Haiku 4.5 model
- **Next.js Web Application (Amplify Gen 2)**: Delivers the user interface for the assistant
- Uses Amazon Cognito (via Amplify Gen 2) for user authentication and IAM permissions — no manual IAM configuration needed
- The application invokes Amazon Bedrock AgentCore for interacting with the assistant (client-side streaming)
- For chart generation, the application directly invokes the Claude Haiku 4.5 model (client-side)
- DynamoDB query results are fetched through a Next.js API route (server-side)

### Strands Agent Features

Expand All @@ -69,7 +71,7 @@ The AgentCore infrastructure handles all storage complexity and provides efficie
| Model Provider | Amazon Bedrock |

> [!NOTE]
> The React Web Application uses Amazon Cognito for user authentication and permissions management, providing secure access to Amazon Bedrock AgentCore and Amazon DynamoDB services through authenticated user roles.
> The Next.js Web Application uses Amazon Cognito (deployed by Amplify Gen 2) for user authentication and permissions management, providing secure access to Amazon Bedrock AgentCore and Amazon DynamoDB services through authenticated user roles.

> [!TIP]
> You can also change the data source to connect to your preferred database engine by adapting the Agent's instructions and tool implementations.
Expand All @@ -79,19 +81,19 @@ The AgentCore infrastructure handles all storage complexity and provides efficie

The **user interaction workflow** operates as follows:

- The web application sends user business questions to the AgentCore Invoke
- The web application sends user business questions to the AgentCore Invoke (via client-side streaming)
- The Strands Agent (powered by Claude Haiku 4.5) processes natural language and determines when to execute database queries
- The agent's built-in tools execute SQL queries against the Aurora PostgreSQL database and formulate an answer to the question
- AgentCore Memory captures session interactions and retrieves previous conversations for context
- After the agent's response is received by the web application, the raw data query results are retrieved from the DynamoDB table to display both the answer and the corresponding records
- After the agent's streaming response completes, the raw data query results are fetched from DynamoDB through a Next.js API route to display both the answer and the corresponding records
- For chart generation, the application invokes a model (powered by Claude Haiku 4.5) to analyze the agent's answer and raw data query results to generate the necessary data to render an appropriate chart visualization

## Deployment Instructions

The deployment consists of two main steps:

1. **Back-End Deployment - [Amazon Bedrock AgentCore and Data Source Deployment with CDK](./cdk-data-analyst-assistant-agentcore-strands/)**
2. **Front-End Implementation - [Integrating AgentCore with a Ready-to-Use Data Analyst Assistant Application](./amplify-video-games-sales-assistant-agentcore-strands/)**
2. **Front-End Implementation - [Integrating AgentCore with a Ready-to-Use Data Analyst Assistant Application (Next.js)](./amplify-video-games-sales-assistant-agentcore-strands/)**

> [!NOTE]
> *It is recommended to use the Oregon (us-west-2) or N. Virginia (us-east-1) regions to deploy the application.*
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# ──────────────────────────────────────────────────────────────
# Copy this file to .env.local and replace the placeholder values
# with your own configuration:
#
# cp .env.local.example .env.local
#
# All variables are server-side only (no NEXT_PUBLIC_ prefix).
# Client components receive these values as props from server
# component wrappers — they are never exposed to the browser.
# ──────────────────────────────────────────────────────────────

# Application metadata (displayed in the UI and page title)
APP_NAME="Data Analyst Assistant"
APP_DESCRIPTION="Video Games Sales Data Analyst powered by Amazon Bedrock AgentCore"

# ──────────────────────────────────────────────────────────────
# Amazon Bedrock AgentCore Configuration
# ──────────────────────────────────────────────────────────────

# The ARN of your Bedrock AgentCore runtime
AGENT_RUNTIME_ARN="arn:aws:bedrock-agentcore:us-east-1:000000000000:runtime/YourAgentRuntime"

# The endpoint name for the agent (usually "DEFAULT")
AGENT_ENDPOINT_NAME="DEFAULT"

# Number of conversation turns to keep in memory for context
LAST_K_TURNS="10"

# ──────────────────────────────────────────────────────────────
# Assistant UI Configuration
# ──────────────────────────────────────────────────────────────

# Welcome message shown in the chat before any conversation
WELCOME_MESSAGE="I'm your Video Games Sales Data Analyst, crunching data for insights."

# Maximum number of characters allowed in the assistant input
MAX_LENGTH_INPUT_SEARCH="500"

# ──────────────────────────────────────────────────────────────
# Chart Generation (Amazon Bedrock)
# ──────────────────────────────────────────────────────────────

# Model ID used for generating chart configurations
MODEL_ID_FOR_CHART="us.anthropic.claude-haiku-4-5-20251001-v1:0"

# DynamoDB table for storing query results (used by the agent)
QUESTION_ANSWERS_TABLE_NAME="your-query-results-table-name"
Original file line number Diff line number Diff line change
Expand Up @@ -3,47 +3,60 @@
# dependencies
/node_modules
/.pnp
.pnp.js
.pnp.*
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/versions

# testing
/coverage

# next.js
/.next/
/out/

# production
/build

# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.pnpm-debug.log*

# env files (can opt-in for committing if needed)
.env*
!.env.local.example

# vercel
.vercel

package-lock.json
src/env.js
amplify
# typescript
*.tsbuildinfo
next-env.d.ts

#amplify-do-not-edit-begin
amplify/\#current-cloud-backend
amplify/.config/local-*
amplify/logs
amplify/mock-data
amplify/mock-api-resources
# Amplify Gen 2
amplify_outputs.json
.amplify/
amplify/.amplify/
.amplifyrc

# Amplify sandbox CDK artifacts (generated at .amplify/artifacts/)
.amplify/artifacts/

# Amplify legacy CLI artifacts (if old CLI is ever run)
amplify/team-provider-info.json
amplify/#current-cloud-backend
amplify/backend/amplify-meta.json
amplify/backend/.temp
build/
dist/
node_modules/
aws-exports.js
awsconfiguration.json
amplifyconfiguration.json
amplifyconfiguration.dart
amplify-build-config.json
amplify-gradle-config.json
amplifytools.xcconfig
.secret-*
**.sample
#amplify-do-not-edit-end

# OS / Editor
.idea/
.vscode/
.kiro/
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node-linker=hoisted
Loading
Loading