Skip to content

FulgerX2007/clickhouse-schemaflow-visualizer

Repository files navigation

ClickHouse Schema Flow Visualizer

Logo

A powerful open-source web application for visualizing ClickHouse table relationships using Mermaid.js diagrams. Browse databases and tables with an intuitive interface, explore table metadata with optional row counts and size information, and export interactive schema diagrams.

Build Status License: MIT GitHub release Go Report Card

πŸ“Έ Screenshots

Main window

Table relationships

Table relationships

✨ Features

  • πŸ” Browse ClickHouse databases and tables with an intuitive interface
  • πŸ“Š Visualize table relationships with Mermaid.js diagrams
  • 🎨 Color-coded icons matching table types for better visualization
  • ↔️ View direction of data flow between tables
  • πŸ“‚ Collapsible table types legend for a cleaner interface
  • πŸ“ˆ Toggle metadata visibility (table rows and size information)
  • πŸ’Ύ Export diagrams as standalone HTML files
  • πŸ”’ Secure connection to ClickHouse with TLS support
  • πŸ“± Responsive web interface for all devices

πŸ—οΈ Architecture

  • Backend: Golang with Gin framework
  • Frontend: HTML, CSS, and JavaScript with Mermaid.js
  • Database: ClickHouse

πŸ“‹ Prerequisites

  • Docker and Docker Compose
  • ClickHouse server

πŸš€ Installation and Setup

Using GitHub Container Registry

  1. Pull the container from GitHub Container Registry:

    docker pull ghcr.io/fulgerx2007/clickhouse-schemaflow-visualizer:latest
  2. Create a .env file with your ClickHouse connection details (see configuration example below)

  3. Run the container:

    docker run -p 8080:8080 --env-file .env ghcr.io/fulgerx2007/clickhouse-schemaflow-visualizer:latest
  4. Access the web interface at http://localhost:8080

Using Docker Compose (Recommended)

  1. Clone the repository:

    git clone https://github.com/fulgerX2007/clickhouse-schemaflow-visualizer.git
    cd clickhouse-schemaflow-visualizer
  2. Start the application:

    docker-compose up -d
  3. Access the web interface at http://localhost:8080

Manual Setup

  1. Clone the repository:

    git clone https://github.com/fulgerX2007/clickhouse-schemaflow-visualizer.git
    cd clickhouse-schemaflow-visualizer
  2. Configure the .env file with your ClickHouse connection details:

    # ClickHouse Connection Settings
    CLICKHOUSE_HOST=localhost
    CLICKHOUSE_PORT=9000
    CLICKHOUSE_USER=default
    CLICKHOUSE_PASSWORD=
    CLICKHOUSE_DATABASE=default
    
    # ClickHouse TLS Settings
    CLICKHOUSE_SECURE=false
    CLICKHOUSE_SKIP_VERIFY=false
    # CLICKHOUSE_CERT_PATH=/path/to/cert.pem
    # CLICKHOUSE_KEY_PATH=/path/to/key.pem
    # CLICKHOUSE_CA_PATH=/path/to/ca.pem
    # CLICKHOUSE_SERVER_NAME=clickhouse.example.com
    
    # Web Interface Settings
    SERVER_ADDR=:8080
    GIN_MODE=debug
    
  3. Install Go dependencies:

    cd backend
    go mod download
  4. Run the application:

    go run main.go
  5. Access the web interface at http://localhost:8080

πŸ“– Usage

1. Browse Databases and Tables

  • The left panel displays all available databases and tables
  • Click on a database to expand/collapse its tables
  • Click on a table to view its schema

2. Toggle Table Metadata

  • Use the "Show Metadata" toggle switch below the Table Types section
  • When enabled, displays table statistics (row count and size) under each table name
  • Metadata is hidden by default for a cleaner interface
  • Your preference is automatically saved and restored

3. View Table Relationships

  • Select a table to see its relationships with other tables
  • The diagram shows the table structure and relationships

4. Export Diagrams

  • Click "Export HTML" to save the current diagram as an HTML file

πŸ”§ How It Works

The application analyzes ClickHouse table structures by querying system tables:

  • system.tables to get tables in each database and determine their types

Relationships between tables are determined based on column names:

  • Direction of data flow is determined automatically for:
    • distributed tables
    • materialized views
    • replicated tables
    • regular tables
    • dictionaries

πŸ‘¨β€πŸ’» Development

Project Structure

clickhouse-schemaflow-visualizer/
β”œβ”€β”€ api/             # API handlers
β”‚   └── handlers.go  # API endpoint implementations
β”œβ”€β”€ assets/          # Project assets
β”‚   └── screenshots/ # Screenshots for documentation
β”œβ”€β”€ config/          # Configuration handling
β”‚   └── config.go    # Environment configuration loader
β”œβ”€β”€ models/          # Data models and ClickHouse client
β”‚   └── clickhouse.go # ClickHouse connection and schema handling
β”œβ”€β”€ static/          # Frontend static files
β”‚   β”œβ”€β”€ css/         # CSS styles
β”‚   β”‚   └── styles.css # Main stylesheet
β”‚   β”œβ”€β”€ html/        # HTML templates
β”‚   β”‚   └── index.html # Main application page
β”‚   β”œβ”€β”€ img/         # Images and icons
β”‚   └── js/          # JavaScript code
β”‚       └── app.js   # Main application logic
β”œβ”€β”€ .env.example     # Example environment configuration
β”œβ”€β”€ docker-compose.yml # Docker Compose configuration
β”œβ”€β”€ Dockerfile       # Docker build instructions
β”œβ”€β”€ go.mod           # Go module dependencies
β”œβ”€β”€ go.sum           # Go module checksums
β”œβ”€β”€ main.go          # Application entry point
└── README.md        # Documentation

Building from Source

  1. Build the Docker image:

    docker build -t clickhouse-schemaflow-visualizer .
  2. Run the container:

    docker run -p 8080:8080 --env-file .env clickhouse-schemaflow-visualizer

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

🀝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors