-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathleetcode.drawio
More file actions
114 lines (114 loc) · 13.9 KB
/
leetcode.drawio
File metadata and controls
114 lines (114 loc) · 13.9 KB
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
<mxfile host="app.diagrams.net" agent="Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36" version="26.2.14">
<diagram name="Page-1" id="gq-hixOonSzh3Yw3gc1U">
<mxGraphModel dx="1205" dy="760" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="850" pageHeight="1100" math="0" shadow="0">
<root>
<mxCell id="0" />
<mxCell id="1" parent="0" />
<mxCell id="vMsRpWaaGCRmH829zkNi-1" value="<h1>LeetCode</h1>" style="text;html=1;align=center;verticalAlign=middle;resizable=0;points=[];autosize=1;strokeColor=none;fillColor=none;" vertex="1" parent="1">
<mxGeometry x="335" y="8" width="130" height="70" as="geometry" />
</mxCell>
<mxCell id="vMsRpWaaGCRmH829zkNi-2" value="<h2>Functional Requirements:</h2><div style=""><ul><li style="text-align: left;">view problem list</li><li style="text-align: left;">code solution in multiple languages</li><li style="text-align: left;">submit solution &amp; get feedback</li><li style="text-align: left;">view leaderboard for competitions</li></ul><h2 style="text-align: left;">Out of Scope:</h2><div style=""><ul><li style="text-align: left;">auth (session/JWT)</li><li style="text-align: left;">profiles</li><li style="text-align: left;">payment</li><li style="text-align: left;">analytics</li><li style="text-align: left;">social features</li></ul></div></div>" style="text;html=1;align=center;verticalAlign=middle;resizable=0;points=[];autosize=1;strokeColor=none;fillColor=none;" vertex="1" parent="1">
<mxGeometry x="50" y="70" width="250" height="260" as="geometry" />
</mxCell>
<mxCell id="vMsRpWaaGCRmH829zkNi-3" value="<h2>Non-Functional Requirements</h2><div style=""><ul><li style="text-align: left;">availability &gt; consistency</li><li style="text-align: left;">isolation + security for user submitted code</li><li style="text-align: left;">submission result &lt; 5s</li><li style="text-align: left;">support competitions &lt; 100k users</li></ul><h2 style="text-align: left;">Out of Scope:</h2><div><ul><li style="text-align: left;">fault-tolerant</li><li style="text-align: left;">secure transactions (purchases)</li><li style="text-align: left;">well tested/easy to deploy</li><li style="text-align: left;">regular backups</li></ul></div></div>" style="text;html=1;align=center;verticalAlign=middle;resizable=0;points=[];autosize=1;strokeColor=none;fillColor=none;" vertex="1" parent="1">
<mxGeometry x="520" y="78" width="290" height="240" as="geometry" />
</mxCell>
<mxCell id="vMsRpWaaGCRmH829zkNi-4" value="<h2>Core Entities</h2><div><ul><li style="text-align: left;">Problem</li><li style="text-align: left;">Solution</li><li style="text-align: left;">Leaderboard</li><li style="text-align: left;">Testcase</li><li style="text-align: left;">User</li></ul></div>" style="text;html=1;align=center;verticalAlign=middle;resizable=0;points=[];autosize=1;strokeColor=none;fillColor=none;" vertex="1" parent="1">
<mxGeometry x="330" y="168" width="130" height="150" as="geometry" />
</mxCell>
<mxCell id="vMsRpWaaGCRmH829zkNi-5" value="<h2>API</h2><div><ul><li style="text-align: left;">GET /problems?page={}&amp;limit={}&amp;filters... -&gt; problems[]</li><li style="text-align: left;">GET /problems/:id?language={} -&gt;&nbsp; problem</li><li style="text-align: left;">POST /solution/:id {code, language } -&gt; solution</li><li style="text-align: left;">GET /leaderboard?challengeId={}&amp;page={}&amp;limit={} -&gt; leaderboard</li></ul></div>" style="text;html=1;align=center;verticalAlign=middle;resizable=0;points=[];autosize=1;strokeColor=none;fillColor=none;" vertex="1" parent="1">
<mxGeometry x="10" y="320" width="420" height="130" as="geometry" />
</mxCell>
<mxCell id="vMsRpWaaGCRmH829zkNi-6" value="<h2>High Level Design</h2>" style="text;html=1;align=center;verticalAlign=middle;resizable=0;points=[];autosize=1;strokeColor=none;fillColor=none;" vertex="1" parent="1">
<mxGeometry x="190" y="460" width="180" height="60" as="geometry" />
</mxCell>
<mxCell id="vMsRpWaaGCRmH829zkNi-9" value="" style="rounded=0;orthogonalLoop=1;jettySize=auto;html=1;strokeColor=default;" edge="1" parent="1" target="vMsRpWaaGCRmH829zkNi-8">
<mxGeometry relative="1" as="geometry">
<mxPoint x="85" y="580" as="sourcePoint" />
</mxGeometry>
</mxCell>
<mxCell id="vMsRpWaaGCRmH829zkNi-7" value="Actor" style="shape=umlActor;verticalLabelPosition=bottom;verticalAlign=top;html=1;outlineConnect=0;" vertex="1" parent="1">
<mxGeometry x="45" y="540" width="30" height="60" as="geometry" />
</mxCell>
<mxCell id="vMsRpWaaGCRmH829zkNi-8" value="LB + API GW" style="whiteSpace=wrap;html=1;aspect=fixed;" vertex="1" parent="1">
<mxGeometry x="145" y="540" width="80" height="80" as="geometry" />
</mxCell>
<mxCell id="vMsRpWaaGCRmH829zkNi-10" value="Code Service" style="shape=process;whiteSpace=wrap;html=1;backgroundOutline=1;" vertex="1" parent="1">
<mxGeometry x="285" y="550" width="120" height="60" as="geometry" />
</mxCell>
<mxCell id="vMsRpWaaGCRmH829zkNi-11" value="Code DB" style="shape=cylinder3;whiteSpace=wrap;html=1;boundedLbl=1;backgroundOutline=1;size=15;" vertex="1" parent="1">
<mxGeometry x="475" y="550" width="60" height="80" as="geometry" />
</mxCell>
<mxCell id="vMsRpWaaGCRmH829zkNi-12" value="" style="endArrow=classic;startArrow=classic;html=1;rounded=0;" edge="1" parent="1">
<mxGeometry width="50" height="50" relative="1" as="geometry">
<mxPoint x="85" y="580" as="sourcePoint" />
<mxPoint x="145" y="580" as="targetPoint" />
</mxGeometry>
</mxCell>
<mxCell id="vMsRpWaaGCRmH829zkNi-13" value="Monaco IDE" style="text;html=1;align=center;verticalAlign=middle;resizable=0;points=[];autosize=1;strokeColor=none;fillColor=none;" vertex="1" parent="1">
<mxGeometry x="45" y="628" width="90" height="30" as="geometry" />
</mxCell>
<mxCell id="vMsRpWaaGCRmH829zkNi-14" value="<h2>Data Model</h2><div><ul><li style="text-align: left;">Problem: { id, desc, codestubs_per_lang[], testcaseIds[]... }</li><li style="text-align: left;">Submissions: { id, submittedAt, submittedBy, timeSpent, Results[], ... }</li><li style="text-align: left;">Leaderboard: {id, userId, score, solutionId, competitionId }</li><li style="text-align: left;">Competition: { id, problemIds[] }</li><li style="text-align: left;">Testcase: { id, lang[] }</li></ul></div>" style="text;html=1;align=center;verticalAlign=middle;resizable=0;points=[];autosize=1;strokeColor=none;fillColor=none;" vertex="1" parent="1">
<mxGeometry x="420" y="310" width="430" height="150" as="geometry" />
</mxCell>
<mxCell id="vMsRpWaaGCRmH829zkNi-15" value="" style="image;sketch=0;aspect=fixed;html=1;points=[];align=center;fontSize=12;image=img/lib/mscae/Docker.svg;" vertex="1" parent="1">
<mxGeometry x="335" y="730" width="50" height="41" as="geometry" />
</mxCell>
<mxCell id="vMsRpWaaGCRmH829zkNi-17" value="" style="shape=cube;whiteSpace=wrap;html=1;boundedLbl=1;backgroundOutline=1;darkOpacity=0.05;darkOpacity2=0.1;" vertex="1" parent="1">
<mxGeometry x="265" y="640" width="170" height="80" as="geometry" />
</mxCell>
<mxCell id="vMsRpWaaGCRmH829zkNi-24" value="Amazon SQS" style="sketch=0;outlineConnect=0;fontColor=#232F3E;gradientColor=none;strokeColor=#ffffff;fillColor=#232F3E;dashed=0;verticalLabelPosition=middle;verticalAlign=bottom;align=center;html=1;whiteSpace=wrap;fontSize=10;fontStyle=1;spacing=3;shape=mxgraph.aws4.productIcon;prIcon=mxgraph.aws4.sqs;" vertex="1" parent="1">
<mxGeometry x="145" y="650" width="80" height="100" as="geometry" />
</mxCell>
<mxCell id="vMsRpWaaGCRmH829zkNi-25" value="" style="endArrow=classic;startArrow=classic;html=1;rounded=0;" edge="1" parent="1">
<mxGeometry width="50" height="50" relative="1" as="geometry">
<mxPoint x="235" y="658" as="sourcePoint" />
<mxPoint x="285" y="608" as="targetPoint" />
</mxGeometry>
</mxCell>
<mxCell id="vMsRpWaaGCRmH829zkNi-26" value="" style="endArrow=classic;startArrow=classic;html=1;rounded=0;entryX=0.5;entryY=1;entryDx=0;entryDy=0;" edge="1" parent="1" target="vMsRpWaaGCRmH829zkNi-10">
<mxGeometry width="50" height="50" relative="1" as="geometry">
<mxPoint x="345" y="640" as="sourcePoint" />
<mxPoint x="370" y="610" as="targetPoint" />
</mxGeometry>
</mxCell>
<mxCell id="vMsRpWaaGCRmH829zkNi-27" value="Java<span style="color: rgba(0, 0, 0, 0); font-family: monospace; font-size: 0px; text-align: start; text-wrap-mode: nowrap;">%3CmxGraphModel%3E%3Croot%3E%3CmxCell%20id%3D%220%22%2F%3E%3CmxCell%20id%3D%221%22%20parent%3D%220%22%2F%3E%3CmxCell%20id%3D%222%22%20value%3D%22Java%22%20style%3D%22swimlane%3BwhiteSpace%3Dwrap%3Bhtml%3D1%3B%22%20vertex%3D%221%22%20parent%3D%221%22%3E%3CmxGeometry%20x%3D%22490%22%20y%3D%22680%22%20width%3D%2240%22%20height%3D%2250%22%20as%3D%22geometry%22%2F%3E%3C%2FmxCell%3E%3C%2Froot%3E%3C%2FmxGraphModel%3E</span>" style="rounded=1;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="295" y="665" width="40" height="30" as="geometry" />
</mxCell>
<mxCell id="vMsRpWaaGCRmH829zkNi-28" value="Python" style="rounded=1;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="340" y="665" width="40" height="30" as="geometry" />
</mxCell>
<mxCell id="vMsRpWaaGCRmH829zkNi-29" value="C++" style="rounded=1;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="385" y="665" width="40" height="30" as="geometry" />
</mxCell>
<mxCell id="vMsRpWaaGCRmH829zkNi-30" value="" style="outlineConnect=0;dashed=0;verticalLabelPosition=bottom;verticalAlign=top;align=center;html=1;shape=mxgraph.aws3.redis;fillColor=#2E73B8;gradientColor=none;" vertex="1" parent="1">
<mxGeometry x="475" y="658" width="60" height="63" as="geometry" />
</mxCell>
<mxCell id="vMsRpWaaGCRmH829zkNi-31" value="" style="endArrow=classic;startArrow=classic;html=1;rounded=0;entryX=0.5;entryY=1;entryDx=0;entryDy=0;entryPerimeter=0;" edge="1" parent="1" source="vMsRpWaaGCRmH829zkNi-30" target="vMsRpWaaGCRmH829zkNi-11">
<mxGeometry width="50" height="50" relative="1" as="geometry">
<mxPoint x="475" y="680" as="sourcePoint" />
<mxPoint x="525" y="630" as="targetPoint" />
</mxGeometry>
</mxCell>
<mxCell id="vMsRpWaaGCRmH829zkNi-32" value="" style="endArrow=classic;startArrow=classic;html=1;rounded=0;exitX=1;exitY=0.5;exitDx=0;exitDy=0;" edge="1" parent="1" source="vMsRpWaaGCRmH829zkNi-10">
<mxGeometry width="50" height="50" relative="1" as="geometry">
<mxPoint x="425" y="620" as="sourcePoint" />
<mxPoint x="475" y="580" as="targetPoint" />
</mxGeometry>
</mxCell>
<mxCell id="vMsRpWaaGCRmH829zkNi-34" value="<h2>Deep Dives</h2>" style="text;html=1;align=center;verticalAlign=middle;resizable=0;points=[];autosize=1;strokeColor=none;fillColor=none;" vertex="1" parent="1">
<mxGeometry x="610" y="463" width="120" height="60" as="geometry" />
</mxCell>
<mxCell id="vMsRpWaaGCRmH829zkNi-35" value="<ul><li>isolation+security: Docker container</li><ul><li>CPU/memory limits</li><li>no network requests</li><li>explicit timeouts</li><li>no syscalls</li></ul><li>efficient leaderboard:</li><ul><li>5sec polling + Redis sorted set</li></ul><li>competition &lt; 100K users:</li><ul><li>calculate score on POST /solution</li><li>horizontal scaling + optional SQS</li></ul><li>testcases:</li><ul><li>stubs autogenerated by AI</li><li>single set to run against any language</li><li>serialize / deserialize output and check</li></ul></ul>" style="text;html=1;align=left;verticalAlign=middle;resizable=0;points=[];autosize=1;strokeColor=none;fillColor=none;" vertex="1" parent="1">
<mxGeometry x="540" y="510" width="310" height="240" as="geometry" />
</mxCell>
<mxCell id="vMsRpWaaGCRmH829zkNi-36" value="" style="endArrow=classic;startArrow=classic;html=1;rounded=0;exitX=1;exitY=0.5;exitDx=0;exitDy=0;" edge="1" parent="1" source="vMsRpWaaGCRmH829zkNi-8">
<mxGeometry width="50" height="50" relative="1" as="geometry">
<mxPoint x="235" y="630" as="sourcePoint" />
<mxPoint x="285" y="580" as="targetPoint" />
</mxGeometry>
</mxCell>
</root>
</mxGraphModel>
</diagram>
</mxfile>