Rammanokar commited on
Commit
1f6521a
·
verified ·
1 Parent(s): fea0c80

make this as html traffic flow diagram,

Browse files

convert this to react diagram.


```mermaid
graph
Internet[Internet]

subgraph "Production VPC - 15.0.0.0/16"
IGW_Prod[Internet Gateway<br/>igw-09cf4bcb7239a6547]
LB_Prod[Internal Load Balancer<br/>ieq-prod-lb]

subgraph "us-east-1a"
PubSub1[Public Subnet<br/>15.0.0.0/20]
EC2Prod1[BE Prod<br/>3.220.214.17<br/>t2.small]
EC2Prod2[BE Admin Prod<br/>3.227.125.175<br/>t2.small]
EC2ML_Prod[ML Prod<br/>98.83.117.30<br/>t2.medium]
end

subgraph "us-east-1b"
PubSub2[Public Subnet<br/>15.0.16.0/20]
end

Internet --> IGW_Prod
IGW_Prod --> PubSub1
IGW_Prod --> PubSub2
PubSub1 --> EC2Prod1
PubSub1 --> EC2Prod2
PubSub1 --> EC2ML_Prod
LB_Prod --> EC2Prod1
end
```
```mermaid
graph TB


Internet[Internet]

subgraph "Default VPC - 172.31.0.0/16 (Dev & PreProd)"
IGW_Default[Internet Gateway<br/>igw-08f0068d5deb99f34]

subgraph "Development Environment"
DevBE[BE Dev<br/>23.22.6.48<br/>t2.small]
DevAdmin[BE Admin Dev<br/>34.225.40.84<br/>t2.micro]
DevML[ML Dev<br/>54.225.50.5<br/>t2.medium]
DevAV[AV Processing<br/>54.224.121.98<br/>t2.small]
end

subgraph "PreProduction Environment"
PreBE[BE PreProd<br/>44.214.177.246<br/>t2.small]
PreAdmin[BE Admin PreProd<br/>34.193.219.91<br/>t2.small]
PreML[ML PreProd<br/>18.234.27.117<br/>c5.2xlarge]
PreMCP[MCP PreProd<br/>44.204.54.3<br/>t2.medium]
end

LB_Dev[ALB: ieq-be-dev<br/>ieq-be-admin-dev-lb]
LB_MCP[Internal ALB<br/>ieq-mcp-stage-lb]

Internet --> IGW_Default
IGW_Default --> DevBE
IGW_Default --> DevAdmin
IGW_Default --> DevML
IGW_Default --> DevAV
IGW_Default --> PreBE
IGW_Default --> PreAdmin
IGW_Default --> PreML
IGW_Default --> PreMCP

LB_Dev --> DevBE
LB_Dev --> DevAdmin
LB_MCP --> PreMCP
end


```

Files changed (1) hide show
  1. script.js +159 -242
script.js CHANGED
@@ -1,277 +1,194 @@
1
  x
2
  const { useState, useEffect } = React;
