-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathc4_contatiner_diagram_system.py
266 lines (245 loc) · 11.4 KB
/
c4_contatiner_diagram_system.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
from diagrams import Diagram
from diagrams.aws.storage import S3
from diagrams.c4 import Person, Container, Database, System, SystemBoundary, Relationship
graph_attr = {
"splines": "spline",
"nodesep": "1.0", # Decrease space between nodes
"ranksep": "2.0" # Decrease space between ranks to encourage vertical alignment
}
with Diagram("Container Diagram for MiniSpace System", direction="TB", graph_attr=graph_attr):
user = Person(name="MiniSpace User", description="User interacting with the MiniSpace system.")
with SystemBoundary("MiniSpace System"):
# Grouping related services together to encourage vertical growth
api_gateway = Container(
name="API Gateway Interface",
technology="Spring Boot",
description="Serves as an entry point for API requests."
)
fabio_load_balancer = Container(
name="Fabio Load Balancer",
technology="HAProxy",
description="Balances the load among HTTP clients using Consul."
)
# Monitoring and Event Handling
event_bus = Container(
name="Event Bus",
technology="RabbitMQ",
description="Handles the events within the system."
)
consul = Container(
name="Consul",
technology="HashiCorp Consul",
description="Service discovery and configuration management."
)
jaeger = Container(
name="Jaeger",
technology="Jaeger",
description="Distributed tracing for monitoring and troubleshooting."
)
seq = Container(
name="Seq",
technology="Seq",
description="Centralized logging for monitoring and alerting."
)
prometheus = Container(
name="Prometheus",
technology="Prometheus",
description="Monitoring and alerting toolkit."
)
grafana = Container(
name="Grafana",
technology="Grafana",
description="Analytics and monitoring dashboard."
)
# Services - Aligned Vertically
comments_service = Container(
name="Comments Service",
technology=".NET",
description="Manages comments on posts."
)
email_service = Container(
name="Email Service",
technology=".NET",
description="Handles email notifications and communication."
)
events_service = Container(
name="Events Service",
technology=".NET",
description="Manages event-related data and services."
)
friends_service = Container(
name="Friends Service",
technology=".NET",
description="Manages friend relationships and connections."
)
identity_service = Container(
name="Identity Service",
technology=".NET",
description="Handles user identity and authentication."
)
media_files_service = Container(
name="Media Files Service",
technology=".NET",
description="Manages media files uploaded by users."
)
notifications_service = Container(
name="Notifications Service",
technology=".NET",
description="Manages notifications to users."
)
organizations_service = Container(
name="Organizations Service",
technology=".NET",
description="Manages organization-related data."
)
posts_service = Container(
name="Posts Service",
technology=".NET",
description="Manages user posts and related data."
)
reactions_service = Container(
name="Reactions Service",
technology=".NET",
description="Handles reactions (likes, dislikes) on posts."
)
reports_service = Container(
name="Reports Service",
technology=".NET",
description="Manages user reports on content or behavior."
)
students_service = Container(
name="Students Service",
technology=".NET",
description="Handles student-specific data and operations."
)
# Databases - Aligned Vertically
comments_db = Database(
name="Comments Database",
technology="MongoDB",
description="Stores comment-related data."
)
email_db = Database(
name="Email Database",
technology="MongoDB",
description="Stores email-related data."
)
events_db = Database(
name="Events Database",
technology="MongoDB",
description="Stores event-related data."
)
friends_db = Database(
name="Friends Database",
technology="MongoDB",
description="Stores friend relationship data."
)
identity_db = Database(
name="Identity Database",
technology="MongoDB",
description="Stores identity and authentication data."
)
media_files_db = Database(
name="Media Files Database",
technology="MongoDB",
description="Stores media file data."
)
notifications_db = Database(
name="Notifications Database",
technology="MongoDB",
description="Stores notification data."
)
organizations_db = Database(
name="Organizations Database",
technology="MongoDB",
description="Stores organization-related data."
)
posts_db = Database(
name="Posts Database",
technology="MongoDB",
description="Stores post-related data."
)
reactions_db = Database(
name="Reactions Database",
technology="MongoDB",
description="Stores reaction-related data."
)
reports_db = Database(
name="Reports Database",
technology="MongoDB",
description="Stores report-related data."
)
students_db = Database(
name="Students Database",
technology="MongoDB",
description="Stores student-related data."
)
# AWS S3 Bucket connected to Media Files Service
s3_bucket = S3("S3 Replication Bucket")
# Define Relationships
user >> Relationship("Uses") >> api_gateway
api_gateway >> Relationship("Routes requests through") >> fabio_load_balancer
fabio_load_balancer >> Relationship("Forwards requests to") >> [
comments_service,
email_service,
events_service,
friends_service,
identity_service,
media_files_service,
notifications_service,
organizations_service,
posts_service,
reactions_service,
reports_service,
students_service
]
comments_service >> Relationship("Stores data in") >> comments_db
email_service >> Relationship("Stores data in") >> email_db
events_service >> Relationship("Stores data in") >> events_db
friends_service >> Relationship("Stores data in") >> friends_db
identity_service >> Relationship("Stores data in") >> identity_db
media_files_service >> Relationship("Stores data in") >> media_files_db
notifications_service >> Relationship("Stores data in") >> notifications_db
organizations_service >> Relationship("Stores data in") >> organizations_db
posts_service >> Relationship("Stores data in") >> posts_db
reactions_service >> Relationship("Stores data in") >> reactions_db
reports_service >> Relationship("Stores data in") >> reports_db
students_service >> Relationship("Stores data in") >> students_db
# Service Discovery, Tracing, and Monitoring
fabio_load_balancer >> Relationship("Registers with") >> consul
[comments_service, email_service, events_service, friends_service, identity_service, media_files_service,
notifications_service, organizations_service, posts_service, reactions_service, reports_service, students_service] >> Relationship("Registers with") >> consul
# API Gateway connects to Jaeger, Seq, Prometheus, and Grafana directly
api_gateway >> Relationship("Sends tracing data to") >> jaeger
api_gateway >> Relationship("Sends logs to") >> seq
api_gateway >> Relationship("Sends metrics to") >> prometheus
prometheus >> Relationship("Visualizes metrics in") >> grafana
# Services sending events to Event Bus
comments_service >> Relationship("Sends: CommentAddedEvent, CommentUpdatedEvent") >> event_bus
email_service >> Relationship("Sends: EmailSentEvent, EmailFailedEvent") >> event_bus
events_service >> Relationship("Sends: EventCreatedEvent, EventUpdatedEvent") >> event_bus
friends_service >> Relationship("Sends: FriendAddedEvent, FriendRemovedEvent") >> event_bus
identity_service >> Relationship("Sends: UserAuthenticatedEvent, UserAuthorizationUpdatedEvent") >> event_bus
media_files_service >> Relationship("Sends: MediaFileUploadedEvent, MediaFileDeletedEvent") >> event_bus
notifications_service >> Relationship("Sends: NotificationSentEvent, NotificationFailedEvent") >> event_bus
organizations_service >> Relationship("Sends: OrganizationCreatedEvent, OrganizationUpdatedEvent") >> event_bus
posts_service >> Relationship("Sends: PostCreatedEvent, PostUpdatedEvent") >> event_bus
reactions_service >> Relationship("Sends: ReactionAddedEvent, ReactionRemovedEvent") >> event_bus
reports_service >> Relationship("Sends: ReportFiledEvent, ReportReviewedEvent") >> event_bus
students_service >> Relationship("Sends: StudentEnrolledEvent, StudentUpdatedEvent") >> event_bus
# Services consuming events from Event Bus
comments_service << Relationship("Consumes: CommentAddedEvent, CommentUpdatedEvent") << event_bus
email_service << Relationship("Consumes: EmailSentEvent, EmailFailedEvent") << event_bus
events_service << Relationship("Consumes: EventCreatedEvent, EventUpdatedEvent") << event_bus
friends_service << Relationship("Consumes: FriendAddedEvent, FriendRemovedEvent") << event_bus
identity_service << Relationship("Consumes: UserAuthenticatedEvent, UserAuthorizationUpdatedEvent") << event_bus
media_files_service << Relationship("Consumes: MediaFileUploadedEvent, MediaFileDeletedEvent") << event_bus
notifications_service << Relationship("Consumes: NotificationSentEvent, NotificationFailedEvent") << event_bus
organizations_service << Relationship("Consumes: OrganizationCreatedEvent, OrganizationUpdatedEvent") << event_bus
posts_service << Relationship("Consumes: PostCreatedEvent, PostUpdatedEvent") << event_bus
reactions_service << Relationship("Consumes: ReactionAddedEvent, ReactionRemovedEvent") << event_bus
reports_service << Relationship("Consumes: ReportFiledEvent, ReportReviewedEvent") << event_bus
students_service << Relationship("Consumes: StudentEnrolledEvent, StudentUpdatedEvent") << event_bus
# Direct connection from Notifications Service to the User application
notifications_service >> Relationship("Pushes notifications to") >> user
# Connection from Media Files Service to S3 Replication Bucket
media_files_service >> Relationship("Stores media in") >> s3_bucket