Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update README with Data Flow and Code Structure for Cupcake App #113

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

ashwanil23
Copy link

@ashwanil23 ashwanil23 commented Oct 28, 2024

This commit adds a detailed explanation of the data flow and code structure for the "Cupcake" app, providing a clear breakdown of user interactions, ViewModel state management, navigation flow, and UI reactivity. A diagram has been added to improve understanding, illustrating the architecture of the app and how data flows through various components like screens and the OrderViewModel.

This update is aimed at improving the documentation to help future contributors and users easily understand the project's structure and logic.

here is the sample of the diagram
cupcake app diagram (1)

The diagram explains the overall data flow of the "Cupcake" app. The architecture and flow can be summarized as follows:

User Interaction (Screens):

The user interacts with the app through four key screens:
StartOrderScreen: Users select the number of cupcakes.
FlavorScreen: Users select the cupcake flavor.
PickupScreen: Users choose a pickup date.
SummaryScreen: The final order details are displayed, and users can share the order.
Cupcake Screens Enum:

The app navigates between screens using the CupcakeScreen enum, where each screen is associated with a title resource (R.string.choose_flavor, etc.).
OrderViewModel:

The OrderViewModel manages the cupcake order state. It uses MutableStateFlow to store the order details, like quantity, flavor, and pickup date. The model also handles logic like price calculation, adding a surcharge for same-day pickup.
As users interact with the UI (selecting a quantity, flavor, or date), the OrderViewModel updates the uiState, which is observed by the UI to reflect the changes in real-time.
Navigation:

The navigation between screens is handled using the NavController. Based on user actions (e.g., clicking "Next"), the app moves to the next screen, and the OrderViewModel updates the necessary state (e.g., quantity, flavor, or date).
UI State and Updates:

The UI is reactive, meaning that it observes changes in the uiState. For example, the price is recalculated every time the user changes the quantity or pickup date, and the updated price is displayed in the UI.
Order Summary:

The SummaryScreen displays the final order details and allows the user to share the order using an Android implicit intent.
The diagram explains the overall data flow of the "Cupcake" app. The architecture and flow can be summarized as follows:

User Interaction (Screens):

The user interacts with the app through four key screens:
StartOrderScreen: Users select the number of cupcakes.
FlavorScreen: Users select the cupcake flavor.
PickupScreen: Users choose a pickup date.
SummaryScreen: The final order details are displayed, and users can share the order.
Cupcake Screens Enum:

The app navigates between screens using the CupcakeScreen enum, where each screen is associated with a title resource (R.string.choose_flavor, etc.).
OrderViewModel:

The OrderViewModel manages the cupcake order state. It uses MutableStateFlow to store the order details, like quantity, flavor, and pickup date. The model also handles logic like price calculation, adding a surcharge for same-day pickup.
As users interact with the UI (selecting a quantity, flavor, or date), the OrderViewModel updates the uiState, which is observed by the UI to reflect the changes in real-time.
Navigation:

The navigation between screens is handled using the NavController. Based on user actions (e.g., clicking "Next"), the app moves to the next screen, and the OrderViewModel updates the necessary state (e.g., quantity, flavor, or date).
UI State and Updates:

The UI is reactive, meaning that it observes changes in the uiState. For example, the price is recalculated every time the user changes the quantity or pickup date, and the updated price is displayed in the UI.
Order Summary:

The SummaryScreen displays the final order details and allows the user to share the order using an Android implicit intent.
Data Flow and Code Structure (with Diagram Explanation):

The diagram explains the overall data flow of the "Cupcake" app. The architecture and flow can be summarized as follows:

User Interaction (Screens):

The user interacts with the app through four key screens:
StartOrderScreen: Users select the number of cupcakes.
FlavorScreen: Users select the cupcake flavor.
PickupScreen: Users choose a pickup date.
SummaryScreen: The final order details are displayed, and users can share the order.
Cupcake Screens Enum:

The app navigates between screens using the CupcakeScreen enum, where each screen is associated with a title resource (R.string.choose_flavor, etc.).
OrderViewModel:

The OrderViewModel manages the cupcake order state. It uses MutableStateFlow to store the order details, like quantity, flavor, and pickup date. The model also handles logic like price calculation, adding a surcharge for same-day pickup.
As users interact with the UI (selecting a quantity, flavor, or date), the OrderViewModel updates the uiState, which is observed by the UI to reflect the changes in real-time.
Navigation:

The navigation between screens is handled using the NavController. Based on user actions (e.g., clicking "Next"), the app moves to the next screen, and the OrderViewModel updates the necessary state (e.g., quantity, flavor, or date).
UI State and Updates:

The UI is reactive, meaning that it observes changes in the uiState. For example, the price is recalculated every time the user changes the quantity or pickup date, and the updated price is displayed in the UI.
Order Summary:

The SummaryScreen displays the final order details and allows the user to share the order using an Android implicit intent.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant