How dinakaran-k/notesappwithroomdb works
Main Components
• User Interface (UI) Layer:
• SplashScreenActivity: Acts as the entry point, displaying the splash screen.
• MainActivity: The central activity that hosts the app’s fragments.
• Fragments: HomeFragment for displaying notes, AddNoteFragment for adding notes, and EditNoteFragment for updating notes.
• Adapter (NoteAdapter): Responsible for binding note data to the list views in HomeFragment.
• Business Logic Layer:
• ViewModel (NoteViewModel and its Factory): Manages UI-related data and communicates with the Repository.
• Data Access Layer:
• Repository (NoteRepository): Acts as an abstraction layer that mediates between the ViewModel and the data source.
• Room Database Components:
• NoteDatabase: The database instance.
• NoteDao: Data Access Object containing methods for CRUD operations.
• Model (Note): The data model representing a note entity.
Relationships and Interactions
• The UI layer (Activities/Fragments) interacts with the ViewModel (NoteViewModel), often through data binding or LiveData.
• The ViewModel makes calls to the Repository to perform data operations.
• The Repository serves as an abstraction for the data layer and interacts with the Room database via NoteDao.
• The Adapter is used within the HomeFragment to display a list of notes derived from the ViewModel.
Architectural Patterns & Design Principles
• The project employs the MVVM pattern:
• Model: Represents the Note data.
• View: Activities and Fragments managing the user interface.
• ViewModel: Provides data to the View and handles UI logic.
• There’s a clear separation of concerns:
• UI handling is distinctly separated from business logic and data access.
• The repository pattern ensures that data operations are not directly tied to the UI components.
Technologies & Frameworks
• Kotlin: The primary programming language.
• Android Components: Activities, Fragments, and other resources (layouts, drawables, navigation).
• Room Database: For local persistence with SQLite.
• Gradle: Used as the build system with associated configuration files (build.gradle.kts, settings.gradle.kts, etc.).