# codefrydev/yournotebook architecture

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

- Interactive diagram: https://gitdiagram.com/codefrydev/yournotebook
- Repository: https://github.com/codefrydev/yournotebook

## Overview

##### Major Components
- UI / Presentation Layer:
- • App.razor, Pages (e.g., Home.razor and Folder.razor)
- • Layouts (MainLayout, FolderLayout, NavMenu, FolderNavMenu)
- • Components for different functionalities (FolderComponent, NotesComponent, ShortcutComponent, and various Popup components)
- Data Management Layer:
- • Data directory (FolderManager, NotesManager, ShortcutManager, InMemoryRepo, IManager) which handles CRUD operations and state management for folders, notes, and shortcuts.
- • Models (data contracts such as FolderModel, Note, Category, Shortcut, etc.)
- Helper and Utility Services:
- • Helper directory (BlazoredLocalStorageHelper, FirebaseHelper, PopUpDialogueStyle) to assist with local storage and Firebase integration.
- • Utils (Constant, CurrentContext, Mapper) for common utilities.
- Integration / Service Layer:
- • Services directory (FirebaseJsInteropService and WeServices folder) for interop with Firebase and any external web services.
- External / Cloud Services:
- • Firebase integration is clearly an important external dependency, as indicated by Firebase-related pop-ups, models, and helper classes.
- Deployment and CI/CD:
- • The presence of .github and its workflows (deploy.yaml) indicates automated deployment builds or integration which can be shown as an external system interacting with your repository.

##### Relationships and Interactions
- The UI components (implemented using Razor pages and reusable components) interact with the Data Management Layer to present and modify the state (e.g., notes, folders, shortcuts).
- When a user takes an action (say, adding or editing a note), the UI triggers components which call into their corresponding code-behind (.razor.cs) that further leverage methods from the Data layer.
- The Data layer interfaces with helper classes (such as those for local storage or Firebase) to persist or retrieve data.
- Services like FirebaseJsInteropService facilitate communication between the Blazor application and external web APIs (Firebase in this case).
- Utility functions (like Mapper) convert between different data formats where needed.
- The CI/CD pipeline defined under .github/workflows/deploy.yaml automates deployment, ensuring that updates to components, data management, or integration logic are built and deployed consistently.

