# dinakaran-k/notesappwithroomdb architecture

> Architecture diagram of the GitHub repository dinakaran-k/notesappwithroomdb, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/dinakaran-k/notesappwithroomdb
- Repository: https://github.com/dinakaran-k/notesappwithroomdb

## Overview

##### 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.).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% UI Layer
    subgraph "UI Layer"
        A["SplashScreenActivity"]:::ui
        B["MainActivity"]:::ui
        C["HomeFragment"]:::ui
        D["AddNoteFragment"]:::ui
        E["EditNoteFragment"]:::ui
        F["NoteAdapter"]:::ui
    end

    %% Presentation Layer
    subgraph "Presentation Layer"
        G["NoteViewModel"]:::presentation
        H["NoteViewModelFactory"]:::presentation
    end

    %% Data Access Layer
    subgraph "Data Access Layer"
        I["NoteRepository"]:::data
        subgraph "Room Database"
            J["NoteDatabase"]:::data
            K["NoteDao"]:::data
        end
        L["Note Model"]:::data
    end

    %% Relationships
    A -->|"launches"| B
    B -->|"hosts"| C
    B -->|"hosts"| D
    B -->|"hosts"| E
    C -->|"binds data with"| F
    C -->|"interacts_with"| G
    D -->|"interacts_with"| G
    E -->|"interacts_with"| G
    H -->|"creates"| G
    G -->|"calls"| I
    I -->|"manages"| L
    I -->|"calls"| K
    J -->|"provides"| K
    G -->|"updates"| F

    %% Click Events
    click A "https://github.com/dinakaran-k/notesappwithroomdb/blob/master/app/src/main/java/com/example/notesappwithroomdb/splashScreen/SplashScreenActivity.kt"
    click B "https://github.com/dinakaran-k/notesappwithroomdb/blob/master/app/src/main/java/com/example/notesappwithroomdb/MainActivity.kt"
    click C "https://github.com/dinakaran-k/notesappwithroomdb/blob/master/app/src/main/java/com/example/notesappwithroomdb/fragment/HomeFragment.kt"
    click D "https://github.com/dinakaran-k/notesappwithroomdb/blob/master/app/src/main/java/com/example/notesappwithroomdb/fragment/AddNoteFragment.kt"
    click E "https://github.com/dinakaran-k/notesappwithroomdb/blob/master/app/src/main/java/com/example/notesappwithroomdb/fragment/EditNoteFragment.kt"
    click F "https://github.com/dinakaran-k/notesappwithroomdb/blob/master/app/src/main/java/com/example/notesappwithroomdb/adapter/NoteAdapter.kt"
    click G "https://github.com/dinakaran-k/notesappwithroomdb/blob/master/app/src/main/java/com/example/notesappwithroomdb/viewmodel/NoteViewModel.kt"
    click H "https://github.com/dinakaran-k/notesappwithroomdb/blob/master/app/src/main/java/com/example/notesappwithroomdb/viewmodel/NoteViewModelFactory.kt"
    click I "https://github.com/dinakaran-k/notesappwithroomdb/blob/master/app/src/main/java/com/example/notesappwithroomdb/repository/NoteRepository.kt"
    click J "https://github.com/dinakaran-k/notesappwithroomdb/blob/master/app/src/main/java/com/example/notesappwithroomdb/database/NoteDatabase.kt"
    click K "https://github.com/dinakaran-k/notesappwithroomdb/blob/master/app/src/main/java/com/example/notesappwithroomdb/database/NoteDao.kt"
    click L "https://github.com/dinakaran-k/notesappwithroomdb/blob/master/app/src/main/java/com/example/notesappwithroomdb/model/Note.kt"

    %% Styles
    classDef ui fill:#ADD8E6,stroke:#0000FF,stroke-width:2px;
    classDef presentation fill:#90EE90,stroke:#00AA00,stroke-width:2px;
    classDef data fill:#FFB6C1,stroke:#FF69B4,stroke-width:2px;
```
