Skip to content

Commit d181d27

Browse files
Fixing bug and update scrollbar and readme file
2 parents 792ef4d + 90f75ad commit d181d27

File tree

13 files changed

+340
-104
lines changed

13 files changed

+340
-104
lines changed

README.md

Lines changed: 231 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,239 @@
11
# Tech_Compiler
22
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.
35

4-
# React + Vite
6+
# Code Editor Compiler
57

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.
79

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.`
911

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
1213

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.
1419

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

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"lint": "eslint .",
1010
"preview": "vite preview"
1111
},
12+
"types": "module",
1213
"dependencies": {
1314
"@monaco-editor/react": "^4.7.0",
1415
"axios": "^1.9.0",

src/App.css

Lines changed: 0 additions & 42 deletions
This file was deleted.

src/App.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import CompilerLandingPage from "./components/CompilerLandingPage";
1+
import CompilerLandingPage from "./pages/CompilerLandingPage";
22

33
function App() {
44
return (
Lines changed: 30 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,47 @@
11
// src/components/CodeEditorWindow.jsx
22
import Editor from "@monaco-editor/react";
3-
import { CODE_SNIPPETS } from "./constant"; // Correct path to constant.js
3+
import { CODE_SNIPPETS } from "../utils/constant"; // Correct path to constant.js
44

5-
const CodeEditorWindow = ({ onChange, language, code, onMount, className = "", style = {} }) => {
6-
return (
5+
const CodeEditorWindow = ({
6+
onChange,
7+
language,
8+
code,
9+
onMount,
10+
className = "",
11+
style = {},
12+
activeFileId,
13+
// openFiles,
14+
}) => {
15+
return activeFileId ? (
716
<div className={`h-full ${className}`} style={style}>
817
<Editor
9-
height="100%" // Editor takes full height of its parent div
18+
height="100%"
1019
language={language || "javascript"}
1120
onMount={onMount}
1221
value={code}
13-
theme="vs-dark" // VS Code's dark theme
22+
theme="vs-dark"
1423
options={{
15-
minimap: { enabled: true }, // Show the minimap (code overview)
16-
fontSize: 14, // Set a comfortable default font size
17-
scrollBeyondLastLine: false, // Don't allow scrolling past the last line
18-
wordWrap: "on", // Wrap long lines
19-
showUnused: true, // Highlight unused variables/imports
20-
// More options for a "wow" feel:
21-
cursorBlinking: "smooth", // Smooth cursor animation
22-
cursorSmoothCaretAnimation: "on", // Animated smooth caret movement
23-
renderLineHighlight: "all", // Highlight the whole line, not just the content
24-
lineNumbersMinChars: 3, // Minimum width for line numbers
25-
fontFamily: "Fira Code, Consolas, 'Courier New', monospace", // Use a popular coding font (install Fira Code for best results)
26-
fontLigatures: true, // Enable font ligatures if the font supports them
27-
'bracketPairColorization.enabled': true, // Colorize matching brackets
28-
'guides.bracketPairs': 'active', // Show guides for bracket pairs
24+
minimap: { enabled: true },
25+
fontSize: 14,
26+
scrollBeyondLastLine: false,
27+
wordWrap: "on",
28+
showUnused: true,
29+
cursorBlinking: "smooth",
30+
cursorSmoothCaretAnimation: "on",
31+
renderLineHighlight: "all",
32+
lineNumbersMinChars: 3,
33+
fontFamily: "Fira Code, Consolas, 'Courier New', monospace",
34+
fontLigatures: true,
35+
"bracketPairColorization.enabled": true,
36+
"guides.bracketPairs": "active",
2937
}}
3038
defaultValue={CODE_SNIPPETS[language]}
3139
onChange={(val) => onChange(val)}
3240
/>
3341
</div>
42+
) : (
43+
<p>Select or create a file to start editing</p>
3444
);
3545
};
3646

37-
export default CodeEditorWindow;
47+
export default CodeEditorWindow;

0 commit comments

Comments
 (0)