Sprint3 - fedemelo/unitrade-wiki GitHub Wiki
Sprint 3: Deliverable
This page gathers all deliverables expected for Sprint 3.
It also includes explanations on many aspects that are expected to be explained during the Viva Voce; they are included here to potentially serve as an aid during the presentation.
The numbering of the sections in this document follows the numbering of the sections in the deliverable. However, the order of the sections differs.
- Sprint 3: Deliverable
9.a. Delivered Features
This section lists all the features that are delivered in this third sprint. The features are comprised of those implemented for the second sprint and those implemented for the current sprint.
№ | Feature | Description | Views in which it was implemented |
---|---|---|---|
1 | Microsoft Login (University Restricted) | Allows only students from the University of the Andes to log in using their Microsoft accounts. | Login View |
2 | Preferences Setup | Upon first login, users select their product preferences (e.g., sports, lab equipment) to personalize their experience. | Preferences Setup View |
3 | Semester and Major Input | Users input their semester and major, which can be used for analysis and potentially for further user personalization. | Preferences Setup View |
4 | Home View with Product Listings | Displays all products available for sale or rent, providing a central hub for browsing items. | Home View |
5 | Text Search Functionality | Enables users to search for products using a search bar, making it easier to find specific items. | Home View |
6 | Price Range Filter | Allows users to filter products based on a specific price range to match their budget constraints. | Home View |
7 | Sort Products Feature | Users can sort products by rating or price in ascending or descending order to organize listings according to their preferences. | Home View |
8 | Category Selection | Users can select specific categories to view all products within that category, streamlining the browsing experience. | Home View |
9 | "For You" Personalized Category | Displays products based on the user's interests selected during sign-up, offering a tailored shopping experience. | Home View |
10 | Upload Product for Sale | Allows users to list a product for sale by entering details like name, description, price, condition, and uploading an image from the gallery or camera. | Upload Product View |
11 | Upload Product for Rent | Enables users to list a product for rent, including all sale details plus specifying the rental period in days. | Upload Product View |
12 | Image Upload Capability | Users can upload images of their products either from their device gallery or by taking a new photo, enhancing the appeal of their listings. | Upload Product View |
13 | AI Category Assignment | Utilizes an AI model to automatically assign relevant categories to uploaded products, improving searchability and organization. | Upload Product View (Background Process) |
14 | Profile Viewing | Users can access their profile to view and edit personal preferences. | Profile View |
15 | Light/Dark Mode Toggle | Users can manually switch between light and dark themes to suit their visual comfort preferences. | Profile View (Theme Settings) |
16 | Context-Aware Theme Switching | Offers a time-aware mode that automatically switches between light and dark themes based on the time of day (light mode during the day, dark mode at night). | Profile View (Theme Settings) |
17 | View User Listings | Users can view all the products they have listed, both for sale and rent, in one place. | Profile View (My Listings) |
18 | Listing Popularity Metrics | Shows users how many others have saved their listed products, providing insights into the popularity and interest in their items. | Profile View (My Listings) |
3 & 9b. Business Questions
The following table contains all the business questions that were implemented in this sprint, with their respective type, rationale, and the view in which they were implemented. Notice the questions are a subset of those presented in the Sprint 1 Deliverable and they differ from those used in the Sprint 2 Deliverable.
№ | Business question | Type | Rationale | View in which it was implemented |
---|---|---|---|---|
1 | Is the average response time for listing a new item in the marketplace, in Android and iOS, below the defined objetive threshold of 1 sec? | 1 | Helps the app developers understand and measure the efficiency of the listing process and potential areas for improvement | Analytics Dashboard |
2 | How many times has the user’s listing been saved by other users? | 2 | Helps the user identify if their listings have prospective buyers or renters, and the popularity of their items, to reflect on their listings and pricing strategies. | My Listings view |
3 | What is the proportion of users who manually choose a light or dark mode preference compared to those who rely on automatic? | 3 | Evaluates the usage of the manual feature versus the automatic feature to asses whether they should be maintained or removed, and may also suggest the creation of similar features. | Analytics Dashboard |
4 | What is the percentage of buyers/renters that select a recommended item from the for you page vs. other pages? | 3 | Identifies the impact of the "for you" page on user selection choices, helping decide whether the "for you" page is a useful feature. | Analytics Dashboard |
5 | Which user demographic, categorized by major, is most likely to sell materials rather than rent them? | 4 | Targets marketing towards demographics most likely to purchase materials | Analytics Dashboard |
6 | Which screens in the application have the longest user engagement time? | * | Identifies popular screens to improve user retention, to evaluate unused screens and to help with advertisement placing | Analytics Dashboard |
2, 6 & 9c. Eventual Connectivity
Eventual Connectivity Scenarios
ID | Title | Event Description | System Response | Possible Antipatterns | Caching and Retrieving Strategy | Storage Type | Stored Data Type |
---|---|---|---|---|---|---|---|
1 | No connectivity on login | The user is trying to log in with Microsoft in the app but has no internet connection (Wi-Fi or mobile) | Network only: The system does not allow login and informs the user to try again when a connection is available. | Anti-pattern #6 & #10: Redirection without connectivity check | Doesn't apply | Doesn't apply | Doesn't apply |
2 | No connectivity when selecting semester, categories, and major | The user tries to upload their information but has no connectivity to upload the data. | Network falling back to cache: The app checks if there is a connection; if there is, it uploads the information. If not, it stores the data in local storage and uploads it when connectivity is restored. In the meantime, the user can navigate to the home page. | Anti-pattern #2: Stuck progress notification. The app should not be stuck because the data can't be uploaded; instead, it should queue it and allow user navigation. | Doesn't apply | NoSQL database (for Flutter, we use Hive) | We created a class, FirebaseQueuedRequest , which has the collection path, document ID, data, and operation. |
3 | No connectivity when uploading a product | The user tries to upload product details (title, description, price, and image) without an internet connection. | The app caches the product information and image locally via cache manager. It informs the user that the product will be uploaded once connectivity is restored. The user can continue using the app without losing the entered product data. Upon reconnection, the product is automatically uploaded, and a success message is shown. | Anti-pattern #2: Stuck progress notification; should allow for navigation and automatic retries upon connectivity restoration. | Cache product information and image locally using cache manager, and automatically upload when online | Cache | Product information and image in a structured format, ready for upload |
4 | No connectivity on home screen | The user navigates to the home screen but has no internet connection to load the product listings and categories. | Network only: if the app does not have connection, it shows an error message telling the user to check their connectivity | Anti-pattern #3 Non-informative message | Doesn't apply | Doesn't apply | Doesn't apply |
5 | No connectivity in listing view | The user tries to view their own product listings, but has no internet connection to retrieve the data from the server. | Network only: if the user is not connected, an error message appears telling the user it was unable to fetch the products | Anti-pattern #3 Non-informative message | Doesn't apply | Doesn't apply | Doesn't apply |
Eventual Connectivity Diagrams
The eventual connectivity diagrams show how the application behaves on the eventual connectivity scenarios.
Scenario 1)
Scenario 2)
Scenario 3)
Scenario 4)
Scenario 5)
4 & 9e. Concurrency or Multi-threading
Swift
In this sprint, we enhanced the ExplorerViewModel
to improve data handling with multithreading. The fetchInitialDataInBackground
function was updated to use DispatchQueue.global(qos: .userInitiated).async
, enabling product data and personalized categories to be fetched asynchronously from Firebase Firestore. This modification allows the app to handle data-intensive tasks in the background, freeing up the main thread to maintain a smooth user interface.
With these updates, the app loads critical data during startup without delaying the user experience on the home screen. When data retrieval completes, DispatchQueue.main.async
ensures UI updates happen seamlessly. Additionally, the network monitor now runs on a background queue, continuously checking connectivity and updating the app's state, allowing it to handle both online and offline scenarios efficiently.
Flutter
To implement multi-threading in the Flutter app, we created a new class called ProductService. This class is designed as a singleton to manage and fetch product data using a secondary thread, optimizing performance by offloading this task to a separate isolate. It uses a private constructor to ensure that only one instance of the class is created, providing a centralized way to load and access product data across the app. When loadProductsInBackground is called, it spawns a new isolate to fetch data from Firebase Firestore in the background.
In the app, we call loadProductsInBackground at the start of the app to retrieve product data as early as possible in the execution process. This improves the efficiency of loading the home page, as the products are already loaded by the time they are needed. On the home page, the app simply accesses the ProductService class to retrieve the cached product data, avoiding redundant API calls and enhancing responsiveness. If the background thread encounters any issues during data retrieval, the app can retry the request to ensure that product data is eventually fetched, providing a more reliable and efficient user experience.
5 & 9d. Local Storage
Swift
In Swift, we used UserDefaults to store key user preferences, including the selected major, preferred categories, semester, and theme settings (light or dark mode). By saving these settings locally, the app can maintain user preferences even when there is limited or no internet connectivity. This setup allows the application to load and apply these preferences from UserDefaults whenever there’s a connectivity issue, ensuring a consistent user experience regardless of network availability. Additionally, if preferences are updated, they are saved locally to UserDefaults and synced with Firestore once a connection is restored, effectively combining local storage with cloud-based persistence for reliable access and seamless functionality.
Flutter
For the Flutter application, the main strategy we implemented for local storage is the use of the shared_preferences
library to save essential user information. Specifically, when the user first logs into the application, we use local storage to save the user's major, categories, and semester, which can later be accessed even when the application is offline. Another instance where we save user preferences is in the user profile view, where the user has the option to select either light or dark mode or use a time-aware theme. This preference is saved in local storage, ensuring that the app theme does not rely on internet connectivity.
The second use of local storage is a NoSQL database utilizing the Hive
library, allowing the app to create an instance of a NoSQL database used by various app components to queue API requests. This way, requests that the app cannot make while offline are stored so that, once the app is back online, it can send all the requests to Firebase, ensuring no user information is lost.
7 & 9f. Caching
The same caching strategy was implemented in both the Swift and Flutter applications. The strategy can be mainly evidenced in the Upload Product View, in which a user can decide to upload a product to the marketplace to either sell or rent. The caching strategy is implemented to ensure that the user can still upload a product even when there is no internet connection.
The user can always fill out the product information, including the title, description, price, and image, and then click the upload button. Then:
- If there is an internet connection, the app will upload the product information and images to the marketplace, showing a loading icon while the process takes place, and then showing a success message once the product is uploaded.
- If there is no internet connection, the app will cache the product information and image locally and show an explanatory message to the user, indicating that the product will be uploaded once the internet connection is restored. The user can then navigate to other parts of the app or close the app without losing the product information. Once the user regains internet connectivity, the app will automatically upload the product to the marketplace and notify the user of the successful upload.
10. Ethics Video
Extra: Documented Microsoft Login Error
This section documents an error encountered while navigating the application, specifically when using the "Login with Microsoft" functionality in the Flutter (and less often in Swift) application. This error was discussed with Professor Vivian and TA Juan Sebastián Urrea; both agreed that the issue is not due to the application itself but is a known problem when implementing Microsoft authentication. Thus, the bug cannot be solved by the current development team. The error is shown in the following image:
Observed Behavior:
- The user taps on the
Login with Microsoft
button. - The user is redirected to the browser for Microsoft sign-in authentication.
- The user successfully logs in through the Microsoft login flow in the browser.
- At the end of the process, instead of being redirected back to the app, the user encounters the "missing initial state" error.
- Despite this, Firebase registers the user as signed in.
- Manually returning to the app shows the user as successfully authenticated, allowing them to select their categories and enter user information.
The console logs also show the user as signed in:
Additionally, if the user recently logged into the app and the authentication token is still valid, the error will no longer appear. Instead, the user will be redirected back to the application seamlessly, without any additional issues.
Unresolved Issues
Additionally, here are some unresolved GitHub and Stack Overflow issues regarding the exact same error, providing further evidence that the problem originates from the authentication provider rather than the application and is out of the development team's control: