Sprint 3 - ISIS3510-202402-T13/SeneParking GitHub Wiki
1. Eventual Connectivity Scenarios and Their Solutions
SeneParking operates in an environment where network reliability cannot be guaranteed. Students and faculty often navigate through areas with poor connectivity within campus buildings, underground parking structures, or during peak usage times. Our eventual connectivity strategy is designed to ensure the app remains functional and reliable across various network conditions, providing a seamless parking experience even when connectivity is compromised.
a. Core Connectivity Scenarios
Complete Network Loss
The most challenging scenario occurs when a user completely loses network connectivity. This typically happens in underground parking areas or elevators. In these situations, the app transitions smoothly into an offline mode that maintains critical functionality. The app continues to operate using locally cached data, including the last known state of parking spots, stored maps, and user information.
When operating in offline mode, the app clearly communicates its status to users through a persistent indicator. Any actions that require network connectivity are queued locally, with the app providing immediate feedback to users about the status of their requests. For example, if a user attempts to reserve a parking spot, the app securely stores the data and processes it automatically once connectivity is restored. In this specific case, it must notify the user wether or not the desired parking spot still is available.
Intermittent Connectivity
Perhaps more common than complete network loss is the challenge of intermittent connectivity, where users experience frequent connection drops or unstable network conditions. This scenario requires a more nuanced approach to data synchronization and user experience management.
The app implements a progressive loading strategy that prioritizes essential information. When connectivity is unstable, the app focuses on maintaining real-time parking spot availability updates while deferring less critical data synchronization like analytics. This ensures that users can still find parking lots and reserve parking spots even under sub-optimal network conditions.
To handle this scenario effectively, the app implements an optimistic update system. When a user performs an action, the app immediately shows the expected result while attempting to synchronize with the server in the background. If synchronization fails, the app queues the operation and continues to retry using an exponential backoff strategy to prevent network congestion.
Weak but Stable Connectivity
In situations where users have consistent but poor network connections, the app adapts its behavior to optimize for reduced bandwidth usage. This commonly occurs during peak hours when network infrastructure is under heavy load. The app implements adaptive quality controls that automatically reduces the frequency of real-time updates to match available bandwidth.
b. Technical Implementation Approach
SeneParking's connectivity strategy revolves around three core components: a Local Storage Manager for offline data persistence, a Sync Manager for handling data synchronization, and a Network Monitor for detecting connectivity changes. These components work together to maintain app functionality across varying network conditions, focusing particularly on critical features like user registration, map display, and parking reservations.
The system prioritizes data synchronization based on user impact, with registration and reservations taking precedence over less critical updates like user preferences or historical data. This ensures that when connectivity returns, the most important user operations are processed first.
c. Feature-Specific Adaptations
User Registration
During online operation, user registration proceeds normally with immediate server validation and account creation. When offline, the system securely caches validated registration data locally and queues it for processing when connectivity returns. Users receive clear notification that their account creation is pending, and the system handles potential conflicts (like duplicate emails) upon synchronization.
Main Map and Parking Availability
The map interface maintains a cache of parking lot locations and their last known availability status. During normal operation, it provides real-time updates of parking spot availability. When offline, it displays cached data with clear timestamps indicating when the information was last updated. This allows users to make informed decisions even with older data, while clearly communicating the data's age.
Parking Spot Reservation
The reservation system allows users to queue reservation requests even when offline. During normal operation, reservations are processed immediately with real-time confirmation. In offline mode, the system stores reservation intents locally and provides users with provisional confirmations. When connectivity returns, these queued reservations are processed in order, with the system handling conflicts such as spots that are no longer available by suggesting alternatives.
This streamlined approach ensures essential functionality remains available while maintaining data integrity and user trust. The system is transparent about its current operational status and data freshness, allowing users to make informed decisions regardless of connectivity state.
d. User Experience Considerations
Throughout all connectivity scenarios, maintaining a clear and honest communication channel with users is crucial. The app uses a status indication system that keeps users informed about connectivity status and data freshness without being intrusive. When operating with cached data, the app clearly indicates this fact.
Error handling is implemented with a user-first approach, providing clear feedback when operations fail due to connectivity issues. Rather than showing technical error messages, the app offers guidance on what to expect once connectivity is restored. The app also implements intelligent background syncing to minimize the impact on user experience. When connectivity is restored, the app prioritizes syncing operations based on their importance and the current context of use, ensuring that the most relevant data is updated first.
2. Implemented Strategies
a. Multi-Threading/Concurrency Strategy
The parking reservation feature implemented uses a Concurrent Validation Strategy utilizing multiple background threads to efficiently process reservation requests. This strategy was chosen because making a parking reservation requires several independent validations - checking spot availability, processing payment information, and verifying user credentials - which traditionally would be performed sequentially, creating unnecessary delays and a poor user experience.
Instead of performing these validations one after another, our strategy leverages Swift's Combine framework and dispatch queues to execute these operations concurrently on separate background threads. While the main thread remains responsible for the user interface, keeping the app responsive, multiple background threads simultaneously handle the intensive validation tasks. This approach significantly reduces the total processing time - what would typically take three or more seconds sequentially can be completed in just over a second, as the total time becomes only as long as the slowest individual validation.
The strategy uses a publisher-subscriber pattern where each validation task is treated as an independent publisher. These publishers are then combined using Combine's CombineLatest3 operator, allowing us to wait for all validations to complete before proceeding with the reservation. This approach not only improves performance but also provides better error handling, as failures in any validation process can be immediately reported back to the user without waiting for other operations to complete.
To maintain thread safety, all UI updates are explicitly dispatched back to the main thread using DispatchQueue.main, while the heavy lifting of data processing and network communications happens on background threads with userInitiated quality of service. This separation ensures that the app remains responsive during the entire reservation process, allowing users to cancel their reservation attempt or interact with other parts of the app while the validations are being processed.
This concurrent validation strategy is particularly valuable in a real-world context where these operations would involve actual network calls, database queries, and payment processing systems, each with their own latencies and potential points of failure. The strategy's design allows for easy extension with additional validation steps or processes without significantly impacting the overall performance or user experience, making it a robust solution for handling complex, multi-step operations in mobile applications.
b. Local Storage Strategy
Our local storage strategy in SeneParking focuses on user experience by reducing repeated authentication and ensuring access to personalized data offline. We use local storage to retain essential information, including:
-
User Credentials: By securely storing user credentials locally, we eliminate the need for repeated logins, providing a seamless experience that allows users to access features immediately, especially in low-connectivity areas.
-
Favorite Parking Spots: We store information on users' favorite parking spots locally, ensuring they can view and navigate to frequently visited locations even without connectivity.
This strategy aligns with SeneParking’s focus on reliability and user-centric design, ensuring essential functionality and improved performance by reducing unnecessary network requests.
c. Eventual Connectivity Strategy in SeneParking
Where It Was Used
The eventual connectivity strategy was implemented across critical app features including User Registration, MainMapView, and Parking Spot Reservation components. The strategy ensures the app remains functional during network interruptions by implementing robust offline capabilities and synchronization mechanisms.
Why It Was Used
The strategy addresses three key scenarios:
- Complete Network Loss: Common in underground parking areas and elevators
- Intermittent Connectivity: Frequent connection drops in campus buildings
- Weak but Stable Connectivity: Peak usage times with reduced bandwidth
Strategy Overview
The approach uses a Progressive Loading and Queuing System. This strategy maintains app functionality across varying network conditions while ensuring data integrity and user trust.
Here's how the strategy works:
- Offline Mode Operation: The app transitions smoothly to offline mode using locally cached data, clearly indicating connectivity status to users
- Data Synchronization: When connectivity returns, the system prioritizes syncing critical operations (like reservations) using an exponential backoff strategy
- Progressive Loading: Essential information like parking spot availability is prioritized over less critical data during poor connectivity
- Optimistic Updates: The app shows expected results immediately while attempting background synchronization, queuing operations if sync fails
This strategy ensures seamless operation across different network conditions while maintaining transparency with users about data freshness and system status.
d. Caching strategy
Caching Strategy in SeneParking
Where It Was Used
The caching strategy was implemented in the MainMapView of SeneParking, specifically for fetching parking lot data from the database. This allows users to see parking lot details (locations, availability, EV spots, etc.) on the map even when the internet connection is unavailable or disrupted. The cached data is retained in the device’s local memory while the app remains open, providing users a smoother experience with continuous access to critical information.
Why It Was Used
The caching strategy was introduced to address two primary needs:
- Offline Availability: Since users may access the app in areas with limited connectivity, caching allows them to continue viewing parking lot information when offline.
- Performance Optimization: Reducing repeated requests to the database minimizes load times and network usage, optimizing app performance and improving responsiveness.
Strategy Overview
The caching approach used is In-Memory Caching. This strategy stores parking lot data locally in memory while the app is running, avoiding the need for repeated database fetches.
Here's a general breakdown of the strategy:
- Data Fetching and Storing: Parking lot data is fetched from the database on the map's initial load or whenever there is a request to refresh. The data is then saved into an in-memory array, which acts as the cache.
- Data Retrieval: If users return to the map or adjust filters, the app first checks the cached data rather than querying the database again, resulting in faster response times.
- Cache Refresh: Users can refresh the cache manually by triggering a fetch action (for instance, reloading the map or navigating back to the main screen). This flexibility ensures that data accuracy is maintained while also allowing offline access when needed.
This strategy aligns well with cross-platform implementations, as both iOS (Swift) and Android (Kotlin) can support similar in-memory storage models, making it adaptable across mobile platforms.
3. Implemented Features
Past
Map with real-time location
- Function: A blue dot will show the user current location in real-time, working with the mobile device location sensors.
- BQ: Do we have real-time information on the user’s location?
- Answer: Yes, this functionality identifies the user's exact location and displays nearby parking lots on the map, improving the overall parking experience helping him locate himself in the map and nearby parking spots.
Detailed information for Santo Domingo (SD) parking lots
- Function: Provide detailed information on the status of parking spots in the SD, this includes: availability, price and additional services.
- BQ: Do we have real-time information on the user’s location?
- Answer: Yes, with this, we can use his location and elaborate based on his context, using real-time location in the SD parking lot and suggest parking spots, we may even include EV spots availability withing the SD.
Smart Feature: Automated License Plate Recognition for Seamless Parking Access and Payment
- Function: This feature integrates advanced license plate recognition technology at parking lot entrances and exits. When a car approaches the entrance, the system quickly scans and recognizes the license plate, automatically opening the barrier for registered users. Upon exit, the system again recognizes the plate, calculates the parking duration, and automatically charges the user's linked account based on the time spent.
- BQ: What percentage of users have clicked on the license plate recognition beta feature for automated entry?
- Answer: This business question helps us gauge user interest and adoption of the new license plate recognition feature. A high percentage of clicks indicates strong user interest, suggesting that the feature is addressing a real need. For example, if 75% of users have clicked on the beta feature, it shows a high level of curiosity and potential adoption, indicating that we should prioritize fully implementing and refining this feature.
- Value Addition: This smart feature enhances the user experience by providing a frictionless, contactless parking process. It eliminates the need for physical tickets or access cards, reducing the potential for lost tickets or forgotten payments. The automatic calculation and charging based on actual parking time ensure fair and transparent billing. Moreover, the system can provide valuable data on parking patterns and usage, allowing for more efficient management of parking resources and potentially informing future expansion decisions.
Authentication views
- Function: Login and registration views, enabling users to authenticate and securely use the functions withing the app.
- BQ: Which parking-related feature (spot reservation, real-time availability, or navigation assistance) is used most frequently by our users on a weekly basis?
- Answer: Authentication will allow us to track behaviors and analyze the features the registered user used. That way we can know what feature is most/least used.
A pin for SD parking lots on Google Maps
- Function: Displays a pin in Google Maps that indicates the location of the available parking spots in the SD parking lot. Given that it is a parking lot with spots for electronic vehicles it is shown in blue. Parking lots without EV spots are shown in green and full parking lots are shown in red.
- BQ: Do we have real-time information on the user’s location?
- Answer: Yes, as we have the users location, we can display with the red dots only those nearby available parking spots, helping him to successfully and effectively park.
Blue pin for EV parking lots
- Function: Displays a green pin in Google Maps that indicates the location of the available EV parking spots in the SD parking lot.
- BQ: Do we have information on what parking lots have spots available for EV use?
- Answer: Yes, this feature helps EV users identify nearby available spots. Getting rid of the time it takes to locate one.
Current
Parking Lot Registration Feature in SeneParking
Purpose
The Parking Lot Registration feature allows parking lot owners to add their parking lot information directly to the SeneParking system. This information includes essential details such as the name, coordinates, availability, EV spots, rates, and operating hours. This feature aims to keep parking information accurate and updated, ultimately improving user experience by providing real-time data.
Implementation Overview
The feature is implemented in the RegisterParkingLotView, a dedicated SwiftUI view that owners can access via the "I'm a Parking Lot Owner" button on the SignInView. It uses Firestore as the backend to store and manage the parking lot data.
Feature Details
-
Form Structure: The form in the RegisterParkingLotView includes the following input fields:
- Parking Lot Name: Text field for identifying the parking lot.
- Fare per Day: Number input field to specify daily rates.
- Open and Close Time: Text fields that accept time in "hh:mmam" or "hh:mmpm" format.
- Available Spots and EV Spots: Number fields for standard and EV spots, indicating parking capacity.
- Coordinates (Latitude and Longitude): Number fields for the parking lot's geographic location.
-
Validation: Each input field has validations that ensure:
- All required fields are completed.
- Proper formats are followed (e.g., time format for open and close hours).
- Data types are appropriate (e.g., integers for available spots and fare). If a field contains invalid input, a descriptive error message appears below that specific field, helping users resolve issues efficiently.
-
Data Submission: Upon successful validation, the form sends a POST request to Firestore, creating a new entry in the database. The parking lot information is then accessible within the app's map view for end-users.
-
Error Handling: If registration fails, users see specific error messages detailing what went wrong. For instance, if network issues prevent saving to Firestore, a network-related error message appears, ensuring users understand the problem without ambiguity.
User Flow
- Accessing the Feature: After signing in, owners navigate to the registration form.
- Inputting Details: Owners complete the form with their parking lot information.
- Validating and Submitting: If the data is valid, the form submits to Firestore; otherwise, targeted error messages guide the owner to correct any issues.
- Confirmation: On success, a confirmation message appears, and the parking lot becomes visible on the map for users.
This feature is built to be adaptable across platforms and could be similarly implemented in Android (Kotlin), ensuring a seamless experience for parking lot owners regardless of device type.
Parking Lot Reservation Feature in SeneParking
Purpose
The Parking Lot Reservation feature allows parking users to book a parking spot on the SeneParking app. This information includes essential details such as the name, coordinates, availability, EV spots, rates, and operating hours for the chosen parking spot. This feature aims to keep parking information accurate and updated, ultimately improving user experience by providing real-time data.
Implementation Overview
The feature is implemented in the ReserveParkingLotView, a dedicated SwiftUI view that users can access via the parking lot detail view.
Feature Details
-
Form Structure: The form in the
ReserveParkingSpotView
includes the following input fields:- User ID: Hidden field that captures the user's identifier for reservation tracking.
- Parking Lot ID: Hidden field that identifies the specific parking lot for the reservation.
- Spot Type: Dropdown selection for choosing between standard and EV spots.
- Reservation Date and Time: Date and time pickers that allow users to set their desired reservation period, with time fields in "hh:mmam" or "hh:mmpm" format.
- Duration: Number input field for specifying the reservation length in hours.
-
Validation: Each input field has validations to ensure:
- All required fields are completed accurately.
- Proper formats are followed (e.g., time format for reservation start and end times).
- The reservation duration does not exceed the parking lot's operating hours. If any field contains invalid input, a descriptive error message appears below that specific field, guiding users in resolving issues quickly.
-
Data Submission: Upon successful validation, the form sends a POST request to Firestore, creating a new reservation entry in the database. The system checks for spot availability in real-time, ensuring concurrent requests can be handled without double-booking spots.
-
Error Handling: If the reservation fails, users receive specific error messages that explain the issue. For example, if a spot becomes unavailable during submission due to concurrent requests, an availability error message appears, prompting the user to select a new time or spot.
User Flow
- Accessing the Feature: After logging in, users navigate to the spot reservation form.
- Inputting Details: Users complete the form with their reservation details, including selecting the parking spot type, date, and time.
- Validating and Submitting: If the data is valid, the reservation is submitted to Firestore, with real-time availability checks to prevent double-booking. Otherwise, targeted error messages guide the user in correcting any issues.
- Confirmation: Upon successful reservation, a confirmation message appears, and the spot is marked as reserved for the specified time, visible on the app's map view.
This feature is built to support high concurrency, ensuring accurate spot tracking even with simultaneous requests, and can be implemented similarly across platforms like Android (Kotlin) for a seamless experience across devices.
4. Implemented Business Questions
-
How can we improve both user satisfaction and parking space utilization by implementing a real-time reservation system that processes multiple validations concurrently?
-
How can the app improve user satisfaction and optimize parking space usage by implementing a real-time, concurrent reservation system with validations that ensure availability and prevent double-booking?