|
| 1 | +# React/Electron Migration Documentation |
| 2 | + |
| 3 | +## Overview |
| 4 | + |
| 5 | +This document describes the migration of the Islamic Text Copier (ITC) from Python/macOS to a modern React/Electron stack for cross-platform support. |
| 6 | + |
| 7 | +## Migration Benefits |
| 8 | + |
| 9 | +### Before (Python/macOS) |
| 10 | +- **Issues:** |
| 11 | + - Dependency conflicts (pyinstaller version issues with Python 3.12) |
| 12 | + - macOS-only builds with py2app |
| 13 | + - Complex setup with tkinter/customtkinter |
| 14 | + - Platform-specific build issues |
| 15 | + |
| 16 | +### After (React/Electron) |
| 17 | +- **Benefits:** |
| 18 | + - Cross-platform builds (macOS, Windows, Linux) |
| 19 | + - Modern web technologies (React, CSS, JavaScript) |
| 20 | + - Better packaging with electron-builder |
| 21 | + - Easier dependency management with npm |
| 22 | + - More robust development environment |
| 23 | + |
| 24 | +## Architecture |
| 25 | + |
| 26 | +### File Structure |
| 27 | +``` |
| 28 | +src/ |
| 29 | +├── main.js # Electron main process |
| 30 | +├── index.js # React entry point |
| 31 | +├── components/ |
| 32 | +│ ├── App.js # Main React component |
| 33 | +│ ├── App.css # Styling |
| 34 | +│ └── PhraseButton.js # Individual phrase button component |
| 35 | +└── data/ |
| 36 | + └── phrases.js # Arabic phrases data |
| 37 | +
|
| 38 | +dist/ # Built React application |
| 39 | +public/ # Static assets |
| 40 | +resources/ # Original resources (icons, documentation) |
| 41 | +``` |
| 42 | + |
| 43 | +### Technology Stack |
| 44 | +- **Frontend:** React 19.1.1 |
| 45 | +- **Desktop Framework:** Electron 38.1.0 |
| 46 | +- **Build System:** Webpack 5.101.3 |
| 47 | +- **Package Manager:** npm |
| 48 | +- **Build Tool:** electron-builder |
| 49 | + |
| 50 | +## Feature Parity |
| 51 | + |
| 52 | +All original Python features have been migrated: |
| 53 | + |
| 54 | +1. **Arabic Phrases Grid** - ✅ Implemented with React components |
| 55 | +2. **Clipboard Functionality** - ✅ Using modern Clipboard API |
| 56 | +3. **Hover Meanings** - ✅ React state management |
| 57 | +4. **Update Checking** - ✅ Fetch API for version checking |
| 58 | +5. **Documentation Button** - ✅ Electron shell integration |
| 59 | +6. **Credits/Website Button** - ✅ External link handling |
| 60 | +7. **Styling** - ✅ CSS matching original design (#1b1c27 theme) |
| 61 | + |
| 62 | +## Build Instructions |
| 63 | + |
| 64 | +### Development |
| 65 | +```bash |
| 66 | +# Install dependencies |
| 67 | +npm install |
| 68 | + |
| 69 | +# Development build and run |
| 70 | +npm run dev |
| 71 | + |
| 72 | +# Production build and run |
| 73 | +npm start |
| 74 | +``` |
| 75 | + |
| 76 | +### Distribution |
| 77 | +```bash |
| 78 | +# Build for all platforms |
| 79 | +npm run dist |
| 80 | + |
| 81 | +# Platform-specific builds |
| 82 | +npm run dist-mac # macOS DMG |
| 83 | +npm run dist-win # Windows NSIS installer |
| 84 | +npm run dist-linux # Linux AppImage |
| 85 | +``` |
| 86 | + |
| 87 | +### Build Outputs |
| 88 | +- **macOS:** DMG file with app bundle |
| 89 | +- **Windows:** NSIS installer executable |
| 90 | +- **Linux:** AppImage portable executable |
| 91 | + |
| 92 | +## Migration Process |
| 93 | + |
| 94 | +### 1. Analysis Phase ✅ |
| 95 | +- Analyzed Python codebase structure |
| 96 | +- Identified core functionality and dependencies |
| 97 | +- Documented build issues |
| 98 | + |
| 99 | +### 2. Setup Phase ✅ |
| 100 | +- Initialized npm project |
| 101 | +- Installed React and Electron dependencies |
| 102 | +- Created project structure |
| 103 | + |
| 104 | +### 3. Implementation Phase ✅ |
| 105 | +- Migrated Arabic phrases data |
| 106 | +- Implemented React UI components |
| 107 | +- Added clipboard functionality |
| 108 | +- Replicated original styling |
| 109 | +- Integrated Electron for desktop features |
| 110 | + |
| 111 | +### 4. Build Configuration ✅ |
| 112 | +- Configured webpack for React bundling |
| 113 | +- Set up electron-builder for packaging |
| 114 | +- Added cross-platform build scripts |
| 115 | + |
| 116 | +## Key Code Changes |
| 117 | + |
| 118 | +### Arabic Phrases Data |
| 119 | +```javascript |
| 120 | +// Extracted from Python list to JavaScript array |
| 121 | +export const arabicPhrases = [ |
| 122 | + { phrase: 'ﷺ', meaning: "Sallá Allāhu ʿAlayhī wa as-Salam..." }, |
| 123 | + // ... 16 total phrases |
| 124 | +]; |
| 125 | +``` |
| 126 | + |
| 127 | +### Clipboard Functionality |
| 128 | +```javascript |
| 129 | +// Modern Clipboard API instead of pyperclip |
| 130 | +const copyToClipboard = async (phrase) => { |
| 131 | + await navigator.clipboard.writeText(phrase); |
| 132 | + setStatusMessage(`${phrase} copied to clipboard`); |
| 133 | +}; |
| 134 | +``` |
| 135 | + |
| 136 | +### Cross-Platform Integration |
| 137 | +```javascript |
| 138 | +// Electron shell for external links and file opening |
| 139 | +const { shell } = window.require('electron'); |
| 140 | +shell.openExternal('https://github.com/itextc/itc-osx'); |
| 141 | +``` |
| 142 | + |
| 143 | +## Testing |
| 144 | + |
| 145 | +The application has been tested for: |
| 146 | +- ✅ Build process completion |
| 147 | +- ✅ React component rendering |
| 148 | +- ✅ Webpack bundling |
| 149 | +- ✅ Electron packaging configuration |
| 150 | +- ⚠️ Runtime testing (limited in headless environment) |
| 151 | + |
| 152 | +## Future Improvements |
| 153 | + |
| 154 | +1. **Auto-updater:** Implement Electron auto-updater |
| 155 | +2. **Themes:** Add light/dark theme support |
| 156 | +3. **Customization:** Allow users to add custom phrases |
| 157 | +4. **Localization:** Support multiple languages |
| 158 | +5. **Performance:** Optimize bundle size |
| 159 | + |
| 160 | +## Conclusion |
| 161 | + |
| 162 | +The migration successfully modernizes the Islamic Text Copier while maintaining all original functionality. The new React/Electron stack provides better cross-platform support, easier maintenance, and a more robust development environment. |
0 commit comments