# liblor/knovleks architecture

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

- Interactive diagram: https://gitdiagram.com/liblor/knovleks
- Repository: https://github.com/liblor/knovleks

## Overview

##### Main Components Identification

The system should be represented with these key components:

a) Core Engine Layer:
- Main Knovleks engine (knovleks.py)
- Document Type Interface (idocument_type.py)

b) Document Handlers Layer:
- Document Handler
- PDF Document Handler
- Website Document Handler

c) User Interface Layer:
- CLI Interface
- Terminal User Interface (TUI)

d) Storage Layer:
- Document Index Storage
- Document Metadata Storage

##### Component Relationships

- User Interface → Core Engine (command flow)
- Core Engine → Document Handlers (document processing)
- Document Handlers → Storage (indexing)
- Storage → Core Engine (search results)

##### Detailed Component Descriptions

Core Engine:

- Knovleks Core     |

- Document Indexing    |
- Search Processing    |
- Tag Management      |

Document Handlers:

- Document Handlers    |

- Note Handler         |
- PDF Handler         |
- Website Handler     |

##### Implementation Details

- IDocumentType interface implementation by each document handler
- CLI commands (index, search, tag-filter) as entry points
- TUI as an alternative interface
- Storage interaction for indexed documents

##### The centralized storage and indexing mechanism

Remember to maintain clarity while showing the extensibility of the system through the document type interface, which allows for easy addition of new document types.

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles
    classDef core fill:#b3d1ff,stroke:#333
    classDef interface fill:#e6ccff,stroke:#333
    classDef handler fill:#90EE90,stroke:#333
    classDef ui fill:#ffeb99,stroke:#333
    classDef storage fill:#e6e6e6,stroke:#333

    %% User Interface Layer
    subgraph UI
        CLI["CLI Interface"]:::ui
        TUI["Terminal UI"]:::ui
    end

    %% Core Layer
    subgraph Core
        Engine["Knovleks Core Engine"]:::core
        IDocType["Document Type Interface"]:::interface
    end

    %% Document Handlers Layer
    subgraph Handlers
        NoteHandler["Note Document Handler"]:::handler
        PDFHandler["PDF Document Handler"]:::handler
        WebHandler["Website Document Handler"]:::handler
    end

    %% Storage Layer
    subgraph Storage
        DocIndex[(Document Index)]:::storage
        MetaStore[(Metadata Storage)]:::storage
    end

    %% Relationships
    CLI --> Engine
    TUI --> Engine
    Engine --> IDocType
    IDocType --> NoteHandler
    IDocType --> PDFHandler
    IDocType --> WebHandler
    NoteHandler --> DocIndex
    PDFHandler --> DocIndex
    WebHandler --> DocIndex
    NoteHandler --> MetaStore
    PDFHandler --> MetaStore
    WebHandler --> MetaStore
    DocIndex --> Engine
    MetaStore --> Engine

    %% Click Events
    click Engine "https://github.com/Liblor/knovleks/blob/master/knovleks/knovleks.py"
    click IDocType "https://github.com/Liblor/knovleks/blob/master/knovleks/idocument_type.py"
    click CLI "https://github.com/Liblor/knovleks/blob/master/knovleks/__main__.py"
    click TUI "https://github.com/Liblor/knovleks/blob/master/knovleks/tui.py"
    click NoteHandler "https://github.com/Liblor/knovleks/blob/master/knovleks/document_types/note_document.py"
    click PDFHandler "https://github.com/Liblor/knovleks/blob/master/knovleks/document_types/pdf_document.py"
    click WebHandler "https://github.com/Liblor/knovleks/blob/master/knovleks/document_types/website_document.py"
    click Handlers "https://github.com/Liblor/knovleks/tree/master/knovleks/document_types/"

    %% Legend
    subgraph Legend
        L1["Core Components"]:::core
        L2["Interfaces"]:::interface
        L3["Document Handlers"]:::handler
        L4["User Interfaces"]:::ui
        L5["Storage"]:::storage
    end
```
