Overview
SplitBox is a single-page, browser-only application with no backend, router, or state management library. All processing happens client-side, and no data ever leaves the browser.Project Structure
Component Architecture
Main Components
SplitBox.tsx - The primary component containing:- Input textarea for pasting lists
- Control panel for split configuration
- Summary statistics display
- Batch results grid
- Theme toggle
- Batch label and item count
- Expandable/collapsible item preview
- Copy to clipboard action
- Download with template-aware extensions (
.txt,.sql,.csv,.json)
Component Patterns
- No external state library: Uses React’s built-in state management
- Single-page design: All functionality in one cohesive interface
- Responsive grid layout: Batches displayed in a responsive grid
- Minimal component nesting: Flat component hierarchy for simplicity
Web Worker Usage
SplitBox leverages Web Workers to maintain UI responsiveness when processing large datasets.Worker Implementation
The split worker (src/workers/splitWorker.ts) runs computationally intensive operations off the main thread:
Worker Workflow
- Main thread sends split request to worker
- Worker calls
prepareItems()to parse and preprocess input - Worker calls
splitPreparedItems()to generate batches - Worker posts results back to main thread
- UI updates with batch results
Core Logic Modules
Splitter (utils/splitter.ts)
Pure functions for parsing and splitting:
parseItems()- Tokenizes raw input by delimiterprepareItems()- Parses, validates, deduplicates input with statisticssplitPreparedItems()- Creates batches based on split modesplitItems()- Convenience wrapper for basic splitting
Split Modes
items_per_group- Fixed number of items per batchtarget_group_count- Distribute items across N batches evenlymax_chars_per_group- Pack batches by character length budget
Output Utilities
output.ts- Template formatting (plain, SQL IN, quoted CSV, JSON array)clipboard.ts- Browser clipboard API integrationdownload.ts- Client-side file downloadexportZip.ts- ZIP generation for bulk export with manifest
Design System
Theme System
SplitBox uses a CSS variable-based theming system:- Theme storage:
localStoragekeysplitbox-theme - Theme attribute:
data-themeon<html>element - Color system: CSS custom properties (
--bg-primary,--text-primary, etc.) - Modes: Dark and light with distinct accent colors
- Dark accent:
#D4A853 - Light accent:
#B8922D
- Dark accent:
Typography
- Display: Bodoni Moda
- Body: Hanken Grotesk
- Monospace: Fira Code
Styling Approach
- Tailwind utility classes for layout, spacing, and structure
- CSS variables (from
index.css) for colors and fonts via inlinestylewhen dynamic - No hardcoded hex colors in components
- Custom animations defined in
index.cssapplied via utility classes
Path Alias
The project uses a path alias for cleaner imports:vite.config.ts:
Data Types
SplitGroup
Core data structure for batch results:Configuration Types
SplitMode-'items_per_group' | 'max_chars_per_group' | 'target_group_count'InputDelimiter-'newline' | 'comma' | 'tab' | 'auto'ValidationMode-'none' | 'alphanumeric' | 'email' | 'custom_regex'DedupeMode-'none' | 'case_sensitive' | 'case_insensitive'
Privacy & Security
- No external API calls: All processing happens locally
- No data collection: No analytics or tracking
- No server communication: Fully client-side application
- Browser-only storage: Theme preference in
localStorageonly