How aws-samples/artifacts-and-tools-for-bedrock works
Main components
• Frontend/User Interface:
– Found in “lib/playground/user-interface”.
– Built with Typescript/React (TSX, HTML, SCSS, etc.).
– Downloads configuration (aws-exports.json) at runtime and interacts with backend endpoints.
• API/Backend Services:
– Organized in “lib/playground/functions”.
– Split across several modules and responsibilities including “api-handler” (handling routes for files, health, sessions), “message-handler” for handling interactive chat/messaging features, “authorizer” for access control, and “connection-handler”.
• AWS Deployment/Infrastructure:
– Infrastructure described in CDK-related files (e.g., “cdk.json”, “lib/stack.ts”) and deployment scripts (bin/artifacts-and-tools.ts).
– Components such as API Gateway, Lambda functions, AWS Cognito (for user authentication), CloudFront distribution, and others are provisioned as part of the deployment.
• Tools and External Services:
– Code Interpreter (under “lib/tools/code-interpreter”) – includes its own Dockerfile, Python logic, and dependencies.
– Web Search Tool (under “lib/tools/web-search”) – integrates externally via the Brave Search API; it includes its own Dockerfile and TypeScript/Node based logic.
– Artifacts functionality for content visualization.
And represent relationships and interactions
• The user accesses the web application (CloudFront distribution serving static files and the UI) and logs in via Cognito.
• The UI interacts with the backend APIs (exposed via API routes, as organized in the “api-handler” module) for retrieving data, managing sessions, and uploading/fetching files.
• Serverless functions (Lambda functions or containers for Code Interpreter and Web Search) provide the dynamic backend logic; they interact with each other when orchestrating tasks.
• The AWS CDK stack encapsulates the provisioning of these components, ensuring that the various services are instantiated with correct inter-dependencies.
Architectural patterns and design principles
• Modular microservices/serverless pattern: the backend is separated into distinct functions (such as message handling, authorization, and connection management), each with its own directory and responsibilities.
• Separation of concerns between the presentation layer (UI) and the business logic/engine (Lambda functions and tools).
• Infrastructure-as-Code (using AWS CDK) that allows reproducible deployment setups.
Relevant technologies and tools
• Frontend: React, Typescript, Vite (as seen from vite.config.ts), SCSS for styling, and various UI components for chat and sessions.
• Backend: Python for some functions (especially in “api-handler”) and Node/Typescript in others (e.g., “user-interface”, “web-search”).
• AWS Services: Lambda, Cognito, CloudFront, and AWS CDK for deployment orchestration.
• Docker: Used for building container images for Code Interpreter and Web Search tools.