How sricharan97/littlelemoneats works
Project Type and Purpose
• This is a native Android mobile application built with Kotlin and Jetpack Compose.
• Its purpose is to provide a seamless food ordering experience, including dynamic menu browsing, advanced filtering, search functionality, and secure transaction management for Little Lemon Restaurant.
• The project is structured as a typical Android application with a clean separation between UI, data management, and networking.
Main Architectural Components
a. UI Layer:
• Represents the user-facing part of the application, built entirely using Jetpack Compose.
• Key packages include:
• ui/composables for reusable UI components (e.g., ActionButton, Header, ProfileAvatar).
• ui/home, ui/menu, ui/onboarding, ui/profile for different screens.
• ui/theme for theming details supporting Material Design 3.
• Navigation is implemented using Compose Navigation (with NavigationComposable, LemonDestinations, etc.) to manage transitions between screens.
b. Data and Persistence Layer:
• Managed in the data package and includes:
• Entity and DAO classes (MenuEntity, MenuItemDao) using Room for local data persistence.
• Repositories (MenuRepository and UserPreferencesRepository) that handle data operations.
• Data classes (CartItem, UserData, UserPreferences) that represent application models.
• SharedPreferences are used to store simple user preferences.
c. Networking Layer:
• Encompasses the network package:
• Contains service interfaces and implementations (MenuItemService, MenuItemServiceImpl) to manage remote API calls using the Ktor client.
• DTOs (DataTransferObjects) for handling JSON data, ensuring clear separation of network data representation.
• All network requests are designed to run asynchronously using Kotlin coroutines.
d. Application Core/Entry Point:
• MainActivity.kt serves as the central entry point to the application.
• Associated ViewModel (MainViewModel.kt) is used for state management and to bridge between the UI and the business logic.
Relationships and Interactions
• UI Components (via Compose) interact with the ViewModel to receive state updates and issue user actions.
• The ViewModel communicates with repositories, which abstract the data sources.
• Repositories decide whether to retrieve or store data in the local Room database or fetch fresh data via the Ktor-based network services.
• Glide is used within UI components to asynchronously load and cache images for the menu items.
• Navigation components (NavigationComposable and Navigation Graph) maintain the flow and lifecycle management between different screens.
Architectural Patterns and Design Principles
• Layered Architecture: Clear separation between UI, data management, and networking.
• MVVM (Model-View-ViewModel): The integration of MainActivity, MainViewModel, and the repositories demonstrates clean separation of concerns.
• Asynchronous Programming: Networking and data persistence operations are managed using Kotlin coroutines to avoid blocking UI threads.
• Modular Design: Code is organized into packages (ui, data, navigation, network, utils), making it easier to understand and maintain.
Elements
• Annotations: Optionally note key technologies (Glide, Jetpack Compose, Ktor, Room) and specific design principles (MVVM, asynchronous processing).