Changes between Version 1 and Version 2 of Use-Case


Ignore:
Timestamp:
08/07/26 11:31:22 (9 days ago)
Author:
231285
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Use-Case

    v1 v2  
    11= Use-case model =
     2
     3The detailed pages for this phase are kept in the project's GitHub repository,
     4[https://github.com/StefanTrsunov/bp StefanTrsunov/bp], under `docs/P3-UseCaseModel/`. Every
     5use-case link below opens the corresponding file there.
    26
    37== Actors / Roles ==
     
    1721=== Visitor ===
    1822
    19  * [wiki:UseCase0001 UC0001] – '''Register new account''' – Visitor creates an account with a
    20    unique username and e-mail; the password is stored as a SHA-256 hash.
    21  * [wiki:UseCase0002 UC0002] – '''Log in''' – Visitor authenticates with username and password so
    22    the system treats every following action as a Trader.
     23 * [https://github.com/StefanTrsunov/bp/blob/main/docs/P3-UseCaseModel/UseCase0001.md UC0001] –
     24   '''Register new account''' – Visitor creates an account with a unique username and e-mail; the
     25   password is stored as a SHA-256 hash.
     26 * [https://github.com/StefanTrsunov/bp/blob/main/docs/P3-UseCaseModel/UseCase0002.md UC0002] –
     27   '''Log in''' – Visitor authenticates with username and password so the system treats every
     28   following action as a Trader.
    2329
    2430=== Trader ===
    2531
    26  * [wiki:UseCase0003 UC0003] – '''Deposit virtual funds''' – Trader tops up their virtual cash
    27    balance; the user row and the ledger are written in one transaction.
    28  * [wiki:UseCase0004 UC0004] – '''Place market BUY order''' – Trader buys a crypto asset at the
    29    current market price, which debits cash and upserts the holding at a running weighted-average
    30    price.
    31  * [wiki:UseCase0005 UC0005] – '''Place market SELL order''' – Trader sells part or all of a
    32    holding at the current market price, which credits cash and preserves the cost basis.
    33  * [wiki:UseCase0006 UC0006] – '''View portfolio and transaction history''' – Trader inspects
    34    current holdings, unrealised P/L, cash balances and the most recent ledger entries.
    35  * [wiki:UseCase0007 UC0007] – '''Manage watchlist''' – Trader lists, adds and removes crypto
    36    assets on a personal watchlist, where adding an asset already on the list is a no-op.
     32 * [https://github.com/StefanTrsunov/bp/blob/main/docs/P3-UseCaseModel/UseCase0003.md UC0003] –
     33   '''Deposit virtual funds''' – Trader tops up their virtual cash balance; the user row and the
     34   ledger are written in one transaction.
     35 * [https://github.com/StefanTrsunov/bp/blob/main/docs/P3-UseCaseModel/UseCase0004.md UC0004] –
     36   '''Place market BUY order''' – Trader buys a crypto asset at the current market price, which
     37   debits cash and upserts the holding at a running weighted-average price.
     38 * [https://github.com/StefanTrsunov/bp/blob/main/docs/P3-UseCaseModel/UseCase0005.md UC0005] –
     39   '''Place market SELL order''' – Trader sells part or all of a holding at the current market
     40   price, which credits cash and preserves the cost basis.
     41 * [https://github.com/StefanTrsunov/bp/blob/main/docs/P3-UseCaseModel/UseCase0006.md UC0006] –
     42   '''View portfolio and transaction history''' – Trader inspects current holdings, unrealised
     43   P/L, cash balances and the most recent ledger entries.
     44 * [https://github.com/StefanTrsunov/bp/blob/main/docs/P3-UseCaseModel/UseCase0007.md UC0007] –
     45   '''Manage watchlist''' – Trader lists, adds and removes crypto assets on a personal watchlist,
     46   where adding an asset already on the list is a no-op.
    3747
    3848=== Market Simulator ===
    3949
    4050The Market Simulator initiates no use case of its own. It participates in
    41 [wiki:UseCase0004 UC0004] and [wiki:UseCase0005 UC0005] indirectly, by keeping
    42 `project.market_trades` populated so that `project.v_latest_prices` returns a current price for
    43 every active market.
     51[https://github.com/StefanTrsunov/bp/blob/main/docs/P3-UseCaseModel/UseCase0004.md UC0004] and
     52[https://github.com/StefanTrsunov/bp/blob/main/docs/P3-UseCaseModel/UseCase0005.md UC0005]
     53indirectly, by keeping `project.market_trades` populated so that `project.v_latest_prices`
     54returns a current price for every active market.
    4455
    4556== Use-case model diagram ==
    4657
    4758{{{#!comment
    48 The diagram is optional for P3. Attach the exported image to this wiki page as
    49 use_case_diagram.png and then replace this comment with:
     59The diagram is optional for P3. Commit the exported image to
     60docs/P3-UseCaseModel/use_case_diagram.png and then replace this comment with:
    5061
    51 [[Image(use_case_diagram.png)]]
     62[https://github.com/StefanTrsunov/bp/blob/main/docs/P3-UseCaseModel/use_case_diagram.png Use-case model diagram]
    5263}}}
    5364
     
    5667The following use-cases are documented in detail, with SQL tested against the P2 database:
    5768
    58  * [wiki:UseCase0001 UseCase0001] – Visitor registers a new account
    59  * [wiki:UseCase0002 UseCase0002] – Visitor logs in
    60  * [wiki:UseCase0003 UseCase0003] – Trader deposits virtual funds
    61  * [wiki:UseCase0004 UseCase0004] – Trader places a market BUY order
    62  * [wiki:UseCase0005 UseCase0005] – Trader places a market SELL order
    63  * [wiki:UseCase0006 UseCase0006] – Trader views portfolio and transaction history
    64  * [wiki:UseCase0007 UseCase0007] – Trader manages a watchlist
     69 * [https://github.com/StefanTrsunov/bp/blob/main/docs/P3-UseCaseModel/UseCase0001.md UseCase0001] – Visitor registers a new account
     70 * [https://github.com/StefanTrsunov/bp/blob/main/docs/P3-UseCaseModel/UseCase0002.md UseCase0002] – Visitor logs in
     71 * [https://github.com/StefanTrsunov/bp/blob/main/docs/P3-UseCaseModel/UseCase0003.md UseCase0003] – Trader deposits virtual funds
     72 * [https://github.com/StefanTrsunov/bp/blob/main/docs/P3-UseCaseModel/UseCase0004.md UseCase0004] – Trader places a market BUY order
     73 * [https://github.com/StefanTrsunov/bp/blob/main/docs/P3-UseCaseModel/UseCase0005.md UseCase0005] – Trader places a market SELL order
     74 * [https://github.com/StefanTrsunov/bp/blob/main/docs/P3-UseCaseModel/UseCase0006.md UseCase0006] – Trader views portfolio and transaction history
     75 * [https://github.com/StefanTrsunov/bp/blob/main/docs/P3-UseCaseModel/UseCase0007.md UseCase0007] – Trader manages a watchlist
    6576
    6677== Realization details on selection of the most important use cases ==
    6778
    6879This is a solo project, so '''at least 3 use cases''' are required. '''7 use cases''' are
    69 documented, for a safety margin. All seven are implemented in the P4 prototype; see `server/`
    70 for the Go source and [wiki:PrototypeImplementation] for the documented runs.
     80documented, for a safety margin. All seven are implemented in the P4 prototype; see
     81[https://github.com/StefanTrsunov/bp/tree/main/server server/] for the Go source and
     82[https://github.com/StefanTrsunov/bp/blob/main/docs/P4-Prototype/PrototypeImplementation.md PrototypeImplementation]
     83for the documented runs.
    7184
    7285||=Use case=||=Importance=||=Why it was selected=||
    73 ||[wiki:UseCase0001 UC0001 – Register]||High||Nothing else works without it; demonstrates `INSERT` with a uniqueness check.||
    74 ||[wiki:UseCase0002 UC0002 – Log in]||High||Authenticates every Trader action; demonstrates `SELECT` with parameter binding.||
    75 ||[wiki:UseCase0003 UC0003 – Deposit]||High||Shows a multi-row transaction: `UPDATE users` plus `INSERT INTO transactions`.||
    76 ||[wiki:UseCase0004 UC0004 – Buy]||Very high||Core of the exchange: `INSERT orders`, `UPDATE users`, upsert `holdings`, ledger entry, market trade.||
    77 ||[wiki:UseCase0005 UC0005 – Sell]||Very high||Dual of Buy; demonstrates row-level `FOR UPDATE` locking and cost-basis bookkeeping.||
    78 ||[wiki:UseCase0006 UC0006 – Portfolio]||High||Demonstrates joins over `holdings`, `markets` and `crypto`, and the `v_portfolio` view.||
    79 ||[wiki:UseCase0007 UC0007 – Watchlist]||Medium||Demonstrates N–M relation handling and `ON CONFLICT` upsert semantics.||
     86||[https://github.com/StefanTrsunov/bp/blob/main/docs/P3-UseCaseModel/UseCase0001.md UC0001 – Register]||High||Nothing else works without it; demonstrates `INSERT` with a uniqueness check.||
     87||[https://github.com/StefanTrsunov/bp/blob/main/docs/P3-UseCaseModel/UseCase0002.md UC0002 – Log in]||High||Authenticates every Trader action; demonstrates `SELECT` with parameter binding.||
     88||[https://github.com/StefanTrsunov/bp/blob/main/docs/P3-UseCaseModel/UseCase0003.md UC0003 – Deposit]||High||Shows a multi-row transaction: `UPDATE users` plus `INSERT INTO transactions`.||
     89||[https://github.com/StefanTrsunov/bp/blob/main/docs/P3-UseCaseModel/UseCase0004.md UC0004 – Buy]||Very high||Core of the exchange: `INSERT orders`, `UPDATE users`, upsert `holdings`, ledger entry, market trade.||
     90||[https://github.com/StefanTrsunov/bp/blob/main/docs/P3-UseCaseModel/UseCase0005.md UC0005 – Sell]||Very high||Dual of Buy; demonstrates row-level `FOR UPDATE` locking and cost-basis bookkeeping.||
     91||[https://github.com/StefanTrsunov/bp/blob/main/docs/P3-UseCaseModel/UseCase0006.md UC0006 – Portfolio]||High||Demonstrates joins over `holdings`, `markets` and `crypto`, and the `v_portfolio` view.||
     92||[https://github.com/StefanTrsunov/bp/blob/main/docs/P3-UseCaseModel/UseCase0007.md UC0007 – Watchlist]||Medium||Demonstrates N–M relation handling and `ON CONFLICT` upsert semantics.||