|
| 1 | +# Smart Code Diff - Advanced Web UI |
| 2 | + |
| 3 | +A state-of-the-art web interface for the Smart Code Diff engine, providing comprehensive code analysis, comparison, and visualization capabilities. |
| 4 | + |
| 5 | +## 🚀 Features |
| 6 | + |
| 7 | +### 📁 File Explorer & Parser |
| 8 | +- **Drag & Drop Support**: Drop files or entire directories directly into the interface |
| 9 | +- **Multi-format Support**: Supports 25+ programming languages including C/C++, JavaScript, Python, Java, Rust, Go, and more |
| 10 | +- **Real-time Parsing**: Parse files instantly with progress tracking and detailed results |
| 11 | +- **Project Structure Visualization**: Interactive file tree with language detection and file size information |
| 12 | +- **Function Extraction**: Automatically extract and display functions, classes, and complexity metrics |
| 13 | + |
| 14 | +### ⚖️ Visual Code Comparison |
| 15 | +- **Side-by-side Comparison**: Compare two files with advanced diff visualization |
| 16 | +- **Similarity Scoring**: Get detailed similarity metrics (overall, structure, content, semantic) |
| 17 | +- **Change Detection**: Identify additions, modifications, deletions, and moves |
| 18 | +- **Configurable Options**: Adjust similarity thresholds, ignore whitespace, detect moves |
| 19 | +- **Real-time Results**: Instant comparison with execution time tracking |
| 20 | + |
| 21 | +### 📊 Advanced Code Analysis |
| 22 | +- **Multi-file Analysis**: Analyze entire codebases with cross-file detection |
| 23 | +- **Duplicate Detection**: Find duplicate functions across files with similarity scoring |
| 24 | +- **Complexity Metrics**: Calculate and visualize code complexity distributions |
| 25 | +- **Dependency Analysis**: Track dependencies and relationships between files |
| 26 | +- **Quality Insights**: Get actionable insights about code quality and maintainability |
| 27 | + |
| 28 | +### ⚙️ Configuration Management |
| 29 | +- **Parser Settings**: Configure file size limits, timeouts, and error recovery |
| 30 | +- **Semantic Analysis**: Adjust resolution depth, cache size, and cross-file analysis |
| 31 | +- **Diff Engine**: Fine-tune similarity thresholds, tree depth, and detection algorithms |
| 32 | +- **Persistent Settings**: Save and restore configuration preferences |
| 33 | + |
| 34 | +## 🎨 Modern Design |
| 35 | + |
| 36 | +### User Experience |
| 37 | +- **Responsive Design**: Works seamlessly on desktop, tablet, and mobile devices |
| 38 | +- **Dark Mode Support**: Automatic dark mode based on system preferences |
| 39 | +- **Accessibility**: Full keyboard navigation and screen reader support |
| 40 | +- **Performance**: Optimized for large codebases with efficient rendering |
| 41 | + |
| 42 | +### Visual Elements |
| 43 | +- **Modern Typography**: Inter font family for readability and JetBrains Mono for code |
| 44 | +- **Intuitive Icons**: Language-specific icons and visual indicators |
| 45 | +- **Smooth Animations**: Subtle transitions and loading states |
| 46 | +- **Color-coded Results**: Visual feedback for similarity scores and change types |
| 47 | + |
| 48 | +## 🛠️ Technical Architecture |
| 49 | + |
| 50 | +### Frontend Stack |
| 51 | +- **Vanilla JavaScript**: No framework dependencies for maximum performance |
| 52 | +- **Modern CSS**: CSS Grid, Flexbox, and CSS Custom Properties |
| 53 | +- **Progressive Enhancement**: Works without JavaScript for basic functionality |
| 54 | +- **Web Standards**: Uses modern web APIs for file handling and drag & drop |
| 55 | + |
| 56 | +### API Integration |
| 57 | +- **RESTful API**: Clean integration with the Smart Code Diff backend |
| 58 | +- **Real-time Updates**: Live progress tracking and status updates |
| 59 | +- **Error Handling**: Comprehensive error handling with user-friendly messages |
| 60 | +- **Caching**: Intelligent caching of parsed results and configuration |
| 61 | + |
| 62 | +## 🚀 Getting Started |
| 63 | + |
| 64 | +### Prerequisites |
| 65 | +- Smart Code Diff server running on `http://localhost:3000` |
| 66 | +- Modern web browser (Chrome 90+, Firefox 88+, Safari 14+, Edge 90+) |
| 67 | + |
| 68 | +### Quick Start |
| 69 | +1. **Start the Server**: |
| 70 | + ```bash |
| 71 | + cargo run --release --bin smart-diff-server |
| 72 | + ``` |
| 73 | + |
| 74 | +2. **Open the Web UI**: |
| 75 | + Navigate to `http://localhost:3000` in your browser |
| 76 | + |
| 77 | +3. **Upload Files**: |
| 78 | + - Drag and drop files or directories into the upload zone |
| 79 | + - Or click "Select Directory" / "Select Files" to browse |
| 80 | + |
| 81 | +4. **Parse and Analyze**: |
| 82 | + - Click "Parse All Files" to extract functions and metadata |
| 83 | + - View results in the interactive file tree and results grid |
| 84 | + |
| 85 | +5. **Compare Files**: |
| 86 | + - Switch to the "Compare" tab |
| 87 | + - Select source and target files from parsed results |
| 88 | + - Configure comparison options and click "Compare Files" |
| 89 | + |
| 90 | +6. **Run Analysis**: |
| 91 | + - Switch to the "Analysis" tab |
| 92 | + - Enable desired analysis options |
| 93 | + - Click "Run Analysis" for comprehensive insights |
| 94 | + |
| 95 | +## 📋 API Endpoints |
| 96 | + |
| 97 | +The web UI integrates with the following API endpoints: |
| 98 | + |
| 99 | +### Health Check |
| 100 | +``` |
| 101 | +GET /api/health |
| 102 | +``` |
| 103 | +Returns system status and component health information. |
| 104 | + |
| 105 | +### File Comparison |
| 106 | +``` |
| 107 | +POST /api/compare |
| 108 | +``` |
| 109 | +Compare two files with detailed similarity analysis. |
| 110 | + |
| 111 | +### Multi-file Analysis |
| 112 | +``` |
| 113 | +POST /api/analyze |
| 114 | +``` |
| 115 | +Analyze multiple files with cross-file detection and metrics. |
| 116 | + |
| 117 | +### Configuration |
| 118 | +``` |
| 119 | +POST /api/configure |
| 120 | +``` |
| 121 | +Update system configuration settings. |
| 122 | + |
| 123 | +## 🎯 Use Cases |
| 124 | + |
| 125 | +### Code Review |
| 126 | +- Compare different versions of files to understand changes |
| 127 | +- Identify potential issues and improvements |
| 128 | +- Track code quality metrics over time |
| 129 | + |
| 130 | +### Refactoring Analysis |
| 131 | +- Detect duplicate code across the codebase |
| 132 | +- Identify opportunities for code consolidation |
| 133 | +- Measure complexity before and after refactoring |
| 134 | + |
| 135 | +### Migration Planning |
| 136 | +- Analyze legacy codebases for migration planning |
| 137 | +- Understand code structure and dependencies |
| 138 | +- Estimate migration effort and complexity |
| 139 | + |
| 140 | +### Quality Assurance |
| 141 | +- Monitor code quality metrics across projects |
| 142 | +- Identify files with high complexity or duplication |
| 143 | +- Track improvements over time |
| 144 | + |
| 145 | +## 🔧 Configuration Options |
| 146 | + |
| 147 | +### Parser Configuration |
| 148 | +- **Max File Size**: Maximum file size to parse (default: 1MB) |
| 149 | +- **Parse Timeout**: Timeout for parsing operations (default: 30s) |
| 150 | +- **Error Recovery**: Enable error recovery during parsing |
| 151 | + |
| 152 | +### Semantic Analysis |
| 153 | +- **Resolution Depth**: Maximum depth for symbol resolution (default: 10) |
| 154 | +- **Cross-file Analysis**: Enable analysis across multiple files |
| 155 | +- **Symbol Cache Size**: Cache size for symbol table (default: 1000) |
| 156 | + |
| 157 | +### Diff Engine |
| 158 | +- **Similarity Threshold**: Default threshold for similarity detection (default: 0.8) |
| 159 | +- **Refactoring Detection**: Enable detection of refactoring patterns |
| 160 | +- **Cross-file Tracking**: Track changes across multiple files |
| 161 | +- **Tree Depth**: Maximum depth for AST analysis (default: 100) |
| 162 | + |
| 163 | +## 🐛 Troubleshooting |
| 164 | + |
| 165 | +### Common Issues |
| 166 | + |
| 167 | +**Files not uploading**: |
| 168 | +- Check file size limits in configuration |
| 169 | +- Ensure files have supported extensions |
| 170 | +- Verify browser supports File API |
| 171 | + |
| 172 | +**Parsing failures**: |
| 173 | +- Check server logs for detailed error messages |
| 174 | +- Verify file encoding (UTF-8 recommended) |
| 175 | +- Try smaller files to isolate issues |
| 176 | + |
| 177 | +**Slow performance**: |
| 178 | +- Reduce file count or size |
| 179 | +- Adjust parser timeout settings |
| 180 | +- Check system resources |
| 181 | + |
| 182 | +### Browser Compatibility |
| 183 | +- **Chrome 90+**: Full support |
| 184 | +- **Firefox 88+**: Full support |
| 185 | +- **Safari 14+**: Full support (some drag & drop limitations) |
| 186 | +- **Edge 90+**: Full support |
| 187 | + |
| 188 | +## 📈 Performance Tips |
| 189 | + |
| 190 | +1. **File Organization**: Organize files in logical directory structures |
| 191 | +2. **Batch Processing**: Parse related files together for better cross-file analysis |
| 192 | +3. **Configuration Tuning**: Adjust settings based on your codebase size and complexity |
| 193 | +4. **Browser Resources**: Close unnecessary tabs and applications for better performance |
| 194 | + |
| 195 | +## 🤝 Contributing |
| 196 | + |
| 197 | +The web UI is designed to be extensible and maintainable: |
| 198 | + |
| 199 | +- **Modular Architecture**: Each feature is self-contained |
| 200 | +- **Clean Code**: Well-documented and commented |
| 201 | +- **Responsive Design**: Mobile-first approach |
| 202 | +- **Accessibility**: WCAG 2.1 AA compliant |
| 203 | + |
| 204 | +## 📄 License |
| 205 | + |
| 206 | +This web UI is part of the Smart Code Diff project and follows the same licensing terms. |
0 commit comments