LLMShark is a Terminal User Interface (TUI) application designed to streamline your PostgreSQL database interactions, particularly when working with Large Language Models (LLMs). It allows you to explore your database structure, add/edit comments, and export schema information in Markdown format, all from your terminal.
Sharing the data model and explaining column relationships can be tedious and time-consuming. LLMShark was born out of this pain, providing a way to quickly generate a Markdown representation of your database schema, ready to be used in your LLM prompts.
This project is heavily inspired by LLMCat and LLMDog :)
llmshark_v2.mp4
Raw:
# Database Schema Documentation
Generated: 2025-02-22 17:25:19
## Schema: `shop`
### Table: `orders`
#### Columns
| Name | Type | Constraints | Description |
|------|------|-------------|-------------|
| `id` | `integer` | PRIMARY KEY, NOT NULL, orders_pkey | - |
| `user_id` | `integer` | NOT NULL | - |
| `total_amount` | `numeric(10,2)` | NOT NULL | Total amount of an order in the webshop |
| `status` | `character varying(50)` | NOT NULL, DEFAULT 'pending'::character varying | - |
| `created_at` | `timestamp without time zone` | DEFAULT CURRENT_TIMESTAMP | - |
### Table: `products`
Product catalog
#### Columns
| Name | Type | Constraints | Description |
|------|------|-------------|-------------|
| `id` | `integer` | PRIMARY KEY, NOT NULL, products_pkey | - |
| `name` | `character varying(200)` | NOT NULL | - |
| `description` | `text` | - | - |
| `price` | `numeric(10,2)` | NOT NULL | Product price in USD |
| `stock` | `integer` | NOT NULL, DEFAULT 0 | - |
## Schema: `test`
### Table: `categories`
#### Columns
| Name | Type | Constraints | Description |
|------|------|-------------|-------------|
| `id` | `integer` | PRIMARY KEY, NOT NULL, categories_pkey | - |
| `name` | `character varying(100)` | UNIQUE, NOT NULL, categories_name_key | name of categories test |
| `description` | `text` | - | - |
### Table: `users`
User account information
#### Columns
| Name | Type | Constraints | Description |
|------|------|-------------|-------------|
| `username` | `character varying(50)` | UNIQUE, NOT NULL, users_username_key | - |
| `email` | `character varying(255)` | NOT NULL | User's primary email address |
| `created_at` | `timestamp without time zone` | DEFAULT CURRENT_TIMESTAMP | - |
Rendered:
Generated: 2025-02-22 17:25:19
| Name | Type | Constraints | Description |
|---|---|---|---|
id |
integer |
PRIMARY KEY, NOT NULL, orders_pkey | - |
user_id |
integer |
NOT NULL | - |
total_amount |
numeric(10,2) |
NOT NULL | Total amount of an order in the webshop |
status |
character varying(50) |
NOT NULL, DEFAULT 'pending'::character varying | - |
created_at |
timestamp without time zone |
DEFAULT CURRENT_TIMESTAMP | - |
Product catalog
| Name | Type | Constraints | Description |
|---|---|---|---|
id |
integer |
PRIMARY KEY, NOT NULL, products_pkey | - |
name |
character varying(200) |
NOT NULL | - |
description |
text |
- | - |
price |
numeric(10,2) |
NOT NULL | Product price in USD |
stock |
integer |
NOT NULL, DEFAULT 0 | - |
| Name | Type | Constraints | Description |
|---|---|---|---|
id |
integer |
PRIMARY KEY, NOT NULL, categories_pkey | - |
name |
character varying(100) |
UNIQUE, NOT NULL, categories_name_key | name of categories test |
description |
text |
- | - |
User account information
| Name | Type | Constraints | Description |
|---|---|---|---|
username |
character varying(50) |
UNIQUE, NOT NULL, users_username_key | - |
email |
character varying(255) |
NOT NULL | User's primary email address |
created_at |
timestamp without time zone |
DEFAULT CURRENT_TIMESTAMP | - |
- π³ Tree-based database schema explorer
- π¬ Add and edit comments on tables and columns
- π Markdown export capability for LLM prompting
- π Secure credential management
- π¨ User-friendly terminal interface
- Database credentials are encrypted using AES-GCM
- Encryption keys are stored separately from credentials
- Credentials are saved in your home directory (
~/.llmshark) - File permissions are set to 600 (user read/write only)
- Clone the repository:
git clone https://github.com/kerem-kaynak/llmshark.git- Navigate to the project directory:
cd llmshark- Run the installation script:
make installThe script will automatically:
- Build the LLMShark binary
- Install it to your Go binary directory
- Add the Go binary directory to your PATH
go install github.com/kerem-kaynak/llmshark@latestSimply run:
llmsharkOn first run, you'll be prompted for your PostgreSQL connection details:
- Host
- Port
- Database name
- Username
- Password
These credentials will be securely stored for future use.
β/βorj/k: Navigate itemsβ/βorl/h: Expand/collapse itemsSpace: Select/deselect itemsc: Add/edit comment on selected itemm: Copy schema as markdownd: Deselect all itemse: Edit connection detailsq: Quit
LLMShark simplifies the process of prompting LLMs about your database:
- Explore your schema: Use LLMShark to navigate your database structure.
- Add descriptions: Add helpful descriptions to tables and columns using the
ckey. These descriptions will be included in the Markdown output. - Select relevant parts: Use the
Spacekey to select the schemas, tables, and columns relevant to your prompt. - Export to Markdown: Press
mto copy the selected schema information to your clipboard in Markdown format. - Paste into your LLM prompt: Paste the Markdown output into your LLM prompt to provide context about your database.
This workflow allows you to quickly and accurately provide LLMs with the information they need to understand your database and generate effective queries or insights.
LLMShark stores its configuration in ~/.llmshark/:
credentials.enc: Encrypted database credentialscredentials.enc.key: Encryption key
LLMShark uses AES-GCM encryption to secure your database credentials:
- On first run, a random 32-byte key is generated
- Credentials are encrypted using AES-GCM with this key
- Encrypted credentials are stored in
~/.llmshark/credentials.enc - The encryption key is stored separately in
~/.llmshark/credentials.enc.key - Both files are created with 600 permissions (user read/write only)
To reset credentials:
- Delete the files in
~/.llmshark/ - Run
llmsharkagain
- Go 1.21 or higher
- PostgreSQL 12 or higher
make buildThis project is licensed under the MIT License.
Contributions are welcome! Please fork the repository, create a new branch for your feature or bug fix, and submit a pull request.