##### Architectural Patterns and Design Principles
- The project employs a component-based design (characteristic of Blazor) where UI, logic, and style are encapsulated within each component (Razor file along with its code-behind, CSS, and JavaScript).
- A layered architecture can be observed with a clear separation between the presentation (UI), business/data logic (Data Managers and Models), and external integrations (Helpers and Services).
- Additionally, use of interfaces (IManager) and dependency injection (likely configured in Program.cs) suggests an emphasis on testability and separation of concerns.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% UI / Presentation Layer
    subgraph "UI / Presentation Layer"
        A["App.razor"]:::ui
        subgraph "Pages"
            PH["Home.razor"]:::ui
            PF["Folder.razor"]:::ui
        end
        subgraph "Layouts"
            ML["MainLayout.razor"]:::ui
            FL["FolderLayout.razor"]:::ui
            NM["NavMenu.razor"]:::ui
            FNM["FolderNavMenu.razor"]:::ui
        end
        subgraph "Reusable Components"
            FC["FolderComponent"]:::ui
            NC["NotesComponent"]:::ui
            SC["ShortcutComponent"]:::ui
            subgraph "Popup Components"
                P1["AddNewFolderDialogue"]:::ui
                P2["AddNotesDialogue"]:::ui
                P3["AddShortcutDialogue"]:::ui
                P4["DeleteDialogue"]:::ui
                P5["EditNotesDialogue"]:::ui
                P6["EditShortcutDialogue"]:::ui
                P7["FirebaseDialogue"]:::ui
                P8["RenameDialogue"]:::ui
            end
        end
    end

    %% Data Management Layer
    subgraph "Data Management Layer"
        subgraph "Data Managers/Repositry"
            D1["FolderManager"]:::data
            D2["NotesManager"]:::data
            D3["ShortcutManager"]:::data
            D4["InMemoryRepo"]:::data
            D5["IManager"]:::data
        end
        subgraph "Models"
            M1["FolderModel"]:::data
            M2["Note"]:::data
            M3["Category"]:::data
            M4["Shortcut"]:::data
        end
    end

    %% Helpers & Utilities
    subgraph "Helpers & Utilities"
        H1["BlazoredLocalStorageHelper"]:::helper
        H2["FirebaseHelper"]:::helper
        H3["PopUpDialogueStyle"]:::helper
        U1["Constant"]:::helper
        U2["CurrentContext"]:::helper
        U3["Mapper"]:::helper
    end

    %% Integration / Service Layer
    subgraph "Integration / Service Layer"
        I1["FirebaseJsInteropService"]:::integration
        I2["AddServices"]:::integration
    end

    %% External / Cloud Services
    subgraph "External / Cloud Services"
        X1["Firebase Cloud Service"]:::external
    end

    %% CI/CD Deployment
    subgraph "CI/CD Deployment"
        C1[".github/workflows/deploy.yaml"]:::cicd
    end

    %% Relationships between UI and Data Management
    PH -->|"triggers"| D4
    PF -->|"triggers"| D4
    FC -->|"calls"| D1
    NC -->|"calls"| D2
    SC -->|"calls"| D3

    %% Relationships between Data Managers and Models
    D1 -->|"handles"| M1
    D2 -->|"handles"| M2
    D2 -->|"handles"| M3
    D3 -->|"handles"| M4

    %% Data Managers leveraging Helpers & Utilities
    D1 -->|"utilizes"| H1
    D2 -->|"utilizes"| H1
    D3 -->|"utilizes"| H1
    D2 -->|"maps"| U3

    %% UI interacting with Helpers directly (Firebase for example)
    NC -->|"integrates"| H2

    %% Helper to Integration flow
    H2 -->|"interop"| I1

    %% Integration with External Cloud Services
    I1 -->|"communicates"| X1
    I2 -->|"communicates"| X1

    %% CI/CD Deployment triggers updates in the project
    C1 -->|"deploys"| A

    %% Class Definitions for Colours
    classDef ui fill:#FFEE93,stroke:#333,stroke-width:2px;
    classDef data fill:#ADD8E6,stroke:#333,stroke-width:2px;
    classDef helper fill:#C8E6C9,stroke:#333,stroke-width:2px;
    classDef integration fill:#FFCC80,stroke:#333,stroke-width:2px;
    classDef external fill:#F08080,stroke:#333,stroke-width:2px;
    classDef cicd fill:#D3D3D3,stroke:#333,stroke-width:2px;

    %% Click Events for UI / Presentation Layer
    click A "https://github.com/codefrydev/yournotebook/blob/master/App.razor"
    click PH "https://github.com/codefrydev/yournotebook/blob/master/Pages/Home.razor"
    click PF "https://github.com/codefrydev/yournotebook/blob/master/Pages/Folder.razor"
    click ML "https://github.com/codefrydev/yournotebook/blob/master/Layout/MainLayout.razor"
    click FL "https://github.com/codefrydev/yournotebook/blob/master/Layout/FolderLayout.razor"
    click NM "https://github.com/codefrydev/yournotebook/blob/master/Layout/NavMenu.razor"
    click FNM "https://github.com/codefrydev/yournotebook/blob/master/Layout/FolderNavMenu.razor"
    click FC "https://github.com/codefrydev/yournotebook/blob/master/Components/FolderComponent.razor"
    click NC "https://github.com/codefrydev/yournotebook/blob/master/Components/NotesComponent.razor"
    click SC "https://github.com/codefrydev/yournotebook/blob/master/Components/ShortcutComponent.razor"
    click P1 "https://github.com/codefrydev/yournotebook/blob/master/Components/Popup/AddNewFolderDialogue.razor"
    click P2 "https://github.com/codefrydev/yournotebook/blob/master/Components/Popup/AddNotesDialogue.razor"
    click P3 "https://github.com/codefrydev/yournotebook/blob/master/Components/Popup/AddShortcutDialogue.razor"
    click P4 "https://github.com/codefrydev/yournotebook/blob/master/Components/Popup/DeleteDialogue.razor"
    click P5 "https://github.com/codefrydev/yournotebook/blob/master/Components/Popup/EditNotesDialogue.razor"
    click P6 "https://github.com/codefrydev/yournotebook/blob/master/Components/Popup/EditShortcutDialogue.razor"
    click P7 "https://github.com/codefrydev/yournotebook/blob/master/Components/Popup/FireBaseDialogue.razor"
    click P8 "https://github.com/codefrydev/yournotebook/blob/master/Components/Popup/RenameDialogue.razor"

    %% Click Events for Data Management Layer
    click D1 "https://github.com/codefrydev/yournotebook/blob/master/Data/FolderManger.cs"
    click D2 "https://github.com/codefrydev/yournotebook/blob/master/Data/NotesManager.cs"
    click D3 "https://github.com/codefrydev/yournotebook/blob/master/Data/ShortcutManager.cs"
    click D4 "https://github.com/codefrydev/yournotebook/blob/master/Data/InMemoryRepo.cs"
    click D5 "https://github.com/codefrydev/yournotebook/blob/master/Data/IManager.cs"
    click M1 "https://github.com/codefrydev/yournotebook/blob/master/Models/FolderModel.cs"
    click M2 "https://github.com/codefrydev/yournotebook/blob/master/Models/Note.cs"
    click M3 "https://github.com/codefrydev/yournotebook/blob/master/Models/Category.cs"
    click M4 "https://github.com/codefrydev/yournotebook/blob/master/Models/Shortcut.cs"

    %% Click Events for Helpers & Utilities
    click H1 "https://github.com/codefrydev/yournotebook/blob/master/Helper/BlazoredLocalStorageHelper.cs"
    click H2 "https://github.com/codefrydev/yournotebook/blob/master/Helper/FirebaseHelper.cs"
    click H3 "https://github.com/codefrydev/yournotebook/blob/master/Helper/PopUpDialogueStyle.cs"
    click U1 "https://github.com/codefrydev/yournotebook/blob/master/Utils/Constant.cs"
    click U2 "https://github.com/codefrydev/yournotebook/blob/master/Utils/CurrentContext.cs"
    click U3 "https://github.com/codefrydev/yournotebook/blob/master/Utils/Mapper.cs"

    %% Click Events for Integration / Service Layer
    click I1 "https://github.com/codefrydev/yournotebook/blob/master/Services/FirebaseJsInteropService.cs"
    click I2 "https://github.com/codefrydev/yournotebook/blob/master/Services/WeServices/AddServices.cs"

    %% Click Event for CI/CD Deployment
    click C1 "https://github.com/codefrydev/yournotebook/blob/master/.github/workflows/deploy.yaml"
```
