# naras/knowledgetree architecture

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

- Interactive diagram: https://gitdiagram.com/naras/knowledgetree
- Repository: https://github.com/naras/knowledgetree

## Overview

- Frontend Web UI: Indicate the “knowledgetreeJSModules” directory, especially the “webUITree” subdirectory. This includes login.htm, various HTML pages (index.html, person_work.html, subject_work.html), and JavaScript files (D3-context-menu, dndTree, etc.). These files are responsible for rendering and permitting interactive editing of the tree visualization.
- RESTful Backend Service: Highlight the “knowledgeTreeRestService” directory and its key modules:
– knowledgeTreeJsonRestService.py: the main REST API implementation.
– knowledgeTreeModel.py & knowledgeTreeModelSmall.py: these likely represent data models to interact with the database.
– Configuration/YAML files (credentials_roles.yaml, database__url.yaml, db_credentials.yaml, localdb.yaml, root_node_names.yaml) for different environment variables and settings.
– DBModelGen.bat: used for database model generation.
– Automated Test: tstKnowledgeTreeRestService.py for service testing.
- Database: Although not a directory within “src”, the presence of KnowledgeTree.sql and the MySQL Workbench file (KnowledgeTree.mwb) indicate a dedicated database layer. This is where the knowledge tree data is stored and queried.
- Supporting Documentation: Elements like the KnowledgeTreeOverview.pptx and KnowledgeTreeProjectProposal.docx provide background and proposals on system design but also can help verify design intentions.

##### Relationships and Data Flows
- Optionally, include a label for configuration management and testing as supporting components within the backend service.

##### Architectural Patterns and Design Principles
- RESTful Architecture: Emphasize that the backend exposes an API that the frontend consumes.
- Separation of Concerns: Show a clear boundary between UI (client-side rendering, interactivity via D3JS) and web service logic (Python-based REST service, database management).
- Data Modeling: Indicate that the system is designed around a tree data structure (inverted tree) with a clear model separation (knowledgeTreeModel, etc.).

##### Technologies and Frameworks
- Programming Languages: Python for the backend, JavaScript and HTML/CSS for the frontend.
- Visualization: D3JS (evidenced by filenames such as d3-context-menu.js and D3JS Tree Editor.md) is used for dynamic tree rendering.
- Configuration Management: YAML files are used to define credentials, URLs, and other runtime configurations.
- Database: SQL file and MySQL Workbench file suggest a relational database is used to store the knowledge tree.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Frontend Layer"
        FE["Frontend UI (JS Modules/WebUI)"]:::frontend
    end

    %% Backend Layer
    subgraph "Backend Layer"
        BE["Backend REST Service"]:::backend
        API["knowledgeTreeJsonRestService.py"]:::backend
        DM1["knowledgeTreeModel.py"]:::backend
        DM2["knowledgeTreeModelSmall.py"]:::backend
        CFG["Configuration Files (YAML)"]:::backend
        GEN["DBModelGen.bat"]:::backend
        TEST["tstKnowledgeTreeRestService.py"]:::backend
    end

    %% Database Layer
    subgraph "Database"
        DB1["SQL Schema (KnowledgeTree.sql)"]:::database
        DB2["MySQL Workbench (KnowledgeTree.mwb)"]:::database
    end

    %% Documentation
    subgraph "Documentation"
        DOC1["KnowledgeTreeOverview.pptx"]:::documentation
        DOC2["KnowledgeTreeProjectProposal.docx"]:::documentation
    end

    %% Data Flows
    FE -->|"JSONRequest"| BE
    BE -->|"DBQuery"| DB1
    BE -->|"DBQuery"| DB2

    %% Internal Backend Structure
    BE -->|"contains"| API
    BE -->|"contains"| DM1
    BE -->|"contains"| DM2
    BE -->|"contains"| CFG
    BE -->|"contains"| GEN
    BE -->|"contains"| TEST

    %% Click Events
    click FE "https://github.com/naras/knowledgetree/tree/master/knowledgetreeJSModules/webUITree"
    click BE "https://github.com/naras/knowledgetree/tree/master/knowledgeTreeRestService"
    click API "https://github.com/naras/knowledgetree/blob/master/knowledgeTreeRestService/knowledgeTreeJsonRestService.py"
    click DM1 "https://github.com/naras/knowledgetree/blob/master/knowledgeTreeRestService/knowledgeTreeModel.py"
    click DM2 "https://github.com/naras/knowledgetree/blob/master/knowledgeTreeRestService/knowledgeTreeModelSmall.py"
    click CFG "https://github.com/naras/knowledgetree/blob/master/knowledgeTreeRestService/credentials_roles.yaml"
    click GEN "https://github.com/naras/knowledgetree/blob/master/knowledgeTreeRestService/DBModelGen.bat"
    click TEST "https://github.com/naras/knowledgetree/blob/master/knowledgeTreeRestService/tstKnowledgeTreeRestService.py"
    click DB1 "https://github.com/naras/knowledgetree/blob/master/KnowledgeTree.sql"
    click DB2 "https://github.com/naras/knowledgetree/blob/master/KnowledgeTree.mwb"
    click DOC1 "https://github.com/naras/knowledgetree/blob/master/KnowledgeTreeOverview.pptx"
    click DOC2 "https://github.com/naras/knowledgetree/blob/master/KnowledgeTreeProjectProposal.docx"

    %% Styles
    classDef frontend fill:#CDEBFF,stroke:#333,stroke-width:2px;
    classDef backend fill:#d4f3e3,stroke:#333,stroke-width:2px;
    classDef database fill:#FFE6A7,stroke:#333,stroke-width:2px;
    classDef documentation fill:#EAD1DC,stroke:#333,stroke-width:2px;
```
