# pbek/qownnotes architecture

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

- Interactive diagram: https://gitdiagram.com/pbek/qownnotes
- Repository: https://github.com/pbek/qownnotes

## Overview

##### Main Components Identification

The system can be broken down into these major components:

a) Core Application Layer:
- Management System (src/entities/note.*)
- Database Service (src/services/databaseservice.*)
- Settings Service (src/services/settingsservice.*)
- Scripting Engine (src/services/scriptingservice.*)
- Encryption Service (src/services/cryptoservice.*)

b) User Interface Layer:
- Main Window (src/mainwindow.*)
- Dialogs (src/dialogs/*)
- Widgets (src/widgets/*)
- Preview System (src/widgets/htmlpreviewwidget.*)

c) External Services Integration:
- Nextcloud/ownCloud Sync (src/services/owncloudservice.*)
- WebSocket Server (src/services/websocketserverservice.*)
- OpenAI Integration (src/services/openaiservice.*)
- Web Companion API (src/services/webappclientservice.*)

d) Data Storage:
- Local File System (markdown files)
- SQLite Database (for metadata)
- Cloud Storage (Nextcloud/ownCloud)

##### Connection Types

- Double lines: Data flow

**┌─────────────────────────────────────────────────────┐**
- UI Layer                           │
- (MainWindow, Dialogs, Widgets, Preview)           │
- ┤
- Core Application Layer               │
- (Note Management, Database, Settings, Scripting)   │
- ┤
- Integration Layer                      │
- (Cloud Sync, WebSocket, OpenAI, Web Companion)    │
- ┤
- Storage Layer                        │
- (Local Files, SQLite, Cloud Storage)              │
- ┘

##### Additional Elements

Supporting components:
- Version control integration
- Spell checking system
- Search functionality
- Tag management
- Todo list integration

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Styles
    classDef ui fill:#90EE90,stroke:#333,stroke-width:2px
    classDef core fill:#ADD8E6,stroke:#333,stroke-width:2px
    classDef storage fill:#D3D3D3,stroke:#333,stroke-width:2px
    classDef external fill:#FFD700,stroke:#333,stroke-width:2px
    classDef api fill:#DDA0DD,stroke:#333,stroke-width:2px

    %% UI Layer
    subgraph UI
        MW[Main Window]
        DS[Dialog System]
        WS[Widget System]
        PS[Preview System]
    end

    %% Core Layer
    subgraph Core
        NMS[Note Management System]
        DBS[Database Service]
        SS[Settings Service]
        SE[Scripting Engine]
        ES[Encryption Service]
    end

    %% Integration Layer
    subgraph Integration
        NCS[Nextcloud/ownCloud Sync]
        WSS[WebSocket Server]
        OAI[OpenAI Integration]
        WCA[Web Companion API]
    end

    %% Storage Layer
    subgraph Storage
        LFS[(Local File System)]
        DB[(SQLite Database)]
        CS[(Cloud Storage)]
    end

    %% Relationships
    MW --> NMS
    MW --> PS
    MW --> DS
    MW --> WS
    NMS --> DBS
    NMS --> ES
    DBS --> DB
    NMS --> LFS
    NCS --> CS
    SE --> NMS
    SE --> WSS
    WCA --> WSS
    OAI --> NMS

    %% Click Events
    click NMS "https://github.com/pbek/QOwnNotes/blob/main/src/entities/note.cpp"
    click DBS "https://github.com/pbek/QOwnNotes/blob/main/src/services/databaseservice.cpp"
    click SS "https://github.com/pbek/QOwnNotes/blob/main/src/services/settingsservice.cpp"
    click SE "https://github.com/pbek/QOwnNotes/blob/main/src/services/scriptingservice.cpp"
    click ES "https://github.com/pbek/QOwnNotes/blob/main/src/services/cryptoservice.cpp"
    click MW "https://github.com/pbek/QOwnNotes/blob/main/src/mainwindow.cpp"
    click DS "https://github.com/pbek/QOwnNotes/tree/main/src/dialogs/"
    click WS "https://github.com/pbek/QOwnNotes/tree/main/src/widgets/"
    click PS "https://github.com/pbek/QOwnNotes/blob/main/src/widgets/htmlpreviewwidget.cpp"
    click NCS "https://github.com/pbek/QOwnNotes/blob/main/src/services/owncloudservice.cpp"
    click WSS "https://github.com/pbek/QOwnNotes/blob/main/src/services/websocketserverservice.cpp"
    click OAI "https://github.com/pbek/QOwnNotes/blob/main/src/services/openaiservice.cpp"
    click WCA "https://github.com/pbek/QOwnNotes/blob/main/src/services/webappclientservice.cpp"

    %% Legend
    subgraph Legend
        UI_L[UI Components]:::ui
        CORE_L[Core Components]:::core
        STORAGE_L[(Storage Systems)]:::storage
        EXT_L[External Services]:::external
        API_L[APIs]:::api
    end

    %% Style Applications
    class MW,DS,WS,PS ui
    class NMS,DBS,SS,SE,ES core
    class LFS,DB,CS storage
    class NCS,WSS,OAI,WCA external
    class WCA api
```
