# idfranco/note-manager architecture

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

- Interactive diagram: https://gitdiagram.com/idfranco/note-manager
- Repository: https://github.com/idfranco/note-manager

## Overview

##### Main Components
- User Interface (Frontend): The Angular application is structured under the src/app directory, which includes:
a. LoginComponent and its related sub-components – CreateCredentialComponent and ChangeCredentialComponent – for the user login and credential management flows.
b. AdministrationComponent for note management, along with sub-components such as:
- Edit (modal), and List Note components.
c. Shared Components such as confirm and view password modals that provide generic UI functionalities.
- Core services and business logic:
a. Services in src/app/core/services (NoteService, CredentialService, CryptoService) implement the primary business logic for managing notes and credentials.
b. Error handling and helper functions in the core section which support application-wide functionalities.
- Infraestructure Layer:
a. Persistence Layer: The services under src/app/infraestructure/persistence.indexedDB (IDBNoteService, IDBCredentialService, and the manager for IndexedDB) encapsulate the client-side database interactions.
b. Integration with external libraries: The integration for CryptoES in src/app/infraestructure/integration.cryptoES, which handles encryption and decryption.
- Guards:
a. Authentication and password configuration guards (AuthGuard, AuthSetPasswordGuard) that protect routes and ensure proper access control.

##### Relationships & Data Flow
- The User Interface components (LoginComponent, AdministrationComponent, etc.) interact with the Core services to perform operations such as creating or listing notes.
- These services, in turn, rely on the Infraestructure layer to persist data within IndexedDB. For instance, when a note is created or updated, the NoteService communicates with the IDBNoteService.
- The CryptoService acts as a helper tool for encrypting/decrypting sensitive information.
- Guards are used to control access to certain routes/components, ensuring that only authenticated users or those with the appropriate password setup can manage notes.

##### Architectural Patterns & Design Principles
- Separation of concerns is evident in the split between UI components, core business logic/services, and the infrastructure layer.
- Modular design: The Angular application is composed of several feature modules (e.g., administration and login) which makes the application scalable and maintainable.
- The layered architecture (UI → Core → Infrastructure) is used to isolate the presentation, business, and persistence logic.
- Dependency Injection is likely used extensively (as per Angular conventions) to overcome dependencies between components and services.

##### Elements
- Guards: Include AuthGuard and AuthSetPasswordGuard to show route security.
- Environment and Configuration: Note the use of environment files (environment.ts and environment.prod.ts) to parameterize database configurations and encryption keys.

## Diagram (Mermaid)

```mermaid
flowchart TD

    %% UI Components
    subgraph "User Interface"
        L["LoginComponent"]:::ui
        CC["CreateCredentialComponent"]:::ui
        CH["ChangeCredentialComponent"]:::ui
        A["AdministrationComponent"]:::ui
        LN["ListNoteComponent"]:::ui
        AN["AddNoteComponent"]:::ui
        EN["EditNoteModalComponent"]:::ui
        CM["ConfirmModalComponent"]:::ui
        VP["ViewPasswordModalComponent"]:::ui
    end

    %% Core Services
    subgraph "Core Services"
        NS["NoteService"]:::core
        CS["CredentialService"]:::core
        CrS["CryptoService"]:::core
    end

    %% Infrastructure Layer
    subgraph "Infrastructure"
        IDS["IDBNoteService"]:::infra
        IDC["IDBCredentialService"]:::infra
        IDM["IDBManagerService"]:::infra
        CES["CryptoES Service"]:::infra
    end

    %% Guards
    subgraph "Guards"
        AG["AuthGuard"]:::guard
        ASP["AuthSetPasswordGuard"]:::guard
    end

    %% Data Flow Connections
    %% UI -> Core
    L -->|"triggers"| NS
    L -->|"triggers"| CS
    A -->|"manages notes via"| NS
    A -->|"manages credentials via"| CS
    CC -->|"sends credentials to"| CS
    CH -->|"updates credentials via"| CS
    LN -->|"fetches notes using"| NS
    AN -->|"creates note via"| NS
    EN -->|"updates note via"| NS
    CM -->|"confirms action for"| A
    VP -->|"displays password for"| A

    %% Core -> Infrastructure
    NS -->|"persists note"| IDS
    CS -->|"persists credential"| IDC
    NS -->|"manages storage via"| IDM
    CS -->|"manages storage via"| IDM
    CrS -->|"encrypts/decrypts using"| CES

    %% Guards protecting UI routes/services
    L --- AG
    A --- AG
    A --- ASP

    %% Styles
    classDef ui fill:#cce5ff,stroke:#004085,stroke-width:2px;
    classDef core fill:#d4edda,stroke:#155724,stroke-width:2px;
    classDef infra fill:#fff3cd,stroke:#856404,stroke-width:2px;
    classDef guard fill:#f8d7da,stroke:#721c24,stroke-width:2px;

    %% Click Events
    click L "https://github.com/idfranco/note-manager/blob/master/src/app/components/login/login.component.ts"
    click CC "https://github.com/idfranco/note-manager/blob/master/src/app/components/login/credential/create-credential.component.ts"
    click CH "https://github.com/idfranco/note-manager/blob/master/src/app/components/login/credential/change-credential.component.ts"
    click A "https://github.com/idfranco/note-manager/blob/master/src/app/components/administration/administration.component.ts"
    click LN "https://github.com/idfranco/note-manager/blob/master/src/app/components/administration/list-note/list-note.component.ts"
    click AN "https://github.com/idfranco/note-manager/blob/master/src/app/components/administration/record-note/record/add-note.component.ts"
    click EN "https://github.com/idfranco/note-manager/blob/master/src/app/components/administration/record-note/record/edit-note-modal.component.ts"
    click CM "https://github.com/idfranco/note-manager/blob/master/src/app/components/shared/confirm-modal/confirm-modal.component.ts"
    click VP "https://github.com/idfranco/note-manager/blob/master/src/app/components/shared/view-password-modal/view-password-modal.component.ts"
    click NS "https://github.com/idfranco/note-manager/blob/master/src/app/core/services/note.service.ts"
    click CS "https://github.com/idfranco/note-manager/blob/master/src/app/core/services/credential.service.ts"
    click CrS "https://github.com/idfranco/note-manager/blob/master/src/app/core/services/crypto.service.ts"
    click IDS "https://github.com/idfranco/note-manager/blob/master/src/app/infraestructure/persistence.indexedDB/services/IDB-note.service.ts"
    click IDC "https://github.com/idfranco/note-manager/blob/master/src/app/infraestructure/persistence.indexedDB/services/IDB-credential.service.ts"
    click IDM "https://github.com/idfranco/note-manager/blob/master/src/app/infraestructure/persistence.indexedDB/services/IDB-manager.service.ts"
    click CES "https://github.com/idfranco/note-manager/blob/master/src/app/infraestructure/integration.cryptoES/services/crypto-es.service.ts"
    click AG "https://github.com/idfranco/note-manager/blob/master/src/app/core/guards/auth.guard.ts"
    click ASP "https://github.com/idfranco/note-manager/blob/master/src/app/core/guards/auth-set-password.guard.ts"
```
