# gc-victor/query architecture

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

- Interactive diagram: https://gitdiagram.com/gc-victor/query
- Repository: https://github.com/gc-victor/query

## Overview

##### Core Components
- CLI Interface (crates/cli)
- Runtime Environment (crates/runtime)
- Server Component (crates/server)
- JSX Parser (crates/jsx_parser)

##### Main Features Layer
- Database Management (SQLite)
- Asset Management
- Caching System
- Function Execution
- Plugin System

##### Top Level (Client Interaction)
- Client applications/browsers connecting to Query
- CLI interface as an entry point

##### Middle Layer (Core Processing)
- It to the Runtime Environment
- JSX Parser integration

##### Bottom Layer (Storage & Services)
- SQLite database storage
- Asset storage system
- Caching mechanism

Key Elements to Include:

##### Request Flow
- Both API and page rendering paths

##### Component Interactions
- How the runtime environment interfaces with SQLite
- Caching mechanisms
- Demonstrate asset handling flow

##### Subsystems
- Function execution environment
- Plugin system architecture
- Asset management pipeline
- Authentication/Authorization flow

Special Considerations:

##### Unique aspects
- Single-file deployment capability
- Integrated caching system
- Built-in admin interface generation
- Use distinct visual elements for these features

##### Specific flows
- Development workflow
- Deployment process
- Asset optimization pipeline
- Database operations

- Connection Types (lines)
- Flow Direction Indicators

Remember to include:
- Version control integration points
- Security boundaries
- Scaling capabilities
- Error handling flows

This will create a comprehensive yet understandable representation of Query's architecture that accurately reflects its unique position as an all-in-one web development solution.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Styles
    classDef client fill:#2196F3,stroke:#1565C0,color:white
    classDef core fill:#4CAF50,stroke:#2E7D32,color:white
    classDef storage fill:#FF9800,stroke:#EF6C00,color:white
    classDef security fill:#F44336,stroke:#C62828,color:white
    classDef process fill:#9C27B0,stroke:#6A1B9A,color:white

    %% Client Layer
    subgraph ClientLayer
        Browser["Web Browser"]:::client
        CLI["CLI Interface"]:::client
        DevTools["Development Tools"]:::client
    end

    %% Core Processing Layer
    subgraph CoreLayer
        Server["Server Component"]:::core
        Runtime["Runtime Environment"]:::core
        JSXParser["JSX Parser"]:::core
        FuncExec["Function Execution"]:::process
        PluginSys["Plugin System"]:::process
    end

    %% Storage Layer
    subgraph StorageLayer
        DB[(SQLite Database)]:::storage
        AssetStore["Asset Management"]:::storage
        Cache["Caching System"]:::storage
    end

    %% Security Layer
    subgraph SecurityLayer
        Auth["Authentication"]:::security
        TokenMgmt["Token Management"]:::security
        DBMigration["Database Migrations"]:::security
    end

    %% Connections
    Browser --> Server
    CLI --> Server
    DevTools --> Server
    
    Server --> Runtime
    Server --> JSXParser
    Server --> FuncExec
    Server --> PluginSys
    
    Runtime --> DB
    Server --> AssetStore
    Server --> Cache
    
    Server --> Auth
    Auth --> TokenMgmt
    Runtime --> DBMigration
    DBMigration --> DB

    %% Click Events
    click CLI "https://github.com/gc-victor/query/tree/main/crates/cli/"
    click Runtime "https://github.com/gc-victor/query/tree/main/crates/runtime/"
    click Server "https://github.com/gc-victor/query/tree/main/crates/server/"
    click JSXParser "https://github.com/gc-victor/query/tree/main/crates/jsx_parser/"
    click DB "https://github.com/gc-victor/query/tree/main/crates/runtime/src/sqlite/"
    click AssetStore "https://github.com/gc-victor/query/blob/main/crates/server/src/controllers/asset.rs"
    click Cache "https://github.com/gc-victor/query/blob/main/crates/server/src/controllers/cache.rs"
    click FuncExec "https://github.com/gc-victor/query/blob/main/crates/server/src/controllers/function.rs"
    click PluginSys "https://github.com/gc-victor/query/blob/main/crates/server/src/controllers/plugin_builder.rs"
    click DBMigration "https://github.com/gc-victor/query/blob/main/crates/server/src/controllers/migration.rs"
    click Auth "https://github.com/gc-victor/query/blob/main/crates/server/src/controllers/user.rs"
    click TokenMgmt "https://github.com/gc-victor/query/blob/main/crates/server/src/controllers/token.rs"

    %% Legend
    subgraph Legend
        Client["Client Components"]:::client
        CoreComp["Core Components"]:::core
        StorageComp["Storage Components"]:::storage
        SecurityComp["Security Components"]:::security
        ProcessComp["Process Components"]:::process
    end
```
