# h4xor7/dnote architecture

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

- Interactive diagram: https://gitdiagram.com/h4xor7/dnote
- Repository: https://github.com/h4xor7/dnote

## Overview

##### Project Type and Purpose
- This is a native Android application written in Kotlin.
- Its main function is to allow users to create both text and voice notes.
- It leverages Android’s architectural components such as ViewModel and LiveData, along with Room Database for persistence.
- Additional functionality includes using the Media Player for audio playback and various broadcast receivers (e.g., for alerts and boot events).

##### Analyzing the File Structure
- The main code is within the “app” directory, and the structure follows a clear separation of concerns.
- Notice the “src/main/java/com/pandey/saurabh/dnote” package – this shows a deeper module separation:
- The “data” folder contains subdirectories like “local” and “local/db” for Room Database implementations (with NoteRoomDatabase.kt and AudioNoteRoomDatabase.kt) and DAO interfaces (NoteDao.kt, AudioNoteDao.kt).
- The “data/model” directory holds the definition of data models such as Note.kt and AudioNote.kt.
- The “data/repository” folder shows repository layers (NoteRepository.kt, AudioNoteRepository.kt) that abstract away data access from the rest of the application.
- The “ui” folder contains subdirectories for views, viewmodels, adapters, and base activities – a typical sign of the MVVM pattern.
- Several Broadcast Receivers (AlertReceiver.kt and BootReceiver.kt) suggest background events or scheduled notifications.
- Other parts such as the “res” directory hold layout XML files, animations, menus, and other resources, outlining the UI design.

- Main Components to Include:
a. UI/Presentation Layer: Represented by activities (e.g., MainActivity, SplashActivity, CreateAudioNoteActivity), fragments or dialogs. Also, list adapters and toolbars.
b. ViewModel Layer: Highlight components like AudioNoteViewModel and MakeEntryViewModel. This layer communicates directly with the repositories.
c. Repository Layer: Indicate NoteRepository and AudioNoteRepository. They act as an intermediary between the ViewModels and the data sources.
d. Data Layer: Include local databases (NoteRoomDatabase and AudioNoteRoomDatabase) along with their DAOs. This is where Room Database interacts with the data models.
e. Multimedia Components: Illustrate the use of Media Player for audio playback.
f. System-level Components: Represent broadcast receivers (AlertReceiver, BootReceiver) which handle external/environmental triggers.
g. Android Framework and Resources: Optionally note that XML resources, layouts, animations, and menus form the UI components.

- Relationships and Interactions:
- The Repository layer should have bidirectional communication with the data layer (Room Database) – retrieve and store data.
- That the Media Player module gets invoked by some UI components (like AudioNoteActivity) for playing audio files.

