generated from cs130-w21/template
-
Notifications
You must be signed in to change notification settings - Fork 2
Sequence diagrams for backend
SeunghyunDKim edited this page Feb 11, 2021
·
7 revisions
@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
@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->C: Return Error message
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->C: Return Error message
end
else otherwise
C->S: POST /auth/logout Logout a user
S->S: Logout a user / Remove Cookies for session
end
@enduml