Skip to content

Sequence diagrams for backend

SeunghyunDKim edited this page Feb 11, 2021 · 7 revisions

Sequence diagrams

Buy and sell routes

@startuml
actor client as C
participant server as S
database Database  as DB

C->S: /api/trading/{buy,sell} of stock S at price P
group if market currently open
 
S->S: get cur_price of S & current portfolio balance
group if (sufficient funds / stocks) && (cur_price ACCEPTABLE (w.r.t P))
 S->DB: start TXN
 S->DB: update client portfolio
 S->DB: insert new trade & end TXN
 DB-->S: OK
 S-->C: return updated portfolio
 else otherwise
 S-->C: failed
end
else otherwise
S-->C: failed - market closed
end
@enduml

User Authentication

![] (http://www.plantuml.com/plantuml/png/fP31Ri8m38RlUGg_mDOxXmb1fKtQ92Qw-sGQqqPBuyfsORpzqghq0DnsQHFR__V_yLeDnOOkEgoD1UeOA1cWmjRrkHFgq6CkACc9PAnNpgFX0PMWl1vokTmurmWFFOGZ37aS4Xj4RXho49BRFhrKA_ZSLLzGu61j8TG4DHBONmz7pY8wJ-eRMCAEe03gC4JmJ3hHCGgXlm3zPe2h9eStr1PwL3sp-AmDgO53BPVUdjlS6gVApGegOw5xT07Z4FdlXH2IyVYuSZFXT--ppmSt8G72G99LhsImPVu9fDCpb5G39-SeAW5RIt8EIhFscAt8EqhUkVl5n8cyy9NauIwMX3LtXv3GiXy4pLSHgkqsflulvqt_OMeUBFkDlzbmnior9SIUEZxHmnoZrJf_XYx-0G00)

@startuml
actor client as C
participant server as S
database Database as DB

group if user not logged in
C->S: POST /auth/register Register for new user

group if username / email does not already exist
S->S: Hash password using bcrypt.hash
S->DB: Store username / email / hashed_password into DB
DB->S: OK
S->S: Login a uer / Get Cookies for session

else otherwise
S->S: failed
end


C->S: POST /auth/login Login a user
group if username / password combination is correct
S->S: Login a user / Get Cookies for session

else otherwise
S->S: failed
end
else otherwise

C->S: POST /auth/logout Logout a user
S->S: Logout a user / Remove Cookies for session
end
@enduml

Clone this wiki locally