##### Architectural Patterns and Technologies
- MVVM architectural pattern: Clearly separate the application into Model (data layer), View (UI layer), and ViewModel (communication/logic layer).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% UI/Presentation Layer
    subgraph "UI/Presentation Layer"
        UI_MainActivity["MainActivity (Entry Point)"]:::ui
        UI_SplashActivity["SplashActivity"]:::ui
        UI_CreateAudioNoteActivity["CreateAudioNoteActivity"]:::ui
        UI_AudioNoteActivity["AudioNoteActivity"]:::ui
        UI_MakeEntryActivity["MakeEntryActivity"]:::ui
        UI_TimePickerFragment["TimePickerFragment"]:::ui
    end

    %% ViewModel Layer
    subgraph "ViewModel Layer"
        VM_AudioNoteViewModel["AudioNoteViewModel"]:::viewmodel
        VM_MakeEntryViewModel["MakeEntryViewModel"]:::viewmodel
    end

    %% Repository Layer
    subgraph "Repository Layer"
        Repo_NoteRepository["NoteRepository"]:::repository
        Repo_AudioNoteRepository["AudioNoteRepository"]:::repository
    end

    %% Data Layer
    subgraph "Data Layer"
        DB_NoteRoomDatabase["NoteRoomDatabase"]:::database
        DB_AudioNoteRoomDatabase["AudioNoteRoomDatabase"]:::database
        subgraph "DAO Layer"
            DAO_Note["NoteDao"]:::database
            DAO_AudioNote["AudioNoteDao"]:::database
        end
    end

    %% Data Models
    subgraph "Data Models"
        Model_Note["Note"]:::models
        Model_AudioNote["AudioNote"]:::models
    end

    %% Broadcast Receivers
    subgraph "Broadcast Receivers"
        Receiver_Alert["AlertReceiver"]:::receivers
        Receiver_Boot["BootReceiver"]:::receivers
    end

    %% Multimedia Component
    MediaPlayer["MediaPlayer (Audio Playback)"]:::multimedia

    %% Connections between layers
    %% UI to ViewModel
    UI_AudioNoteActivity -->|"userAction"| VM_AudioNoteViewModel
    UI_MakeEntryActivity -->|"userAction"| VM_MakeEntryViewModel

    %% ViewModel to Repository
    VM_AudioNoteViewModel -->|"fetchUpdate"| Repo_AudioNoteRepository
    VM_MakeEntryViewModel -->|"fetchUpdate"| Repo_NoteRepository

    %% Repository to Data Layer
    Repo_AudioNoteRepository -->|"CRUD"| DB_AudioNoteRoomDatabase
    Repo_NoteRepository -->|"CRUD"| DB_NoteRoomDatabase

    %% Data Layer to DAO
    DB_NoteRoomDatabase -->|"provides"| DAO_Note
    DB_AudioNoteRoomDatabase -->|"provides"| DAO_AudioNote

    %% DAO to Data Models
    DAO_Note -->|"mapsTo"| Model_Note
    DAO_AudioNote -->|"mapsTo"| Model_AudioNote

    %% UI Multimedia interaction
    UI_AudioNoteActivity -->|"invokes"| MediaPlayer

    %% Broadcast Receivers trigger UI actions
    Receiver_Alert -->|"triggers"| UI_MainActivity
    Receiver_Boot -->|"triggers"| UI_SplashActivity

    %% Click Events
    click UI_MainActivity "https://github.com/h4xor7/dnote/tree/master/app/src/main/java/com/pandey/saurabh/dnote/ui/main/view"
    click UI_SplashActivity "https://github.com/h4xor7/dnote/tree/master/app/src/main/java/com/pandey/saurabh/dnote/ui/main/view"
    click UI_CreateAudioNoteActivity "https://github.com/h4xor7/dnote/tree/master/app/src/main/java/com/pandey/saurabh/dnote/ui/main/view"
    click UI_AudioNoteActivity "https://github.com/h4xor7/dnote/blob/master/app/src/main/java/com/pandey/saurabh/dnote/ui/main/view/AudioNoteActivity.kt"
    click UI_MakeEntryActivity "https://github.com/h4xor7/dnote/tree/master/app/src/main/java/com/pandey/saurabh/dnote/ui/main/view"
    click UI_TimePickerFragment "https://github.com/h4xor7/dnote/tree/master/app/src/main/java/com/pandey/saurabh/dnote/ui/main/view"
    
    click VM_AudioNoteViewModel "https://github.com/h4xor7/dnote/tree/master/app/src/main/java/com/pandey/saurabh/dnote/ui/main/viewmodel"
    click VM_MakeEntryViewModel "https://github.com/h4xor7/dnote/tree/master/app/src/main/java/com/pandey/saurabh/dnote/ui/main/viewmodel"
    
    click Repo_NoteRepository "https://github.com/h4xor7/dnote/tree/master/app/src/main/java/com/pandey/saurabh/dnote/data/repository"
    click Repo_AudioNoteRepository "https://github.com/h4xor7/dnote/tree/master/app/src/main/java/com/pandey/saurabh/dnote/data/repository"

    click DB_NoteRoomDatabase "https://github.com/h4xor7/dnote/tree/master/app/src/main/java/com/pandey/saurabh/dnote/data/local/db"
    click DB_AudioNoteRoomDatabase "https://github.com/h4xor7/dnote/tree/master/app/src/main/java/com/pandey/saurabh/dnote/data/local/db"
    click DAO_Note "https://github.com/h4xor7/dnote/tree/master/app/src/main/java/com/pandey/saurabh/dnote/data/local/db/dao"
    click DAO_AudioNote "https://github.com/h4xor7/dnote/tree/master/app/src/main/java/com/pandey/saurabh/dnote/data/local/db/dao"

    click Model_Note "https://github.com/h4xor7/dnote/tree/master/app/src/main/java/com/pandey/saurabh/dnote/data/model"
    click Model_AudioNote "https://github.com/h4xor7/dnote/tree/master/app/src/main/java/com/pandey/saurabh/dnote/data/model"

    click Receiver_Alert "https://github.com/h4xor7/dnote/tree/master/app/src/main/java/com/pandey/saurabh/dnote/receiver"
    click Receiver_Boot "https://github.com/h4xor7/dnote/tree/master/app/src/main/java/com/pandey/saurabh/dnote/receiver"

    %% Styles
    classDef ui fill:#AED6F1,stroke:#1B4F72,stroke-width:2px;
    classDef viewmodel fill:#A9DFBF,stroke:#145A32,stroke-width:2px;
    classDef repository fill:#F9E79F,stroke:#B7950B,stroke-width:2px;
    classDef database fill:#F5CBA7,stroke:#943126,stroke-width:2px;
    classDef models fill:#D5F5E3,stroke:#1E8449,stroke-width:2px;
    classDef receivers fill:#D7BDE2,stroke:#6C3483,stroke-width:2px;
    classDef multimedia fill:#FAD7A0,stroke:#AF601A,stroke-width:2px;
```