3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
  const VPCDiagram = () => {
5
  const [selectedComponent, setSelectedComponent] = useState(null);
6
 
7
- const productionComponents = [
8
- {
9
- id: 'igw-prod',
10
- type: 'Internet Gateway',
11
- name: 'Internet Gateway',
12
- details: 'igw-09cf4bcb7239a6547',
13
- icon: 'globe'
14
- },
15
- {
16
- id: 'lb-prod',
17
- type: 'Load Balancer',
18
- name: 'Internal Load Balancer',
19
- details: 'ieq-prod-lb',
20
- icon: 'layers'
21
- },
22
- {
23
- id: 'ec2-prod-1',
24
- type: 'EC2 Instance',
25
- name: 'BE Prod',
26
- details: '3.220.214.17 - t2.small',
27
- icon: 'server'
28
- },
29
- {
30
- id: 'ec2-prod-2',
31
- type: 'EC2 Instance',
32
- name: 'BE Admin Prod',
33
- details: '3.227.125.175 - t2.small',
34
- icon: 'server'
35
- },
36
- {
37
- id: 'ec2-ml-prod',
38
- type: 'EC2 Instance',
39
- name: 'ML Prod',
40
- details: '98.83.117.30 - t2.medium',
41
- icon: 'cpu'
42
- }
43
- ];
44
 
45
- const developmentComponents = [
46
- {
47
- id: 'dev-be',
48
- type: 'EC2 Instance',
49
- name: 'BE Dev',
50
- details: '23.22.6.48 - t2.small',
51
- icon: 'server'
52
- },
53
- {
54
- id: 'dev-admin',
55
- type: 'EC2 Instance',
56
- name: 'BE Admin Dev',
57
- details: '34.225.40.84 - t2.micro',
58
- icon: 'server'
59
- },
60
- {
61
- id: 'dev-ml',
62
- type: 'EC2 Instance',
63
- name: 'ML Dev',
64
- details: '54.225.50.5 - t2.medium',
65
- icon: 'cpu'
66
- },
67
- {
68
- id: 'dev-av',
69
- type: 'EC2 Instance',
70
- name: 'AV Processing',
71
- details: '54.224.121.98 - t2.small',
72
- icon: 'shield'
73
- },
74
- {
75
- id: 'lb-dev',
76
- type: 'Load Balancer',
77
- name: 'ALB Dev',
78
- details: 'ieq-be-dev',
79
- icon: 'layers'
80
- }
81
- ];
82
 
83
- const preproductionComponents = [
84
- {
85
- id: 'pre-be',
86
- type: 'EC2 Instance',
87
- name: 'BE PreProd',
88
- details: '44.214.177.246 - t2.small',
89
- icon: 'server'
90
- },
91
- {
92
- id: 'pre-admin',
93
- type: 'EC2 Instance',
94
- name: 'BE Admin PreProd',
95
- details: '34.193.219.91 - t2.small',
96
- icon: 'server'
97
- },
98
- {
99
- id: 'pre-ml',
100
- type: 'EC2 Instance',
101
- name: 'ML PreProd',
102
- details: '18.234.27.117 - c5.2xlarge',
103
- icon: 'cpu'
104
- },
105
- {
106
- id: 'pre-mcp',
107
- type: 'EC2 Instance',
108
- name: 'MCP PreProd',
109
- details: '44.204.54.3 - t2.medium',
110
- icon: 'zap'
111
- },
112
- {
113
- id: 'lb-mcp',
114
- type: 'Load Balancer',
115
- name: 'Internal ALB',
116
- details: 'ieq-mcp-stage-lb',
117
- icon: 'layers'
118
- }
119
  ];
120
 
121
- const ComponentCard = ({ component, onClick }) => {
122
- const getComponentClass = (type) => {
123
- switch (type) {
124
- case 'Internet Gateway':
125
- return 'internet-gateway';
126
- case 'Load Balancer':
127
- return 'load-balancer';
128
- case 'EC2 Instance':
129
- return 'ec2-instance';
130
- default:
131
- return '';
132
- }
133
- };
 
 
134
 
135
- return (
136
- <div
137
- className={`component ${getComponentClass(component.type)}`}
138
- onClick={() => onClick(component)}
139
- >
140
- <i data-feather={component.icon} className="component-icon"></i>
141
- <div className="component-title">{component.name}</div>
142
- <div className="component-details">{component.details}</div>
143
  </div>
144
- );
145
- };
146
-
147
- const ConnectionFlow = () => (
148
- <div className="connections">
149
- <h3>Connection Flow</h3>
150
- <div className="connection-flow">
151
- <div className="connection-item">
152
- <i data-feather="globe"></i> Internet
153
- </div>
154
- <div className="arrow">→</div>
155
- <div className="connection-item">
156
- <i data-feather="shield"></i> Internet Gateway
157
- </div>
158
- <div className="arrow">→</div>
159
- <div className="connection-item">
160
- <i data-feather="layers"></i> Load Balancer
161
- </div>
162
- <div className="arrow">→</div>
163
- <div className="connection-item">
164
- <i data-feather="server"></i> EC2 Instances
165
- </div>
166
  </div>
167
  </div>
168
  );
169
 
170
- const Stats = () => (
171
- <div className="stats">
172
- <h3>Infrastructure Overview</h3>
173
- <div className="stats-grid">
174
- <div className="stat-item">
175
- <div className="stat-number">2</div>
176
- <div className="stat-label">VPCs</div>
177
- </div>
178
- <div className="stat-item">
179
- <div className="stat-number">13</div>
180
- <div className="stat-label">EC2 Instances</div>
181
- </div>
182
- <div className="stat-item">
183
- <div className="stat-number">4</div>
184
- <div className="stat-label">Load Balancers</div>
185
- </div>
186
- <div className="stat-item">
187
- <div className="stat-number">2</div>
188
- <div className="stat-label">Internet Gateways</div>
189
  </div>
190
  </div>
191
- </div>
192
- );
193
 
194
  useEffect(() => {
195
  feather.replace();
196
  }, []);
197
 
198
- const handleComponentClick = (component) => {
199
- setSelectedComponent(component);
200
- };
201
-
202
  return (
203
  <div className="container">
204
  <div className="header">
205
- <h1>AWS VPC Architecture Diagram</h1>
206
- <p>Interactive visualization of Production and Development VPC infrastructure</p>
207
  </div>
208
 
209
  <div className="diagram-container">
210
- {/* Production VPC */}
211
- <div className="vpc-section">
212
- <div className="vpc-header">
213
- <h2>Production VPC</h2>
214
- <p>15.0.0.0/16</p>
215
- </div>
216
-
217
- <div className="environments-grid">
218
- <div className="environment">
219
- <h3>Production Environment</h3>
220
- <div className="components-grid">
221
- {productionComponents.map(component => (
222
- <ComponentCard
223
- key={component.id}
224
- component={component}
225
- onClick={handleComponentClick}
226
- />
227
- ))}
228
- </div>
229
- </div>
230
- </div>
231
- </div>
232
-
233
- {/* Development VPC */}
234
- <div className="vpc-section">
235
- <div className="vpc-header">
236
- <h2>Default VPC</h2>
237
- <p>172.31.0.0/16 (Dev & PreProd)</p>
238
- </div>
239
-
240
- <div className="environments-grid">
241
- <div className="environment">
242
- <h3>Development Environment</h3>
243
- <div className="components-grid">
244
- {developmentComponents.map(component => (
245
- <ComponentCard
246
- key={component.id}
247
- component={component}
248
- onClick={handleComponentClick}
249
- />
250
- ))}
251
- </div>
252
- </div>
253
-
254
- <div className="environment">
255
- <h3>PreProduction Environment</h3>
256
- <div className="components-grid">
257
- {preproductionComponents.map(component => (
258
- <ComponentCard
259
- key={component.id}
260
- component={component}
261
- onClick={handleComponentClick}
262
- />
263
- ))}
264
- </div>
265
- </div>
266
- </div>
267
- </div>
268
-
269
- <ConnectionFlow />
270
- <Stats />
271
  </div>
 
 
272
  </div>
273
  );
274
  };
