# d4software/querytree architecture

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

- Interactive diagram: https://gitdiagram.com/d4software/querytree
- Repository: https://github.com/d4software/querytree

## Overview

The system architecture should be represented in multiple layers, with the following components and relationships:

##### Core Components

a. Web Application Layer (ASP.NET Core)
- Controllers (Authentication, Query Management, Team Management)
- Views (MVC pattern)
- Services (Email, Password Management)
- Models (Database entities)

b. Query Engine Layer
- Query Processing Nodes (Various node types for different operations)
- Data Source Management
- Query Execution Pipeline

c. Data Storage
- Application Database (User data, reports, configurations)
- Target Databases (External databases being queried)

##### Key Relationships to Highlight

**[Client Browser] ←→ [Web Application Layer]**
- ↓
**[Authentication] ←→ [Query Builder Interface]**
- ↓
**[Query Engine] ←→ [Node Processing Pipeline]**
- ↓
**[Database Connectors] ←→ [Target Databases]**

##### Detailed Component Breakdown

a. Query Engine Components (Show as a pipeline):
- DataSourceNode
- FilterNode
- JoinNode
- SelectNode
- SummarizeNode
- AppendNode
- GraphNode

b. Security Layer:
- SSH Tunneling
- Password Encryption
- Custom Password Managers

c. Integration Points:
- Email Service
- Schedule Management
- Team Collaboration

##### Important Elements

- Separation between the web interface and the query engine
- Security layers (SSH tunneling, encryption)
- Demonstrate the flow from user input to query execution
- Reporting pipeline stages
- Scheduled task management

##### Technical Details to Note

- Built on .NET 6.0
- Uses MVC architecture
- Supports multiple database types (MySQL, PostgreSQL, MS SQL)
- Implements custom password management
- Includes email integration
- Features team collaboration tools

For the specific implementation, I recommend using a combination of:

This will provide a complete picture of both the system's structure and its behavioral aspects.

Remember to include notes about scalability considerations, such as the load balancing capability mentioned in the README, and the ability to share encryption keys across multiple web servers.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client
        Browser["`Client Browser`"]:::ui
    end

    subgraph WebApp["`Web App Layer`"]
        Controllers["`Controllers`"]:::core
        Views["`Views`"]:::ui
        Services["`Services`"]:::core
        ViewModels["`View Models`"]:::core
        Program["`Program`"]:::core
    end

    subgraph QueryEngine["`Query Engine`"]
        direction TB
        DataSourceNode["`Data Source`"]:::engine
        FilterNode["`Filter`"]:::engine
        JoinNode["`Join`"]:::engine
        SelectNode["`Select`"]:::engine
        SummarizeNode["`Summarize`"]:::engine
        AppendNode["`Append`"]:::engine
        GraphNode["`Graph`"]:::engine
    end

    subgraph Security["`Security Stuff`"]
        PasswordManager["`Password Manager`"]:::security
        SSHProxy["`SSH Proxy`"]:::security
        SSHKeyFile["`SSH Key File`"]:::security
    end

    Browser -.-> Controllers
    Controllers ~~~ QueryEngine
    QueryEngine -..-> DataStorage
    Security ~~~~ DataStorage

    %% Wobbly connections
    DataSourceNode -.- FilterNode
    FilterNode ~~~ JoinNode
    JoinNode -.-> SelectNode
    SelectNode -.- SummarizeNode
    SummarizeNode ~~~ AppendNode
    AppendNode -.-> GraphNode

    %% Click events preserved from original
    click Controllers "https://github.com/d4software/QueryTree/tree/master/Web/Controllers/"
    click Views "https://github.com/d4software/QueryTree/tree/master/Web/Views/"
    click ViewModels "https://github.com/d4software/QueryTree/tree/master/Web/ViewModels/"
    click Program "https://github.com/d4software/QueryTree/blob/master/Web/Program.cs"
    click DataSourceNode "https://github.com/d4software/QueryTree/blob/master/Engine/DataSourceNode.cs"
    click FilterNode "https://github.com/d4software/QueryTree/blob/master/Engine/FilterNode.cs"
    click JoinNode "https://github.com/d4software/QueryTree/blob/master/Engine/JoinNode.cs"
    click SelectNode "https://github.com/d4software/QueryTree/blob/master/Engine/SelectNode.cs"
    click SummarizeNode "https://github.com/d4software/QueryTree/blob/master/Engine/SummarizeNode.cs"
    click AppendNode "https://github.com/d4software/QueryTree/blob/master/Engine/AppendNode.cs"
    click GraphNode "https://github.com/d4software/QueryTree/blob/master/Engine/GraphNode.cs"
    click PasswordManager "https://github.com/d4software/QueryTree/blob/master/Web/Managers/PasswordManager.cs"
    click SSHProxy "https://github.com/d4software/QueryTree/blob/master/Web/Managers/SSHProxy.cs"
    click SSHKeyFile "https://github.com/d4software/QueryTree/blob/master/Web/Controllers/SshKeyFileController.cs"

    %% Crayon-like styling
    classDef ui fill:#ff7eb9,stroke-width:3px,stroke:#000
    classDef core fill:#90ee90,stroke-width:4px,stroke:#000
    classDef engine fill:#87ceeb,stroke-width:3px,stroke:#000
    classDef security fill:#ffd700,stroke-width:4px,stroke:#000
    classDef default stroke-width:3px,stroke:#000
```
