The lib
directory contains the core logic and infrastructure definitions for the application, structured to provide modularity and scalability. The architecture is designed to integrate seamlessly with AWS services, ensuring a robust, scalable, and secure solution. Below is a detailed overview of the components and how they interact with the AWS ecosystem.
Handles authentication and user group management.
Key Components:
- user-group-handler/: Manages group membership and permissions, interacting with Amazon Cognito for user pool management.
- websocket-api-authorizer/: Implements authorization logic for WebSocket APIs, leveraging custom Lambda authorizers and Cognito.
- README-auth.md: Documentation for authorization components.
- index.*: Entry points for the authorization module.
AWS Services:
- Amazon Cognito: Manages user authentication and authorization.
- IAM: Enforces fine-grained permissions for resources.
Encapsulates the chatbot's backend logic, integrating various AWS services for storage, search, and API handling.
Subcomponents:
- Buckets (
buckets/
):- Defines S3 buckets for storing chatbot-related data, feedback, and temporary files.
- Supports secure file upload and download using presigned URLs.
- Functions (
functions/
):- Lambda functions handle API operations like processing feedback, interacting with DynamoDB, and generating presigned URLs for S3.
- Gateway (
gateway/
):- Configures API Gateway for routing HTTP and WebSocket requests to backend services.
- Kendra (
kendra/
):- Integrates with Amazon Kendra to provide intelligent search capabilities.
- Tables (
tables/
):- DynamoDB table definitions store chatbot session data, user feedback, and related metadata.
- index.*: Entry points for the chatbot API.
AWS Services:
- API Gateway: Routes requests to Lambda functions.
- Lambda: Processes chatbot logic and backend interactions.
- DynamoDB: Stores structured data for sessions and feedback.
- Amazon Kendra: Powers advanced search capabilities for the chatbot.
- S3: Stores files and feedback exports.
Contains reusable utility functions for common operations.
Key Components:
- utils.*: Scripts and modules in TypeScript, JavaScript, and declaration formats for shared functionality.
AWS Services:
- None directly; supports other modules.
Defines the user-facing elements of the application, including the website and frontend components.
Key Components:
- app/: Application code for the UI.
- README-ui.md: Documentation for the user interface.
- generate-app.*: Scripts for dynamic generation of application components.
- index.*: Entry points for the user interface module.
Deployment and Architecture:
- AWS Amplify: Used to connect the UI to Amazon Cognito for authentication.
- S3: Hosts the static files for the UI.
- CloudFront: Distributes the UI globally via a Content Delivery Network (CDN), ensuring low latency and high availability.
- CORS Configuration: Supports secure cross-origin resource sharing for API interactions.
The application uses two API Gateway configurations for managing HTTP and WebSocket requests:
- REST API Gateway:
- Handles standard HTTP requests routed to Lambda functions or other AWS resources.
- Integrates with DynamoDB, S3, and Amazon Kendra.
- WebSocket API Gateway:
- Provides persistent connections for real-time, two-way communication.
- Ideal for chat messaging or live updates.
- README-lib.md: This documentation file for the
lib
directory. - cdk-rag-app-stack.*: Infrastructure definitions for the application stack using AWS CDK.
- The architecture leverages AWS CDK for infrastructure as code, ensuring consistent and repeatable deployments.
- Each module is designed to integrate seamlessly with AWS services for scalability, reliability, and security.
- CORS Settings: Configured for development but should be restricted in production.
-
Authorization
-
Chatbot API
-
Shared Utilities
-
User Interface
Please refer to the individual READMEs for detailed information about each component.