# felipfr/serverless-genai-assistant architecture

> Architecture diagram of the GitHub repository felipfr/serverless-genai-assistant, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-20). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/felipfr/serverless-genai-assistant
- Repository: https://github.com/felipfr/serverless-genai-assistant

## Overview

##### Main Components Identification

- Frontend (Vue.js Application)
- AWS Lambda with FastAPI
- AWS Step Functions
- Amazon Bedrock
- Knowledge Base
- Authentication Layer (AWS Cognito/Lambda JWT Verify)

##### Component Relationships

- → Synchronous requests
- ⇢ Streaming responses
- ⇄ Bidirectional communication

##### Specific Implementation Details

Specialized sections showing:
- Prompt chaining flow
- RAG parallel tasks
- Error handling paths
- State machine workflow

##### Important Notes

Callouts for:
- Response streaming capability
- Synchronous Express Workflow
- Prompt chaining implementation
- Knowledge base integration
- Authentication mechanism

##### Implementation Notes

Technical details about:
- Lambda Web Adapter integration
- Step Functions state machine configuration
- Bedrock model selection
- Knowledge base configuration

- The streaming response architecture
- Parallel execution capabilities
- Prompt chaining implementation
- Error handling mechanisms
- Authentication flow

This system design should reflect both the technical implementation details from the file structure and the architectural concepts described in the README, particularly highlighting the RAG implementation and prompt chaining capabilities.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Client
        UI["Vue.js Frontend"]:::frontend
        Config["Assistant Config UI"]:::frontend
        Chat["Chat Interface"]:::frontend
    end

    subgraph Auth
        JWT["JWT Verification"]:::auth
        Cognito["AWS Cognito"]:::aws
    end

    subgraph "API Layer"
        LambdaURL["Lambda Function URL"]:::aws
        FastAPI["FastAPI Backend"]:::backend
        WebAdapter["Lambda Web Adapter"]:::aws
    end

    subgraph "Orchestration Layer"
        StepFunctions["AWS Step Functions"]:::aws
        RAGWorkflow["RAG Parallel Tasks"]:::workflow
    end

    subgraph "AI/ML Layer"
        Bedrock["Amazon Bedrock"]:::aws
        Claude["Claude 3 Haiku"]:::ai
        Llama["Llama 3"]:::ai
        KB["Knowledge Base"]:::storage
    end

    UI --> |Request| LambdaURL
    Chat --> |Stream| LambdaURL
    Config --> |Config| LambdaURL
    
    LambdaURL --> JWT
    JWT --> FastAPI
    FastAPI --> WebAdapter
    
    FastAPI --> |Invoke| StepFunctions
    StepFunctions --> RAGWorkflow
    RAGWorkflow --> |Query| KB
    RAGWorkflow --> |Generate| Bedrock
    Bedrock --> Claude
    Bedrock --> Llama
    
    RAGWorkflow --> |Response| FastAPI
    FastAPI --> |Stream| UI

    classDef frontend fill:#90EE90
    classDef aws fill:#FF9900
    classDef backend fill:#1E90FF
    classDef auth fill:#DDA0DD
    classDef workflow fill:#FFB6C1
    classDef ai fill:#98FB98
    classDef storage fill:#B8860B

    click UI "https://github.com/felipfr/serverless-genai-assistant/tree/main/examples/sample_web_application/amplify_ui/src/"
    click Chat "https://github.com/felipfr/serverless-genai-assistant/blob/main/examples/sample_web_application/amplify_ui/src/components/ChatComponent.vue"
    click Config "https://github.com/felipfr/serverless-genai-assistant/blob/main/examples/sample_web_application/amplify_ui/src/components/AssistantConfig.vue"
    click FastAPI "https://github.com/felipfr/serverless-genai-assistant/blob/main/examples/sample_web_application/app/main.py"
    click JWT "https://github.com/felipfr/serverless-genai-assistant/tree/main/examples/sample_web_application/lambda-jwt-verify/src/"
    click RAGWorkflow "https://github.com/felipfr/serverless-genai-assistant/blob/main/examples/sample_web_application/statemachine/rag_parallel_tasks/RagGenAI.asl.json"
```
