|
1 | 1 | # Tech_Compiler |
2 | 2 | Code editor created for community . |
| 3 | +## Project Overview |
| 4 | +This project is an advanced Code Editor and Compiler platform designed specifically for students to write, compile, and run code in multiple programming languages—all within a single, unified web application. It provides a seamless and interactive experience, empowering learners to experiment and practice coding in an efficient environment. |
3 | 5 |
|
4 | | -# React + Vite |
| 6 | +# Code Editor Compiler |
5 | 7 |
|
6 | | -This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules. |
| 8 | +A comprehensive web-based code editor and compiler that supports multiple programming languages in a single platform. This project provides students and developers with an integrated development environment (IDE) for writing, editing, and executing code across various programming languages. |
7 | 9 |
|
8 | | -Currently, two official plugins are available: |
| 10 | +The platform is built using modern web technologies including **React**, **Vite**, and **Tailwind CSS** to ensure a fast, responsive, and visually appealing user interface. It leverages an external compilation API service (requiring an API key) to compile and execute code securely in the cloud.` |
9 | 11 |
|
10 | | -- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md) uses [Babel](https://babeljs.io/) for Fast Refresh |
11 | | -- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh |
| 12 | +## 🚀 Features |
12 | 13 |
|
13 | | -## Expanding the ESLint configuration |
| 14 | +- **Multi-language Support**: Supports 40+ programming languages including: |
| 15 | + - JavaScript, TypeScript, Python, Java, C/C++ |
| 16 | + - Go, Rust, Swift, Kotlin, Ruby, PHP |
| 17 | + - Assembly, Bash, Haskell, Scala, SQL, and many more |
| 18 | + - Compile and run code from a wide range of programming languages. |
14 | 19 |
|
15 | | -If you are developing a production application, we recommend using TypeScript and enable type-aware lint rules. Check out the [TS template](https://github.com/vitejs/vite/tree/main/packages/create-vite/template-react-ts) to integrate TypeScript and [`typescript-eslint`](https://typescript-eslint.io) in your project. |
| 20 | +- **Monaco Editor Integration**: Professional code editing experience with: |
| 21 | + - Syntax highlighting |
| 22 | + - Auto-completion |
| 23 | + - Error detection |
| 24 | + - Dark theme interface |
| 25 | + - Minimap navigation |
| 26 | + - User-friendly, syntax-highlighted editor to write and edit code. |
| 27 | + |
| 28 | +- **Real-time Code Execution**: Execute code directly in the browser with: |
| 29 | + - Live output display |
| 30 | + - Error handling and display |
| 31 | + - Execution status tracking |
| 32 | + - Base64 encoding for secure transmission |
| 33 | + |
| 34 | +- **Responsive Design**: Modern, dark-themed UI built with Tailwind CSS |
| 35 | +- **Keyboard Shortcuts**: Ctrl+Enter to run code quickly |
| 36 | +- **Resizable Panels**: Adjustable editor and output panel sizes |
| 37 | +- **Language Switching**: Easy language selection with version information |
| 38 | +- **Code Snippets**: Access to a library of code snippets for common tasks |
| 39 | +- **Cloud Compilation:** Code is sent to a secure API to compile and run, handling backend complexities. |
| 40 | +- **Fast and Responsive UI:** Built using React with Vite and styled using Tailwind CSS for modern, responsive design. |
| 41 | +- **API Key Based Access:** Secure access to the compilation API with a user-provided API key. |
| 42 | + |
| 43 | + |
| 44 | +## 🛠️ Technologies Used |
| 45 | + |
| 46 | +- **Frontend Framework**: React 19.1.0 |
| 47 | +- **Build Tool**: Vite 6.3.5 |
| 48 | +- **Styling**: Tailwind CSS 3.4.17 |
| 49 | +- **Code Editor**: Monaco Editor (@monaco-editor/react) |
| 50 | +- **HTTP Client**: Axios 1.9.0 |
| 51 | +- **Code Execution API**: Judge0 CE via RapidAPI |
| 52 | +- **Language**: JavaScript/JSX |
| 53 | +- **Package Manager**: npm |
| 54 | + |
| 55 | + |
| 56 | +## Prerequisites |
| 57 | +- Node.js (version 14 or above) |
| 58 | +- npm or yarn package manager |
| 59 | +- API key for the code compilation service (you must register on the API provider's platform to obtain this) |
| 60 | + |
| 61 | + |
| 62 | +## 📦 Installation |
| 63 | + |
| 64 | +1. **Clone the repository** |
| 65 | + ```bash |
| 66 | + git clone <repository-url> |
| 67 | + cd tech_compiler |
| 68 | + ``` |
| 69 | + |
| 70 | +2. **Install dependencies** |
| 71 | + ```bash |
| 72 | + npm install |
| 73 | + ``` |
| 74 | + |
| 75 | +3. **Configure API Key** |
| 76 | + - Sign up for RapidAPI and subscribe to Judge0 CE |
| 77 | + - Replace the API key in `src/components/api.js`: |
| 78 | + ```javascript |
| 79 | + "X-RapidAPI-Key": "YOUR_API_KEY_HERE" |
| 80 | + ``` |
| 81 | + |
| 82 | +4. **Start the development server** |
| 83 | + ```bash |
| 84 | + npm run dev |
| 85 | + ``` |
| 86 | + |
| 87 | +5. **Open your browser** |
| 88 | + - Navigate to `http://localhost:5173` |
| 89 | + |
| 90 | +## 🏗️ Project Structure |
| 91 | + |
| 92 | +``` |
| 93 | +code-editor/ |
| 94 | +├── public/ |
| 95 | +├── src/ |
| 96 | +│ ├── components/ |
| 97 | +│ │ ├── CompilerLandingPage.jsx # Main editor component |
| 98 | +│ │ ├── CodeEditorWindow.jsx # Monaco editor wrapper |
| 99 | +│ │ ├── LanguageSelector.jsx # Language dropdown |
| 100 | +│ │ ├── Output.jsx # Output display component |
| 101 | +│ │ ├── api.js # API integration |
| 102 | +│ │ └── constant.js # Language configurations |
| 103 | +│ ├── hooks/ |
| 104 | +│ │ └── keyPress.js # Custom hook for keyboard shortcuts |
| 105 | +│ ├── App.jsx # Root component |
| 106 | +│ ├── main.jsx # Entry point |
| 107 | +│ └── index.css # Global styles |
| 108 | +├── package.json |
| 109 | +├── vite.config.js |
| 110 | +└── README.md |
| 111 | +``` |
| 112 | + |
| 113 | +## 🔧 Available Scripts |
| 114 | + |
| 115 | +- `npm run dev` - Start development server |
| 116 | +- `npm run build` - Build for production |
| 117 | +- `npm run preview` - Preview production build |
| 118 | +- `npm run lint` - Run ESLint for code quality |
| 119 | + |
| 120 | +## 🌐 API Integration |
| 121 | + |
| 122 | +This project uses **Judge0 CE API** through RapidAPI for code execution: |
| 123 | + |
| 124 | +- **Submission Endpoint**: Creates code execution jobs |
| 125 | +- **Status Endpoint**: Checks execution status and retrieves results |
| 126 | +- **Base64 Encoding**: Ensures secure code transmission |
| 127 | +- **Polling Mechanism**: Handles asynchronous execution |
| 128 | + |
| 129 | +### Supported Language IDs |
| 130 | +- JavaScript (Node.js): 63 |
| 131 | +- Python 3: 71 |
| 132 | +- Java (OpenJDK): 62 |
| 133 | +- C++ (GCC): 54 |
| 134 | +- C (GCC): 50 |
| 135 | +- And 35+ more languages... |
| 136 | + |
| 137 | +## 💡 Usage |
| 138 | + |
| 139 | +1. **Select Language**: Choose from the dropdown menu (40+ languages available) |
| 140 | +2. **Write Code**: Use the Monaco editor with syntax highlighting |
| 141 | +3. **Execute Code**: Click "Run Code" or press Ctrl+Enter |
| 142 | +4. **View Output**: Results appear in the bottom panel |
| 143 | +5. **Resize Panels**: Drag the divider to adjust editor/output sizes |
| 144 | +6. **Handle Errors**: Error messages are displayed with red highlighting |
| 145 | + |
| 146 | +## 🎯 Key Components |
| 147 | + |
| 148 | +### CompilerLandingPage.jsx |
| 149 | +- Main container component |
| 150 | +- Manages editor state and execution |
| 151 | +- Handles resizing functionality |
| 152 | +- Integrates all sub-components |
| 153 | + |
| 154 | +### CodeEditorWindow.jsx |
| 155 | +- Monaco editor wrapper |
| 156 | +- Provides syntax highlighting |
| 157 | +- Manages editor configuration |
| 158 | +- Handles code snippets |
| 159 | + |
| 160 | +### LanguageSelector.jsx |
| 161 | +- Dropdown for language selection |
| 162 | +- Displays language versions |
| 163 | +- Updates editor configuration |
| 164 | + |
| 165 | +### Output.jsx |
| 166 | +- Displays execution results |
| 167 | +- Handles error formatting |
| 168 | +- Provides output scrolling |
| 169 | +- Toggle visibility |
| 170 | + |
| 171 | +### api.js |
| 172 | +- Judge0 CE API integration |
| 173 | +- Handles code submission |
| 174 | +- Manages execution polling |
| 175 | +- Error handling |
| 176 | + |
| 177 | +## 🚀 Deployment |
| 178 | + |
| 179 | +### Build for Production |
| 180 | +```bash |
| 181 | +npm run build |
| 182 | +``` |
| 183 | + |
| 184 | +### Deploy to Vercel/Netlify |
| 185 | +1. Connect your GitHub repository |
| 186 | +2. Set build command: `npm run build` |
| 187 | +3. Set publish directory: `dist` |
| 188 | +4. Deploy automatically |
| 189 | + |
| 190 | +## 🔐 Environment Variables |
| 191 | + |
| 192 | +For production deployment, consider using environment variables for the API key: |
| 193 | + |
| 194 | +```javascript |
| 195 | +const API_KEY = import.meta.env.VITE_RAPIDAPI_KEY || "your-fallback-key"; |
| 196 | +``` |
| 197 | + |
| 198 | +## 🤝 Contributing |
| 199 | + |
| 200 | +1. Fork the repository |
| 201 | +2. Create a feature branch (`git checkout -b feature/AmazingFeature`) |
| 202 | +3. Commit your changes (`git commit -m 'Add some AmazingFeature'`) |
| 203 | +4. Push to the branch (`git push origin feature/AmazingFeature`) |
| 204 | +5. Open a Pull Request |
| 205 | + |
| 206 | +## 📝 Future Enhancements |
| 207 | + |
| 208 | +- [ ] File upload/download functionality |
| 209 | +- [ ] User authentication and code saving |
| 210 | +- [ ] Collaborative editing features |
| 211 | +- [ ] Additional language support |
| 212 | +- [ ] Custom themes and fonts |
| 213 | +- [ ] Code sharing functionality |
| 214 | +- [ ] Performance optimizations |
| 215 | +- [ ] Mobile responsiveness improvements |
| 216 | + |
| 217 | +## 🐛 Known Issues |
| 218 | + |
| 219 | +- API rate limiting may occur with frequent requests |
| 220 | +- Some languages may have longer execution times |
| 221 | +- Large output may affect performance |
| 222 | + |
| 223 | +## 📄 License |
| 224 | + |
| 225 | +This project is licensed under the MIT License - see the LICENSE file for details. |
| 226 | + |
| 227 | +## 👨💻 Author |
| 228 | + |
| 229 | +**[ VISHAL & SHAILENDRA ]** |
| 230 | +- GitHub: [Vishal](https://github.com/@vishal6268),[Shailendra Singh Panwar](https://github.com/Shailendrasingh189) |
| 231 | + |
| 232 | +- LinkedIn: [Vishal Choudhary](https://www.linkedin.com/in/vishal-choudhary-1690202b7),[shailendrasingh189](https://www.linkedin.com/in/shailendrasingh189). |
| 233 | + |
| 234 | +## 🙏 Acknowledgments |
| 235 | + |
| 236 | +- Judge0 CE for providing the code execution API |
| 237 | +- Monaco Editor team for the excellent code editor |
| 238 | +- React and Vite communities for the amazing tools |
| 239 | +- Tailwind CSS for the utility-first CSS framework |
0 commit comments