How pixegami/deploy-rag-to-aws works
Main Components
• Application Container (Dockerized): Based on the “image/” directory, this component is responsible for:
• Ingesting PDF documents (populate_database.py in image/).
• Processing queries: There are two main modes – interactive (using FastAPI via app_api_handler.py) and batch/worker mode (via app_work_handler.py).
• Executing RAG logic: The “rag_app” subdirectory includes modules for obtaining a Chroma database instance (get_chroma_db.py), for fetching an embedding function (get_embedding_function.py), and for querying the RAG system (query_rag.py).
• Query model orchestration: query_model.py likely ties together the query handling and retrieval workflow.
• Data Sources: Inside “image/src/data/source/” you have source PDFs (e.g., galaxy-design-client-guide.pdf). These are used to build the vector DB.
• External AWS Services:
• AWS Bedrock for LLM and embedding functionalities.
• DynamoDB for data storage (as indicated by environment variables and the mention of TABLE_NAME).
• Infrastructure Provisioning (rag-cdk-infra): AWS CDK scripts in this directory deploy the AWS resources that the application interacts with.
Relationships and Interactions
• User Interaction & Query Lifecycle:
• When a user sends a query, it is received via a FastAPI endpoint (app_api_handler.py) or executed via the work handler in Docker.
• The query passes to the query model logic (inside rag_app) where the system retrieves relevant content from the vector store (likely managed via Chroma and DynamoDB) and interacts with AWS Bedrock (or similar LLM service) to generate a response.
• Data Ingestion:
• A dedicated pipeline (populate_database.py) reads PDF files from the source directory, processes them, and populates the vector database.
• Deployment & Infrastructure:
Architectural Patterns/Design Principles
• Modular Design: The separation between data ingestion, query-processing, and API-handling is clear.
• Containerization: The application is containerized through Docker, ensuring portability across local and cloud environments.
• Infrastructure as Code: Use of AWS CDK indicates that provisioning is automated and version-controlled.
• Separation of Concerns: The clear split between application logic (in the “image/” directory) and deployment/infrastructure (in “rag-cdk-infra”) reinforces best practices.