# [WP] BistroQ - Milestone 3 Report > [!Note] > This report can be viewed in [HackMD - Milestone 3](https://hackmd.io/IyPQ1qkBQi6bd1jpK7Frmw) (We strongly recommend to read on the web for better reading experience). > [!Note] Links > Milestone 1 report: [HackMD - Milestone 1](https://hackmd.io/4tSDCY54TkaXIRHzsXetDg) > Milestone 2 report: [HackMD - Milestone 2](https://hackmd.io/gwAceDgMRQSu2DYeAvD3Sg) > Link to project: [Google Drive](https://drive.google.com/drive/folders/1yOPkMX5zgYTEN986CiEkPVB_U9MS15DY?usp=sharing) > Documentation (Generated by Doxygen): [WinUI](https://tien4112004.github.io/bistro-q-documentation/html/index.html), [API](https://tien4112004.github.io/bistro-q-api-documentation/) > Published GitHub Repositories: [WinUI](https://github.com/tien4112004/bistro-q), [API](https://github.com/tien4112004/bistro-q-api) > Demo video: [YouTube]](https://youtu.be/fLFgXRDfpOc) ## Table of Contents - [Overview](#Overview) - [Project Setup](#Project-Setup) - [Backend Setup](#Backend-Setup) - [Frontend Setup](#Frontend-Setup) - [Test Accounts](#Test-Accounts) - [Features](#Features) - [Completed Works](#Completed-Works) - [UI/UX](#UI-UX) - [Design Pattern](#Design-Pattern) - [Architecture](#Architecture) - [Documentation](#Documentation) - [Advanced Topics](#Advanced-Topics) - [SignalR](#SignalR) - [VietQR](#VietQR) - [Unit Test](#Unit-Test) - [Git Flow Evidence](#Git-Flow-Evidence) - [Code Review Evidence](#Code-Review-Evidence) - [Admin Account API](#Admin-Account-API) - [Admin Account WinUI](#Admin-Account-WinUI) - [Nutrition Fact CRUD API](#Nutrition-Fact-CRUD-API) - [UpdateNutritionFact API](#Update-Nutrition-Fact-API) - [Nutrition Fact Admin Interface WinUI](#Nutrition-Fact-Admin-Interface-WinUI) - [Refactor Version 2 WinUI](#Refactor-Version-2-WinUI) - [Product Recommendation API](#Product-Recommendation-API) - [Nutrition Fact Client Interface WinUI](#Nutrition-Fact-Client-Interface-WinUI) - [Checkout API](#Checkout-API) - [Checkout WinUI](#Checkout-WinUI) - [Recommendation Products WinUI](#Recommendation-Products-WinUI) - [Documentation](#Documentation) ## Overview In this milestone, we are focused in the new features about nutrition facts, product recommendations and realtime handling between clients. ## Project Setup ### Backend Setup 1. Create `.env` based on `.env.sample` file and fill the API Key with the key provided in submission in Moodle. 2. Ensure MySQL and database is working 3. Run database migration: ```bash! dotnet ef database update --project BistroQ.Infrastructure --startup-project BistroQ.API --context BistroQ.Infrastructure.Data.BistroQContext --verbose # Run migrations ``` 4. Run server: ```bash! dotnet watch run --project .\BistroQ.API ``` ### Frontend Setup 1. Have backend server running successfully. 2. Run `BistroQ.Presentation` Project through Visual Studio. ### Test Accounts | Role | Username | Password | | ------- | -------- | -------- | | Admin | admin | admin | | Kitchen | kitchen | kitchen | | Cashier | cashier | cashier | | Client | client1 | client | | Client | client2 | client | | Client | client3 | client | ... | Client | client8 | client | | Client | client9 | client | ## Features ### Completed Works In this milestone, we have done these tasks below: | Task | Working hours (est.) | Responsible by | | -------------------------------------- | -------------------- | -------------- | | Admin Account API Implementation | 1 hours | Toàn | | Admin Account WinUI Interface | 0.5 hours | Toàn | | Nutrition Fact CRUD API | 1 hours | Tiến | | Nutrition Fact Admin Interface WinUI | 0.75 hours | Tiến | | Product Recommendation API | 2.25 hours | Both | | Nutrition Fact Client WinUI (Integrated LiveCharts2) | 2 hours| Tiến | | Checkout API Implementation | 2 hours | Toàn | | Checkout WinUI Interface | 2.5 hours | Toàn | | Recommendation Products WinUI | 0.5 hours | Tiến | | Documentation | 1.5 hours | Both | Total estimated working hours: 14 hours. ## UI/UX - Demo video: [here](https://youtu.be/fLFgXRDfpOc) - Realtime PR (see how cashier know the client is checking out): [here](https://github.com/tien4112004/bistro-q/pull/26) ## Design Pattern :::info In this milestone, we only utilized the patterns from previous milestones without introducing any new ones. ::: ## Architecture :::info We decided to keep architecture since it was well-constructed. ::: ## Documentation In both projects, we have prepared the Doxyfile for generating documentations. Please install `doxygen` and its dependencies, then run the command below to generate documents. ```bash doxygen ``` Because of the generation process may takes some times (~100MB for both projects), we have hosted the documentation to GitHub Pages: [WinUI](https://tien4112004.github.io/bistro-q-documentation/html/index.html) & [Backend](https://tien4112004.github.io/bistro-q-api-documentation/) ## Advanced Topics ### SignalR `SignalR` is used to implement real-time communication between the Client and Cashier during the checkout process. This enables immediate updates and interactions between both parties. Example: ```csharp! // Server public class CheckoutHub : Hub { public async Task InitiateCheckout(int tableId) { // Some implementations await Clients.Caller.SendAsync("CheckoutInitiated", paymentData); // Send payment data back to client await Clients.Group("Cashiers").SendAsync("NewCheckout", tableId, table.Number, table.ZoneName); // Send new payment announcement to cashier } public async Task CompleteCheckout(int tableId) { // Some implementations await Clients.Group($"Client_{tableId}").SendAsync("CheckoutCompleted"); // Send client that the checkout is completed } } // Client public class CheckoutRealTimeService : ICheckoutRealTimeService { public CheckoutRealTimeService() { // Some other connections and initializations // Shows the payment URL to the client _hubConnection.On<string>("CheckoutInitiated", (paymentData) => OnCheckoutInitiated?.Invoke(paymentData)); // Notifies the client that the payment has been completed _hubConnection.On("CheckoutCompleted", () => OnCheckoutCompleted?.Invoke()); // Notifies the cashier that a new checkout has been requested _hubConnection.On<int, int, string>("NewCheckout", (tableId, tableNumber, zoneName) => OnNewCheckout?.Invoke(tableId, tableNumber, zoneName)); } public async Task StartAsync() { await _hubConnection.StartAsync(); } public async Task StopAsync() { await _hubConnection.StopAsync(); } public async Task NotifyCheckoutRequestedAsync(int tableId) { await _hubConnection.InvokeAsync("InitiateCheckout", tableId); } public async Task NotifyCheckoutCompletedAsync(int tableId) { await _hubConnection.InvokeAsync("CompleteCheckout", tableId); } } ``` #### Demo Please check this [Pull Request](https://github.com/tien4112004/bistro-q/pull/26) to see how it behave in actual use cases. We have a video on PR detail. ### VietQR The application integrates the [VietQR API by Casso](https://www.vietqr.io/danh-sach-api/link-tao-ma-nhanh/api-tao-ma-qr/) to generate QR codes for banking payments during checkout. This allows seamless payment processing using bank QR codes. ## Unit test We have implement some tests in backend. We decided to mock the backend services and test routes in controllers. To run the test, please use the Test runner/Test explorer in IDE like Visual Studio or Jetbrains Rider. ## Git Flow Evidence #### WinUI project ![image](https://hackmd.io/_uploads/HyaJkLFLJl.png) ![image](https://hackmd.io/_uploads/rJ8ARrYIye.png) ![image](https://hackmd.io/_uploads/SkK2ArFLyl.png) #### ASP .NET project ![image](https://hackmd.io/_uploads/ByWVJUFLkx.png) ## Code Review Evidence :::success These PRs are sorted in ascending chronological order. ::: :::info ### PR Admin Account API ::: ![PR_Admin_Account_API-images-0](https://hackmd.io/_uploads/Bk50QQFUyl.jpg) ![PR_Admin_Account_API-images-1](https://hackmd.io/_uploads/rkqR7XtL1e.jpg) :::info ### PR Admin Account WinUI ::: ![PR_Admin_Account_WinUI-images-0](https://hackmd.io/_uploads/HyFJE7KU1e.jpg) ![PR_Admin_Account_WinUI-images-1](https://hackmd.io/_uploads/H1t1E7t8kg.jpg) :::info ### PR Nutrition Fact CRUD API ::: ![PR_NutritionFact_CRUD_API-images-0](https://hackmd.io/_uploads/ByV5NXtLJx.jpg) ![PR_NutritionFact_CRUD_API-images-1](https://hackmd.io/_uploads/Hy454XK8kx.jpg) ![PR_NutritionFact_CRUD_API-images-2](https://hackmd.io/_uploads/HkE5NXtI1l.jpg) ![PR_NutritionFact_CRUD_API-images-3](https://hackmd.io/_uploads/HkNqE7YUkx.jpg) :::info ### PR Nutrition Fact Admin Interface WinUI ::: ![PR_Admin_NutritionFact_WinUI-images-0](https://hackmd.io/_uploads/HkiCVXtLke.jpg) ![PR_Admin_NutritionFact_WinUI-images-1](https://hackmd.io/_uploads/SJ9AEXF81x.jpg) ![PR_Admin_NutritionFact_WinUI-images-2](https://hackmd.io/_uploads/SJ5CN7YLJx.jpg) ![PR_Admin_NutritionFact_WinUI-images-3](https://hackmd.io/_uploads/r15CVmYLJx.jpg) :::info ### PR Refactor Version 2 WinUI ::: ![PR_Refactor_WinUI_page-0001](https://hackmd.io/_uploads/SJpJSXF8ye.jpg) ![PR_Refactor_WinUI_page-0002](https://hackmd.io/_uploads/B1hkrmF81x.jpg) ![PR_Refactor_WinUI_page-0003](https://hackmd.io/_uploads/B1nyBmtIkx.jpg) ![PR_Refactor_WinUI_page-0004](https://hackmd.io/_uploads/SkpkSQYIyl.jpg) ![PR_Refactor_WinUI_page-0005](https://hackmd.io/_uploads/H1TyBQF8yx.jpg) ![PR_Refactor_WinUI_page-0006](https://hackmd.io/_uploads/B1TkS7FIyl.jpg) ![PR_Refactor_WinUI_page-0007](https://hackmd.io/_uploads/S1nkrXYUyx.jpg) :::info ### PR Product Recommendation API ::: ![PR_Recommendation_API_page-0001](https://hackmd.io/_uploads/BJcQS7tI1e.jpg) ![PR_Recommendation_API_page-0002](https://hackmd.io/_uploads/H15QS7K81l.jpg) ![PR_Recommendation_API_page-0003](https://hackmd.io/_uploads/HJcmB7tUJe.jpg) ![PR_Recommendation_API_page-0004](https://hackmd.io/_uploads/S1Y7B7tIyx.jpg) ![PR_Recommendation_API_page-0005](https://hackmd.io/_uploads/HktmBQt8kl.jpg) ![PR_Recommendation_API_page-0006](https://hackmd.io/_uploads/HJgYmSmtLkx.jpg) :::info ### PR Nutrition Fact Client Interface WinUI ::: ![PR_ClientNutritionFact_WinUI_page-0001](https://hackmd.io/_uploads/BJ5IrmK81e.jpg) ![PR_ClientNutritionFact_WinUI_page-0002](https://hackmd.io/_uploads/Sy5UHXFUJx.jpg) ![PR_ClientNutritionFact_WinUI_page-0003](https://hackmd.io/_uploads/B19ISmtL1e.jpg) ![PR_ClientNutritionFact_WinUI_page-0004](https://hackmd.io/_uploads/B19UHQt8Jx.jpg) ![PR_ClientNutritionFact_WinUI_page-0005](https://hackmd.io/_uploads/SycLSQK81e.jpg) ![PR_ClientNutritionFact_WinUI_page-0006](https://hackmd.io/_uploads/r1qUSXYIJg.jpg) ![PR_ClientNutritionFact_WinUI_page-0007](https://hackmd.io/_uploads/HJ9ISXFIkg.jpg ![PR_ClientNutritionFact_WinUI_page-0008](https://hackmd.io/_uploads/rkxqISXYL1l.jpg) :::info ### PR Checkout API ::: ![PR_Checkout_API_page-0001](https://hackmd.io/_uploads/BkKLvQYUkg.jpg) ![PR_Checkout_API_page-0002](https://hackmd.io/_uploads/ryJKrmtLJl.jpg) :::info ### PR Checkout WinUI ::: ![PR_Checkout_WinUI_page-0001](https://hackmd.io/_uploads/S1O9rQKIJe.jpg) ![PR_Checkout_WinUI_page-0002](https://hackmd.io/_uploads/BkOqBmY8ke.jpg) ![PR_Checkout_WinUI_page-0003](https://hackmd.io/_uploads/ByxucBXYIyl.jpg) ![PR_Checkout_WinUI_page-0004](https://hackmd.io/_uploads/B1dqS7FIyl.jpg) ![PR_Checkout_WinUI_page-0005](https://hackmd.io/_uploads/B1u5rmFUkx.jpg) :::info ### PR Recommendation Products WinUI ::: ![PR_Recommendation_WinUI_page-0002](https://hackmd.io/_uploads/S1IormKLJl.jpg) ![PR_Recommendation_WinUI_page-0003](https://hackmd.io/_uploads/SJUoH7KL1e.jpg) ![PR_Recommendation_WinUI_page-0001](https://hackmd.io/_uploads/SJIjBXFI1g.jpg) :::info ### PR Documentation ::: ![PR_Document_V1_page-0002](https://hackmd.io/_uploads/Hk9nSXtLJx.jpg) ![PR_Document_V1_page-0001](https://hackmd.io/_uploads/B1c3HXF81g.jpg)