ShardingTools - A Professional Database Sharding Management and Calculation Raycast Extension
๐ Project Overview
ShardingTools is a professional Raycast extension tool specifically designed for database sharding scenarios. It provides complete sharding configuration management, real-time calculation, and SQL generation functionality, greatly improving developers' efficiency in database sharding scenarios.
โจ Features
๐๏ธ Configuration Management
- Multiple Configuration Storage: Support saving and managing multiple sharding configurations
- Configuration Editing: Modify saved configuration parameters at any time
- Configuration Deletion: Support deleting individual or all configurations
- Configuration Import/Export: Support importing and exporting configuration files for backup and sharing
๐งฎ Smart Calculation
- Sharding Calculator: Input shard factor values to automatically calculate corresponding database and table locations
- Numeric Modulo Algorithm: Use simple and intuitive modulo operations for sharding calculations
- Configuration Switching: Quickly switch between different table configurations in the calculator
๐ง Convenient Features
- Automatic Clipboard Reading: Automatically read clipboard content when entering the calculator
- SQL Statement Generation: Automatically generate corresponding query SQL statements
- One-Click Copy: Quick copy of database names, table names, SQL statements, and other information
- Enter Shortcut: Support Enter key for quick calculations
- Data Backup and Recovery: Achieve configuration backup and recovery through export/import functionality
โก Deep Raycast Integration
- Three Independent Commands: Add configuration, view list, quick calculation
- Smooth Navigation: Seamless switching between different functions
- Local Storage: All data is safely saved locally
- Shortcut Support: Rich shortcut operations to improve usage efficiency
๐ ๏ธ Installation and Usage
Prerequisites
- Raycast application
- Node.js 18+
- npm or yarn
Local Development
- Clone the project:
git clone <repository-url>
cd shardingtools
- Install dependencies:
npm install
- Start development mode:
npm run dev
- Import the local extension in Raycast using
Import Extension
Publish to Raycast Store
npm run publish
๐ Usage Instructions
๐ Quick Start
ShardingTools provides three independent commands covering the complete workflow of database sharding:
1. Add Sharding Configuration
Search for "Add Shard Config" in Raycast and fill in the following information:
- Table Name: Data table name (e.g., user_info)
- Database Name: Database name (e.g., db_user)
- Database Count: Number of databases (e.g., 4)
- Table Count: Number of tables per database (e.g., 16)
- Shard Factor: Sharding field name (e.g., user_id)
2. View Sharding Configuration List
Search for "List Shard Configs" in Raycast:
- View all saved configurations
- Edit existing configurations
- Delete unnecessary configurations
- Quick access to calculator
- Export configuration files (โโงE)
- Import configuration files (โโงI)
3. Sharding Calculator
Search for "Shard Calculator" in Raycast:
- Automatically read clipboard content as shard factor value
- Select the configuration to calculate (if multiple exist)
- Input specific shard factor value (e.g., 123456)
- Press Enter or click "Calculate Shard"
- View calculation results and generated SQL statements
4. Configuration Import/Export
Export Configuration:
- Press
โโงE
or click "Export All Configs" in the configuration list
- Configuration data will be automatically copied to clipboard (JSON format)
- Can be saved as
.json
file for backup
Import Configuration:
- Press
โโงI
or click "Import Config" in the configuration list
- Select import mode:
- Merge Mode: Add imported configurations to existing ones
- Replace Mode: Replace all existing configurations with imported ones
- Paste JSON data or press
โV
to read from clipboard
- Click "Import Config" to complete the import
๐ก Usage Tips
- Batch Calculation: Copy user ID to clipboard, open calculator for automatic filling
- SQL Generation: Copy generated query SQL directly from the calculation results page
- Multiple Configuration Management: Create different sharding configurations for different projects
- Quick Navigation: Press Enter in the list page to directly access the calculator for that configuration
- Configuration Backup: Regularly export configuration files to ensure data security
- Team Collaboration: Share configurations among team members through export/import functionality
- Environment Migration: Sync sharding configurations across different devices
โจ๏ธ Shortcuts
โโงE
- Export all configurations
โโงI
- Import configurations
โV
- Read data from clipboard (import page)
โ
- Quick calculation (calculator page)
โ
- Enter calculator (list page)
๐ฏ Implemented Features
๐ธ Feature Screenshots
Add Configuration
Configure basic parameters for database sharding, supporting table names, database names, shard counts, and other settings.

Configuration List
Manage all sharding configurations with support for editing, deletion, and quick calculation.

Sharding Calculator
Input shard factor values for real-time calculation of corresponding database and table locations, with automatic SQL statement generation.

๐งฎ Calculation Example
Assuming the following configuration:
- Table Name:
user_info
- Database Name:
db_user
- Database Count: 4
- Table Count: 8
- Shard Factor:
user_id
When inputting user_id = 123456
:
- Database Index:
123456 % 4 = 0
- Table Index:
123456 % 8 = 0
- Result Database Name:
db_user
- Result Table Name:
user_info_0
- Generated SQL:
SELECT * FROM user_info_0 WHERE user_id = 123456;
Data will be stored in the user_info_0 table of the db_user database.
๐ง Development Notes
Project Structure
shardingtools/
โโโ assets/
โ โโโ extension-icon.png # Extension icon
โโโ src/
โ โโโ addtable.tsx # Add configuration command entry
โ โโโ list.tsx # Configuration list management
โ โโโ calculator.tsx # Sharding calculator
โ โโโ shard-form.tsx # Unified form component
โ โโโ import-form.tsx # Configuration import form
โโโ package.json # Project configuration and command definitions
โโโ tsconfig.json # TypeScript configuration
โโโ eslint.config.js # ESLint configuration
โโโ README.md # Project documentation
Technology Stack
- Framework: React + TypeScript
- Platform: Raycast Extension API
- Build Tool: Raycast CLI
Available Scripts
npm run dev
- Development mode
npm run build
- Build project
npm run lint
- Code linting
npm run fix-lint
- Auto-fix code issues
๐ค Contributing
Welcome to submit Issues and Pull Requests to help improve this project.
- Fork this repository
- Create a feature branch (
git checkout -b feature/AmazingFeature
)
- Commit your changes (
git commit -m 'Add some AmazingFeature'
)
- Push to the branch (
git push origin feature/AmazingFeature
)
- Open a Pull Request
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.
๐จโ๐ป Author
- KevinWang0224 - Project Maintainer