275
 
276
  const root = ReactDOM.createRoot(document.getElementById('root'));
277
- root.render(<VPCDiagram />);
 
1
  x
2
  const { useState, useEffect } = React;
3
 
4
+ const FlowNode = ({ id, title, details, type, position, onClick }) => {
5
+ const getNodeClass = (type) => {
6
+ switch (type) {
7
+ case 'internet':
8
+ return 'internet-node';
9
+ case 'igw':
10
+ return 'igw-node';
11
+ case 'subnet':
12
+ return 'subnet-node';
13
+ case 'ec2':
14
+ return 'ec2-node';
15
+ case 'lb':
16
+ return 'lb-node';
17
+ default:
18
+ return 'default-node';
19
+ }
20
+ };
21
+
22
+ return (
23
+ <div
24
+ className={`flow-node ${getNodeClass(type)}`}
25
+ style={{ left: position.x, top: position.y }}
26
+ onClick={() => onClick && onClick({ id, title, details, type })}
27
+ >
28
+ <div className="node-title">{title}</div>
29
+ {details && <div className="node-details">{details}</div>}
30
+ </div>
31
+ );
32
+ };
33
+
34
+ const FlowArrow = ({ from, to }) => {
35
+ const deltaX = to.x - from.x;
36
+ const deltaY = to.y - from.y;
37
+ const length = Math.sqrt(deltaX * deltaX + deltaY * deltaY);
38
+ const angle = Math.atan2(deltaY, deltaX) * 180 / Math.PI;
39
+
40
+ return (
41
+ <div
42
+ className="flow-arrow"
43
+ style={{
44
+ left: from.x,
45
+ top: from.y,
46
+ width: length,
47
+ transform: `rotate(${angle}deg)`,
48
+ transformOrigin: '0 0'
49
+ }}
50
+ />
51
+ );
52
+ };
53
+
54
  const VPCDiagram = () => {
55
  const [selectedComponent, setSelectedComponent] = useState(null);
56
 
57
+ // Production VPC flow configuration
58
+ const prodFlow = {
59
+ internet: { id: 'prod-internet', title: 'Internet', type: 'internet', position: { x: 50, y: 100 } },
60
+ igw: { id: 'prod-igw', title: 'Internet Gateway', details: 'igw-09cf4bcb7239a6547', type: 'igw', position: { x: 300, y: 100 } },
61
+ pubsub1: { id: 'prod-pubsub1', title: 'Public Subnet', details: '15.0.0.0/20\nus-east-1a', type: 'subnet', position: { x: 550, y: 50 } },
62
+ pubsub2: { id: 'prod-pubsub2', title: 'Public Subnet', details: '15.0.16.0/20\nus-east-1b', type: 'subnet', position: { x: 550, y: 150 } },
63
+ ec2prod1: { id: 'prod-ec2-1', title: 'BE Prod', details: '3.220.214.17\nt2.small', type: 'ec2', position: { x: 800, y: 20 } },
64
+ ec2prod2: { id: 'prod-ec2-2', title: 'BE Admin Prod', details: '3.227.125.175\nt2.small', type: 'ec2', position: { x: 800, y: 80 } },
65
+ ec2ml: { id: 'prod-ec2-ml', title: 'ML Prod', details: '98.83.117.30\nt2.medium', type: 'ec2', position: { x: 800, y: 140 } },
66
+ lbprod: { id: 'prod-lb', title: 'Internal Load Balancer', details: 'ieq-prod-lb', type: 'lb', position: { x: 1050, y: 80 } }
67
+ };
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
68
 
69
+ // Default VPC flow configuration
70
+ const defaultFlow = {
71
+ internet: { id: 'def-internet', title: 'Internet', type: 'internet', position: { x: 50, y: 400 } },
72
+ igw: { id: 'def-igw', title: 'Internet Gateway', details: 'igw-08f0068d5deb99f34', type: 'igw', position: { x: 300, y: 400 } },
73
+
74
+ // Development Environment
75
+ devbe: { id: 'dev-be', title: 'BE Dev', details: '23.22.6.48\nt2.small', type: 'ec2', position: { x: 600, y: 320 } },
76
+ devadmin: { id: 'dev-admin', title: 'BE Admin Dev', details: '34.225.40.84\nt2.micro', type: 'ec2', position: { x: 600, y: 370 } },
77
+ devml: { id: 'dev-ml', title: 'ML Dev', details: '54.225.50.5\nt2.medium', type: 'ec2', position: { x: 600, y: 420 } },
78
+ devav: { id: 'dev-av', title: 'AV Processing', details: '54.224.121.98\nt2.small', type: 'ec2', position: { x: 600, y: 470 } },
79
+
80
+ // PreProduction Environment
81
+ prebe: { id: 'pre-be', title: 'BE PreProd', details: '44.214.177.246\nt2.small', type: 'ec2', position: { x: 900, y: 320 } },
82
+ preadmin: { id: 'pre-admin', title: 'BE Admin PreProd', details: '34.193.219.91\nt2.small', type: 'ec2', position: { x: 900, y: 370 } },
83
+ preml: { id: 'pre-ml', title: 'ML PreProd', details: '18.234.27.117\nc5.2xlarge', type: 'ec2', position: { x: 900, y: 420 } },
84
+ premcp: { id: 'pre-mcp', title: 'MCP PreProd', details: '44.204.54.3\nt2.medium', type: 'ec2', position: { x: 900, y: 470 } },
85
+
86
+ // Load Balancers
87
+ lbdev: { id: 'dev-lb', title: 'ALB Dev', details: 'ieq-be-dev\nieq-be-admin-dev-lb', type: 'lb', position: { x: 1200, y: 345 } },
88
+ lbmcp: { id: 'pre-lb', title: 'Internal ALB', details: 'ieq-mcp-stage-lb', type: 'lb', position: { x: 1200, y: 445 } }
89
+ };
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
90
 
91
+ // Production connections
92
+ const prodConnections = [
93
+ { from: 'prod-internet', to: 'prod-igw' },
94
+ { from: 'prod-igw', to: 'prod-pubsub1' },
95
+ { from: 'prod-igw', to: 'prod-pubsub2' },
96
+ { from: 'prod-pubsub1', to: 'prod-ec2-1' },
97
+ { from: 'prod-pubsub1', to: 'prod-ec2-2' },
98
+ { from: 'prod-pubsub1', to: 'prod-ec2-ml' },
99
+ { from: 'prod-lb', to: 'prod-ec2-1' }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
100
  ];
101
 
102
+ // Default VPC connections
103
+ const defaultConnections = [
104
+ { from: 'def-internet', to: 'def-igw' },
105
+ { from: 'def-igw', to: 'dev-be' },
106
+ { from: 'def-igw', to: 'dev-admin' },
107
+ { from: 'def-igw', to: 'dev-ml' },
108
+ { from: 'def-igw', to: 'dev-av' },
109
+ { from: 'def-igw', to: 'pre-be' },
110
+ { from: 'def-igw', to: 'pre-admin' },
111
+ { from: 'def-igw', to: 'pre-ml' },
112
+ { from: 'def-igw', to: 'pre-mcp' },
113
+ { from: 'dev-lb', to: 'dev-be' },
114
+ { from: 'dev-lb', to: 'dev-admin' },
115
+ { from: 'pre-lb', to: 'pre-mcp' }
116
+ ];
117
 
118
+ const VPCSection = ({ title, vpc, flow, connections }) => (
119
+ <div className="vpc-flow-section">
120
+ <div className="vpc-flow-header">
121
+ <h2>{title}</h2>
 
 
 
 
122
  </div>
123
+ <div className="flow-diagram">
124
+ {connections.map((conn, index) => (
125
+ <FlowArrow
126
+ key={index}
127
+ from={flow[conn.from].position}
128
+ to={flow[conn.to].position}
129
+ />
130
+ ))}
131
+ {Object.values(flow).map((node) => (
132
+ <FlowNode
133
+ key={node.id}
134
+ id={node.id}
135
+ title={node.title}
136
+ details={node.details}
137
+ type={node.type}
138
+ position={node.position}
139
+ onClick={setSelectedComponent}
140
+ />
141
+ ))}
 
 
 
142
  </div>
143
  </div>
144
  );
145
 
146
+ const ComponentDetails = () => {
147
+ if (!selectedComponent) return null;
148
+
149
+ return (
150
+ <div className="component-details-overlay" onClick={() => setSelectedComponent(null)}>
151
+ <div className="component-details-panel" onClick={(e) => e.stopPropagation()}>
152
+ <h3>{selectedComponent.title}</h3>
153
+ {selectedComponent.details && <p>{selectedComponent.details}</p>}
154
+ <p>Type: {selectedComponent.type}</p>
155
+ <button onClick={() => setSelectedComponent(null)}>Close</button>
 
 
 
 
 
 
 
 
 
156
  </div>
157
  </div>
158
+ );
159
+ };
160
 
161
  useEffect(() => {
162
  feather.replace();
163
  }, []);
164
 
 
 
 
 
165
  return (
166
  <div className="container">
167
  <div className="header">
168
+ <h1>AWS VPC Traffic Flow Diagram</h1>
169
+ <p>Interactive visualization of Production and Development VPC traffic patterns</p>
170
  </div>
171
 
172
  <div className="diagram-container">
173
+ <VPCSection
174
+ title="Production VPC - 15.0.0.0/16"
175
+ vpc="production"
176
+ flow={prodFlow}
177
+ connections={prodConnections}
178
+ />
179
+
180
+ <VPCSection
181
+ title="Default VPC - 172.31.0.0/16 (Dev & PreProd)"
182
+ vpc="default"
183
+ flow={defaultFlow}
184
+ connections={defaultConnections}
185
+ />
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
186
  </div>
187
+
188
+ <ComponentDetails />
189
  </div>
190
  );
191
  };
192
 
193
  const root = ReactDOM.createRoot(document.getElementById('root'));
194
+ root.render(<VPCDiagram />);