This directory contains practical examples and use cases for the Smart Code Diff tool.
examples/
├── README.md # This file
├── cli/ # Command-line interface examples
│ ├── basic-comparison.sh # Basic file comparison
│ ├── directory-analysis.sh # Directory comparison
│ ├── batch-processing.sh # Batch file processing
│ └── ci-integration.sh # CI/CD integration
├── api/ # API integration examples
│ ├── javascript/ # Node.js examples
│ ├── python/ # Python examples
│ ├── curl/ # cURL examples
│ └── postman/ # Postman collection
├── web/ # Web interface examples
│ ├── screenshots/ # UI screenshots
│ └── workflows/ # Common workflows
├── sample-code/ # Sample code files for testing
│ ├── java/ # Java examples
│ ├── python/ # Python examples
│ ├── javascript/ # JavaScript examples
│ ├── cpp/ # C++ examples
│ └── c/ # C examples
├── configurations/ # Configuration examples
│ ├── basic-config.toml # Basic configuration
│ ├── enterprise-config.toml # Enterprise settings
│ └── ci-config.toml # CI/CD optimized
└── use-cases/ # Real-world use cases
├── code-review/ # Code review scenarios
├── refactoring/ # Refactoring analysis
├── migration/ # Code migration
└── quality-assessment/ # Code quality analysis
Compare two Java files to see structural changes:
# Navigate to examples directory
cd examples/sample-code/java
# Compare original and refactored versions
smart-diff-cli compare Calculator.java Calculator_refactored.javaUse the REST API to compare files programmatically:
# Start the server
smart-diff-server &
# Compare files via API
curl -X POST http://localhost:3000/api/compare \
-H "Content-Type: application/json" \
-d @examples/api/curl/compare-request.json- Start the web server:
smart-diff-server - Open http://localhost:3000
- Upload files from
examples/sample-code/ - Explore different visualization modes
- basic-comparison.sh: Simple file comparison
- directory-analysis.sh: Recursive directory comparison
- batch-processing.sh: Processing multiple files
- ci-integration.sh: CI/CD pipeline integration
- JavaScript/Node.js: Complete client implementation
- Python: Python integration examples
- cURL: Raw HTTP requests
- Postman: Postman collection for testing
- Code Review: Pull request analysis
- Refactoring: Large-scale refactoring analysis
- Migration: Language/framework migration
- Quality Assessment: Code quality metrics
The sample-code/ directory contains example files in different languages that demonstrate various scenarios:
Calculator.java/Calculator_refactored.java- Method extraction refactoringUserService.java/UserService_v2.java- Interface changesDataProcessor.java/DataProcessor_optimized.java- Performance optimization
math_utils.py/math_utils_enhanced.py- Function additionsdata_analyzer.py/data_analyzer_refactored.py- Class restructuringapi_client.py/api_client_v2.py- API version migration
calculator.js/calculator.es6.js- ES6 migrationuser-manager.js/user-manager-async.js- Async/await conversionutils.js/utils.modular.js- Modularization
matrix.cpp/matrix_optimized.cpp- Algorithm optimizationstring_utils.cpp/string_utils_modern.cpp- Modern C++ featuresnetwork.cpp/network_refactored.cpp- Architecture changes
linked_list.c/linked_list_improved.c- Memory management improvementsparser.c/parser_enhanced.c- Feature additionscrypto.c/crypto_secure.c- Security improvements
[parser]
max_file_size = 5242880 # 5MB
parse_timeout = 15
enable_error_recovery = true
[semantic]
max_resolution_depth = 8
enable_cross_file_analysis = false
symbol_cache_size = 500
[diff_engine]
default_similarity_threshold = 0.7
enable_refactoring_detection = true
enable_cross_file_tracking = false
max_tree_depth = 15
[output]
default_format = "text"
enable_colors = true
include_timestamps = false[parser]
max_file_size = 52428800 # 50MB
parse_timeout = 120
enable_error_recovery = true
[semantic]
max_resolution_depth = 15
enable_cross_file_analysis = true
symbol_cache_size = 5000
[diff_engine]
default_similarity_threshold = 0.6
enable_refactoring_detection = true
enable_cross_file_tracking = true
max_tree_depth = 25
[output]
default_format = "json"
enable_colors = false
include_timestamps = true
[performance]
parallel_workers = 8
memory_limit_mb = 4096
cache_size_mb = 1024- Build the Smart Code Diff tool:
cargo build --release- Ensure the binaries are in your PATH or use full paths:
export PATH=$PATH:./target/release# Run basic comparison example
./examples/cli/basic-comparison.sh
# Run directory analysis
./examples/cli/directory-analysis.sh
# Run batch processing
./examples/cli/batch-processing.sh# Start the server
smart-diff-server &
# Run JavaScript examples
cd examples/api/javascript
npm install
node basic-comparison.js
# Run Python examples
cd examples/api/python
pip install -r requirements.txt
python basic_comparison.py- Start the web server:
smart-diff-server-
Follow the workflows in
examples/web/workflows/
We welcome contributions of new examples! Please follow these guidelines:
- Create clear, focused examples that demonstrate specific features
- Include documentation explaining the example's purpose
- Provide sample data when needed
- Test examples before submitting
- Follow naming conventions used in existing examples
When creating new examples, use this template:
#!/bin/bash
# Example: [Brief Description]
# Purpose: [Detailed explanation of what this example demonstrates]
# Usage: ./example-name.sh
set -e
echo "Smart Code Diff Example: [Example Name]"
echo "======================================="
# Setup
echo "Setting up example..."
# Setup code here
# Main example
echo "Running analysis..."
# Main example code here
# Results
echo "Results:"
# Display or process results
echo "Example completed successfully!"If you encounter issues running examples:
- Check prerequisites: Ensure all tools are installed and in PATH
- Verify file paths: Make sure sample files exist
- Check permissions: Ensure scripts are executable
- Review logs: Check output for error messages
- Update examples: Pull latest changes from repository
- User Guide - Comprehensive usage documentation
- API Documentation - REST API reference
- Developer Guide - Development and contribution guide
- Configuration Reference - Detailed configuration options
For questions or issues with examples, please:
- Check existing GitHub Issues
- Create a new issue with the "examples" label
- Join our GitHub Discussions for community support