How google-developer-training/basic-android-kotlin-compose-training-bus-schedule-app works
Project Type and Purpose
• Since this is a mobile application, the architecture will be focused on the Android platform.
• The primary purpose is to retrieve, store, and display bus schedule data. It retrieves the bus schedule data from a local Room database, formats it in a view model, and renders the list in the UI (using Jetpack Compose).
File Structure
• The project contains an "app" directory which holds the Android application code.
• Application Entry Point: BusScheduleApplication.kt
• The Main UI: MainActivity.kt
• UI components: Inside the "ui" package (screens, view model, theme)
• Data layer: In the "data" package (AppDatabase.kt, BusSchedule.kt, BusScheduleDao.kt)
• The project also contains typical Android resource directories under “app/src/main/res” which include layouts, drawable assets, strings, dimensions, and themes.
• Configuration files such as build.gradle.kts are present at both the project and app levels, indicating the use of Gradle as the build tool.
Expanding on README Insights
• The README confirms that the app leverages the Room database (local persistence) to manage bus schedules.
• There is mention of a view model, which signifies adherence to MVVM architecture, a common pattern in Android development.
• The UI is built with Jetpack Compose, streamlining UI creation and interactions.
a. Main Components:
• Android Application Shell:
• MainActivity.kt: Entry point for UI renders.
• BusScheduleApplication.kt: Application-level configuration.
• User Interface (UI) Layer:
• Compose-based screens (BusScheduleScreens.kt) within the “ui” package.
• Theme and styling components (theme package).
• Data Layer:
• Room Database configuration: AppDatabase.kt.
• Data Models: BusSchedule.kt (Schedule data class).
• Data Access Object (DAO): BusScheduleDao.kt for database operations.
• View Model:
• BusScheduleViewModel.kt handling the business logic and data formatting.
• Assets:
• Pre-populated database (bus_schedule.db) is stored under assets for initial data load.
b. Relationships and Interactions:
• The UI layer interacts with the ViewModel (BusScheduleViewModel.kt) to request and present bus schedule data.
• The ViewModel calls methods from the DAO (BusScheduleDao.kt) to query the Room database (AppDatabase.kt).
• The Room database is initialized on app start, possibly at the Application level from BusScheduleApplication.kt.
• Assets provide the pre-populated database to seed the Room database.
• Gradle build system and configuration files are on the peripheral, handling project dependencies, build variants, and packaging.
c. Architectural Patterns and Design Principles:
• MVVM Pattern: Separation of concerns where the View (UI) is separated from the data handling logic (ViewModel), and the Model (data entities and persistence operations) is encapsulated in a Room database.
• Layered Architecture: Clear segregation between UI, business logic, and data persistence.
• Local Data Persistence: The use of Room database abstracts the SQL interactions and provides a robust local storage solution.
d. Relevant Technologies:
• Kotlin: As the programming language.
• Jetpack Compose: For building the user interface.
• Room Database: For handling local data storage and queries.
• Android Studio and Gradle: For development and build automation.