-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBitPin.drawio
More file actions
91 lines (91 loc) · 11.6 KB
/
BitPin.drawio
File metadata and controls
91 lines (91 loc) · 11.6 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
<mxfile host="app.diagrams.net" modified="2024-05-23T17:41:44.501Z" agent="Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36" etag="NS7MKqqpirGe-HGuVpu1" version="24.4.6" type="device">
<diagram name="Page-1" id="A13zV0KK_G3ZBwLwW0nN">
<mxGraphModel dx="920" dy="1172" grid="0" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="0" pageScale="1" pageWidth="850" pageHeight="1100" math="0" shadow="0">
<root>
<mxCell id="0" />
<mxCell id="1" parent="0" />
<mxCell id="g95xKWHiburPXzUNhOFQ-1" value="<h2 style="margin-top: 0px;">Routes</h2><p>Get /posts<br><span style="background-color: initial;">Post /posts/&lt;postId&gt;/rates</span></p>" style="text;html=1;whiteSpace=wrap;overflow=hidden;rounded=0;" parent="1" vertex="1">
<mxGeometry x="477" y="-117" width="180" height="120" as="geometry" />
</mxCell>
<mxCell id="g95xKWHiburPXzUNhOFQ-8" style="edgeStyle=none;curved=1;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;entryX=0;entryY=0.5;entryDx=0;entryDy=0;fontSize=12;startSize=8;endSize=8;" parent="1" source="g95xKWHiburPXzUNhOFQ-3" target="g95xKWHiburPXzUNhOFQ-6" edge="1">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="g95xKWHiburPXzUNhOFQ-3" value="Mobile client" style="sketch=0;outlineConnect=0;fontColor=#232F3E;gradientColor=none;strokeColor=#232F3E;fillColor=#ffffff;dashed=0;verticalLabelPosition=bottom;verticalAlign=top;align=center;html=1;fontSize=12;fontStyle=0;aspect=fixed;shape=mxgraph.aws4.resourceIcon;resIcon=mxgraph.aws4.mobile_client;" parent="1" vertex="1">
<mxGeometry x="20" y="99" width="60" height="60" as="geometry" />
</mxCell>
<mxCell id="g95xKWHiburPXzUNhOFQ-7" style="edgeStyle=none;curved=1;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;entryX=0;entryY=0.5;entryDx=0;entryDy=0;fontSize=12;startSize=8;endSize=8;" parent="1" source="g95xKWHiburPXzUNhOFQ-4" target="g95xKWHiburPXzUNhOFQ-6" edge="1">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="g95xKWHiburPXzUNhOFQ-4" value="Client" style="sketch=0;outlineConnect=0;fontColor=#232F3E;gradientColor=none;strokeColor=#232F3E;fillColor=#ffffff;dashed=0;verticalLabelPosition=bottom;verticalAlign=top;align=center;html=1;fontSize=12;fontStyle=0;aspect=fixed;shape=mxgraph.aws4.resourceIcon;resIcon=mxgraph.aws4.client;" parent="1" vertex="1">
<mxGeometry x="20" y="196" width="60" height="60" as="geometry" />
</mxCell>
<mxCell id="g95xKWHiburPXzUNhOFQ-15" style="edgeStyle=none;curved=1;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;entryX=0;entryY=1;entryDx=0;entryDy=0;fontSize=12;startSize=8;endSize=8;" parent="1" source="g95xKWHiburPXzUNhOFQ-6" target="g95xKWHiburPXzUNhOFQ-9" edge="1">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="g95xKWHiburPXzUNhOFQ-6" value="Load balancer<br>(Nginx)" style="ellipse;whiteSpace=wrap;html=1;aspect=fixed;" parent="1" vertex="1">
<mxGeometry x="194" y="147" width="80" height="80" as="geometry" />
</mxCell>
<mxCell id="g95xKWHiburPXzUNhOFQ-14" value="" style="group" parent="1" vertex="1" connectable="0">
<mxGeometry x="351" y="140" width="142" height="118" as="geometry" />
</mxCell>
<mxCell id="g95xKWHiburPXzUNhOFQ-9" value="" style="rounded=0;whiteSpace=wrap;html=1;" parent="g95xKWHiburPXzUNhOFQ-14" vertex="1">
<mxGeometry x="3" width="106" height="47" as="geometry" />
</mxCell>
<mxCell id="g95xKWHiburPXzUNhOFQ-10" value="" style="rounded=0;whiteSpace=wrap;html=1;" parent="g95xKWHiburPXzUNhOFQ-14" vertex="1">
<mxGeometry x="13" y="10" width="106" height="47" as="geometry" />
</mxCell>
<mxCell id="g95xKWHiburPXzUNhOFQ-11" value="Application" style="rounded=0;whiteSpace=wrap;html=1;" parent="g95xKWHiburPXzUNhOFQ-14" vertex="1">
<mxGeometry x="23" y="20" width="106" height="47" as="geometry" />
</mxCell>
<mxCell id="g95xKWHiburPXzUNhOFQ-12" value="Application is stateless<br style="font-size: 11px;">So you can scale it easily" style="text;html=1;align=center;verticalAlign=middle;resizable=0;points=[];autosize=1;strokeColor=none;fillColor=none;fontSize=11;" parent="g95xKWHiburPXzUNhOFQ-14" vertex="1">
<mxGeometry y="80" width="142" height="38" as="geometry" />
</mxCell>
<mxCell id="g95xKWHiburPXzUNhOFQ-16" value="Database" style="shape=cylinder3;whiteSpace=wrap;html=1;boundedLbl=1;backgroundOutline=1;size=15;" parent="1" vertex="1">
<mxGeometry x="583" y="143" width="60" height="80" as="geometry" />
</mxCell>
<mxCell id="g95xKWHiburPXzUNhOFQ-17" style="edgeStyle=none;curved=1;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;fontSize=12;startSize=8;endSize=8;" parent="1" source="g95xKWHiburPXzUNhOFQ-11" target="g95xKWHiburPXzUNhOFQ-16" edge="1">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="g95xKWHiburPXzUNhOFQ-22" value="<p style="margin:0px;margin-top:4px;text-align:center;"><b>posts<br>(shard by id)</b></p><hr size="1" style="border-style:solid;"><div style="height:2px;">+ id: int (4B)<br>+ titile: string (512B)<br>+ content: sting (65000B)<br>+ rate_count: int (4B)<br>+ score_sum: int(4B)<br>+ created_at: datetime (8B)<br></div><div style="height:2px;"><br><br><br><br></div>" style="verticalAlign=top;align=left;overflow=fill;html=1;whiteSpace=wrap;" parent="1" vertex="1">
<mxGeometry x="2" y="337" width="192" height="155" as="geometry" />
</mxCell>
<mxCell id="g95xKWHiburPXzUNhOFQ-26" style="edgeStyle=none;curved=1;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;entryX=1;entryY=0.5;entryDx=0;entryDy=0;fontSize=12;startSize=8;endSize=8;" parent="1" source="g95xKWHiburPXzUNhOFQ-24" target="g95xKWHiburPXzUNhOFQ-22" edge="1">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="g95xKWHiburPXzUNhOFQ-24" value="<p style="margin:0px;margin-top:4px;text-align:center;"><b>posts_rates<br>(shard by postId)</b></p><hr size="1" style="border-style:solid;"><div style="height:2px;">+ id: bigint (8B)<br>+ post_id: int (4B)<br>+ user_id: int(4B)<br>+ score: smallint (2B)<br>+ old_score: smallint (2B)<br>+ is_applied: boolean(1B)<br><div style="height: 2px;">+ created_at: datetime (8B)<br></div><div><br></div></div>" style="verticalAlign=top;align=left;overflow=fill;html=1;whiteSpace=wrap;" parent="1" vertex="1">
<mxGeometry x="266" y="340" width="194" height="153" as="geometry" />
</mxCell>
<mxCell id="g95xKWHiburPXzUNhOFQ-27" value="7GB for 100 thousand posts" style="text;html=1;align=center;verticalAlign=middle;resizable=0;points=[];autosize=1;strokeColor=none;fillColor=none;fontSize=16;" parent="1" vertex="1">
<mxGeometry x="-11" y="306" width="217" height="31" as="geometry" />
</mxCell>
<mxCell id="g95xKWHiburPXzUNhOFQ-29" value="Each post, 5 million rate:<div><br></div>" style="text;html=1;align=center;verticalAlign=middle;resizable=0;points=[];autosize=1;strokeColor=none;fillColor=none;fontSize=16;" parent="1" vertex="1">
<mxGeometry x="267" y="290" width="193" height="50" as="geometry" />
</mxCell>
<mxCell id="g95xKWHiburPXzUNhOFQ-30" value="<div><font style="font-size: 12px;">15TB for 100,000 post * 5 million rate</font></div>" style="text;html=1;align=center;verticalAlign=middle;resizable=0;points=[];autosize=1;strokeColor=none;fillColor=none;fontSize=16;" parent="1" vertex="1">
<mxGeometry x="253" y="314" width="216" height="31" as="geometry" />
</mxCell>
<mxCell id="g95xKWHiburPXzUNhOFQ-31" value="<div style=""><div style=""><span style="font-size: 12px;">This table logs each rate used for updating your rate.</span></div><div style=""><span style="font-size: 12px;">You can shard it by post ID to keep the database <br>functional as the records increase.</span></div><div style=""><span style="font-size: 12px;"><br></span></div><div style=""><span style="font-size: 12px;">There are enough reasons to use a NoSQL database,<br>&nbsp;but let's keep it simple. PostgreSQL is fine too and<br>&nbsp;has good features for concurrency control and scaling.</span></div></div>" style="text;html=1;align=left;verticalAlign=middle;resizable=0;points=[];autosize=1;strokeColor=none;fillColor=none;fontSize=16;" parent="1" vertex="1">
<mxGeometry x="472" y="345" width="310" height="146" as="geometry" />
</mxCell>
<mxCell id="OkIYj3103qbB7PWcmSPV-1" value="" style="group" parent="1" vertex="1" connectable="0">
<mxGeometry x="536" y="33" width="142" height="118" as="geometry" />
</mxCell>
<mxCell id="OkIYj3103qbB7PWcmSPV-2" value="" style="rounded=0;whiteSpace=wrap;html=1;" parent="OkIYj3103qbB7PWcmSPV-1" vertex="1">
<mxGeometry x="3" width="106" height="47" as="geometry" />
</mxCell>
<mxCell id="OkIYj3103qbB7PWcmSPV-3" value="" style="rounded=0;whiteSpace=wrap;html=1;" parent="OkIYj3103qbB7PWcmSPV-1" vertex="1">
<mxGeometry x="13" y="10" width="106" height="47" as="geometry" />
</mxCell>
<mxCell id="OkIYj3103qbB7PWcmSPV-4" value="FraudWorkers" style="rounded=0;whiteSpace=wrap;html=1;" parent="OkIYj3103qbB7PWcmSPV-1" vertex="1">
<mxGeometry x="23" y="20" width="106" height="47" as="geometry" />
</mxCell>
<mxCell id="4o4NbnxVGa7DIjqOIOSn-1" style="edgeStyle=none;curved=1;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;fontSize=12;startSize=8;endSize=8;" parent="1" source="OkIYj3103qbB7PWcmSPV-4" target="g95xKWHiburPXzUNhOFQ-16" edge="1">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="ukEkeMWxO7Vua0eZMhOf-2" value="<h1>System Consideration</h1><h1 style="margin-top: 0px;"><ul style="font-size: 12px;"><li style="">Real-World Conditions:<span style="font-weight: 400;"> The design and implementation consider real-world production conditions to ensure scalability, reliability, and performance.</span></li><li style="">Simplicity: <span style="font-weight: 400;">The solution focuses on simplicity while addressing the core requirements. Additional features like user profiles are omitted for simplicity.</span></li><li style="">Anti-Fraud Mechanism:<span style="font-weight: 400;"> The application implements a mechanism to prevent short-term events from significantly impacting post ratings. While the exact strategy may vary, the goal is to stabilize ratings over time and mitigate the influence of short-term fluctuations.</span></li></ul></h1>" style="text;html=1;whiteSpace=wrap;overflow=hidden;rounded=0;" vertex="1" parent="1">
<mxGeometry x="2" y="-140" width="440" height="222" as="geometry" />
</mxCell>
</root>
</mxGraphModel>
</diagram>
</mxfile>