source: docs/P3-UseCaseModel/UseCaseModel.md@ df05838

main
Last change on this file since df05838 was df05838, checked in by Stefan <trsunovstefan@…>, 3 weeks ago

Zip files

  • Property mode set to 100644
File size: 7.4 KB
Line 
1= 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.
6
7== Actors / Roles ==
8
9'''Visitor''' – Anyone using EduBerza without an account, who can look at public market
10information, create an account, and log in.
11
12'''Trader''' – A registered, logged-in user who deposits virtual funds, places market buy and
13sell orders, follows the value of their portfolio, and keeps a watchlist of assets they want to
14monitor.
15
16'''Market Simulator''' – An external automated system (the bot in `bots/`) that writes simulated
17trades and candles into the database so prices move without a connection to a real exchange.
18
19== Use-Cases ==
20
21=== Visitor ===
22
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.
29
30=== Trader ===
31
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.
47
48=== Market Simulator ===
49
50The Market Simulator initiates no use case of its own. It participates in
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.
55
56== Use-case model diagram ==
57
58{{{#!comment
59The diagram is optional for P3. Commit the exported image to
60docs/P3-UseCaseModel/use_case_diagram.png and then replace this comment with:
61
62[https://github.com/StefanTrsunov/bp/blob/main/docs/P3-UseCaseModel/use_case_diagram.png Use-case model diagram]
63}}}
64
65== Detailed Use-Cases ==
66
67The following use-cases are documented in detail, with SQL tested against the P2 database:
68
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
76
77== Realization details on selection of the most important use cases ==
78
79This is a solo project, so '''at least 3 use cases''' are required. '''7 use cases''' are
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.
84
85||=Use case=||=Importance=||=Why it was selected=||
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.||
93
94== AI usage ==
95
96AI was used in this phase and is logged in full, per the course rule for P1 onward.
97
98 * '''Phase log:'''
99 [https://github.com/StefanTrsunov/bp/blob/main/docs/P3-UseCaseModel/UseCaseModelAIUsage.md UseCaseModelAIUsage.md]
100 – service used, what the AI produced, and what I decided myself.
101 * '''Full conversation transcript:'''
102 [https://github.com/StefanTrsunov/bp/blob/main/docs/P1-ConceptualModel/ERModelAIUsage.md ERModelAIUsage.md]
103 – the same conversation produced the P1–P4 artefacts, so the complete prompt/response log is
104 kept in one place. Direct links:
105 [https://github.com/StefanTrsunov/bp/blob/main/docs/P1-ConceptualModel/ERModelAIUsage.md#session-1--2026-04-21 Session 1 – 2026-04-21],
106 [https://github.com/StefanTrsunov/bp/blob/main/docs/P1-ConceptualModel/ERModelAIUsage.md#session-2--2026-08-06--2026-08-07 Session 2 – 2026-08-06/07].
107
108'''Service:''' Claude Code (Anthropic), https://claude.com/claude-code – Claude subscription,
109model Claude Opus 4.7 (1M context).
110
111'''In short:''' the AI proposed the actor taxonomy and drafted the seven use cases with their SQL
112in session 1. In session 2 the use-case model itself was '''not''' changed – the only work was
113re-executing every scenario, including the failure paths, against a live PostgreSQL 16 database.
Note: See TracBrowser for help on using the repository browser.