1+ from diagrams import Diagram , Cluster , Edge
2+ from diagrams .aws .compute import Lambda
3+ from diagrams .aws .network import APIGateway , CloudFront , Route53
4+ from diagrams .aws .storage import S3
5+ from diagrams .aws .database import Dynamodb
6+ from diagrams .aws .ml import Sagemaker , Bedrock
7+ from diagrams .aws .security import Cognito , SecretsManager
8+ from diagrams .aws .integration import Eventbridge , SQS , SNS , StepFunctions
9+ from diagrams .aws .analytics import KinesisDataAnalytics
10+ from diagrams .onprem .client import Users
11+
12+ # Configuration for the diagram
13+ graph_attr = {
14+ "fontsize" : "14" ,
15+ "bgcolor" : "white" ,
16+ "pad" : "0.5" ,
17+ }
18+
19+ with Diagram (
20+ "AWS GenAI LLM Chatbot Architecture" ,
21+ filename = "aws_genai_chatbot_architecture" ,
22+ show = False ,
23+ direction = "TB" ,
24+ graph_attr = graph_attr
25+ ):
26+
27+ # Users
28+ user = Users ("Users" )
29+
30+ with Cluster ("Frontend Layer" ):
31+ dns = Route53 ("Route 53" )
32+ cdn = CloudFront ("CloudFront" )
33+ webapp = S3 ("Web App\n (S3 Static Site)" )
34+
35+ with Cluster ("API Layer" ):
36+ apigw = APIGateway ("API Gateway" )
37+ websocket_apigw = APIGateway ("WebSocket API" )
38+
39+ with Cluster ("Authentication" ):
40+ auth = Cognito ("Cognito\n User Pool" )
41+
42+ with Cluster ("Application Logic" ):
43+ with Cluster ("Lambda Functions" ):
44+ api_lambda = Lambda ("API Handler" )
45+ websocket_lambda = Lambda ("WebSocket\n Handler" )
46+ chat_lambda = Lambda ("Chat Processing" )
47+ orchestrator = Lambda ("Orchestrator" )
48+
49+ with Cluster ("AI/ML Services" ):
50+ bedrock = Bedrock ("Amazon Bedrock\n (LLM Models)" )
51+ sagemaker = Sagemaker ("SageMaker\n (Custom Models)" )
52+
53+ with Cluster ("Data Storage" ):
54+ dynamodb = Dynamodb ("DynamoDB\n (Chat History)" )
55+ s3_data = S3 ("S3\n (Documents)" )
56+ secrets = SecretsManager ("Secrets Manager" )
57+
58+ with Cluster ("Message Processing" ):
59+ queue = SQS ("SQS Queue" )
60+ eventbus = Eventbridge ("EventBridge" )
61+ step_func = StepFunctions ("Step Functions\n (Workflow)" )
62+
63+ with Cluster ("Monitoring & Analytics" ):
64+ analytics = KinesisDataAnalytics ("Kinesis\n Analytics" )
65+ notifications = SNS ("SNS\n Notifications" )
66+
67+ # Flow connections
68+ user >> Edge (label = "HTTPS" ) >> dns >> cdn >> webapp
69+
70+ webapp >> Edge (label = "REST API" ) >> apigw
71+ webapp >> Edge (label = "WebSocket" ) >> websocket_apigw
72+
73+ apigw >> auth
74+ websocket_apigw >> auth
75+
76+ auth >> api_lambda
77+ auth >> websocket_lambda
78+
79+ api_lambda >> chat_lambda
80+ websocket_lambda >> chat_lambda
81+
82+ chat_lambda >> orchestrator
83+ orchestrator >> queue
84+ queue >> step_func
85+
86+ step_func >> bedrock
87+ step_func >> sagemaker
88+ step_func >> s3_data
89+
90+ chat_lambda >> dynamodb
91+ orchestrator >> dynamodb
92+
93+ bedrock >> Edge (label = "Response" ) >> orchestrator
94+ sagemaker >> Edge (label = "Response" ) >> orchestrator
95+
96+ orchestrator >> Edge (label = "Store" ) >> dynamodb
97+ s3_data >> Edge (label = "RAG Context" ) >> orchestrator
98+
99+ secrets >> api_lambda
100+ secrets >> chat_lambda
101+
102+ eventbus >> analytics
103+ chat_lambda >> eventbus
104+
105+ analytics >> notifications
0 commit comments