Spaces:
Sleeping
Sleeping
| title: Pro Code Playground | |
| emoji: ๐ป | |
| colorFrom: indigo | |
| colorTo: blue | |
| sdk: streamlit | |
| sdk_version: 1.47.0 | |
| app_file: app.py | |
| pinned: true | |
| # ๐ป Pro Code Playground | |
| **Pro Code Playground** is an interactive, multi-language coding environment with a built-in AI assistant and live execution โ all accessible directly from your browser. | |
| Powered by Hugging Face Spaces, Streamlit, and Groqโs LLaMA 3.3โ70B, this project merges code editing, language support, AI debugging, and even narration in a single clean, responsive app. No installations. No setup. Just code, ask, listen, and learn. | |
| --- | |
| ## ๐ฅ Features | |
| - ๐ง AI-powered Code Assistant via **Groq + LangChain** | |
| - โ๏ธ Support for **Python, Java, C++, C, JavaScript, C#** | |
| - ๐ค File upload with **auto language detection** | |
| - ๐ฅ Stdin simulation for programs needing user input | |
| - ๐ **Voice narration** of assistant responses (Edge TTS) | |
| - ๐ฌ Scrollable chatbot with memory and summarization | |
| - ๐ **Dark/light theme toggle** with instant styling | |
| - ๐พ One-click code download with proper extension | |
| - ๐งช Runtime stats (execution time, memory used) | |
| --- | |
| ## ๐ Try It Live | |
| ๐ [Click here to run it](https://huggingface.co/spaces/vsj0702/Code_editor) | |
| No login or install required โ it runs right in your browser. | |
| --- | |
| # ๐ Usage Guide | |
| ### ๐ 1. Toggle Light/Dark Theme | |
| - Click the theme button (๐ or โ๏ธ) on the top-right to switch between dark and light modes. | |
| - Styling is fully dynamic and applies instantly to all components including the code editor and chat. | |
| --- | |
| ### ๐งโ๐ป 2. Select a Language | |
| - Choose from: Python, Java, C, C++, JavaScript, or C# | |
| - Language auto-switches when uploading supported files | |
| --- | |
| ### ๐ 3. Write or Upload Code | |
| - Start writing code directly in the editor | |
| - Or upload a file: `.py`, `.cpp`, `.c`, `.java`, `.js`, `.cs`, `.txt` | |
| - The editor auto-switches to the detected language | |
| --- | |
| ### ๐งช 4. Input (stdin) | |
| - Use the **Input (stdin)** text box for user inputs | |
| - Inputs are passed line-by-line to your code | |
| --- | |
| ### โถ๏ธ 5. Run the Code | |
| - Hit **โถ๏ธ Run** | |
| - Output is shown in a result panel | |
| - Errors are displayed separately in red | |
| - Runtime and memory stats appear below the result | |
| --- | |
| ### ๐ฌ 6. Ask the AI Assistant | |
| - Use the chat sidebar to ask anything about your code | |
| - The AI uses full context (code, input, output, errors, history) | |
| - Great for debugging, refactoring, or learning | |
| --- | |
| ### ๐ 7. Narrate Responses | |
| - Click "๐ Narrate" to generate a voice explanation of the AIโs answer | |
| - Plays using Edge TTS voices | |
| - You can replay the audio or skip it | |
| --- | |
| ### ๐พ 8. Download Your Code | |
| - Download the edited code anytime | |
| - File is automatically named with the correct extension | |
| --- | |
| # ๐ณ File Structure: Think of It Like a Tree | |
| Imagine your app like a growing tree. | |
| At the **trunk**, thereโs `app.py` โ the brain of your app. Everything connects to it, and it sends life (data, layout, session state) to all other components. From this trunk, other files branch out like **modules**, each handling a specific responsibility. The result? A modular, clean, powerful structure that makes debugging and extending your app a breeze. | |
| --- | |
| ### ๐ฒ `app.py` โ The Trunk of the Tree | |
| This is the **entry point** of the application โ the first file Streamlit runs. Think of it as the control center. Its responsibilities include: | |
| - Setting page layout and title | |
| - Initializing theme and session state | |
| - Dividing the screen into columns | |
| - Calling the editor module (`code_editor.py`) on the left | |
| - Calling the chatbot module (`chatbot.py`) on the right | |
| **Without this file, nothing would render.** It acts as the coordinator, delegating tasks to the appropriate submodules like a team lead. | |
| --- | |
| ### ๐ฟ `code_editor.py` โ The Code Branch | |
| This file handles everything related to writing and running code. Itโs like the **workbench** where users type, upload, and execute their programs. | |
| Key responsibilities: | |
| - Displaying the code editor using `streamlit_ace` | |
| - Handling file uploads and auto-detecting language | |
| - Taking user input (stdin) | |
| - Running code via the backend (local or OneCompiler API) | |
| - Showing output, errors, runtime, and memory stats | |
| - Offering code download with the correct extension | |
| Itโs tightly integrated with `utils.py`, which handles the actual logic for compiling and executing the code. | |
| --- | |
| ### ๐ฟ `chatbot.py` โ The Smart Brain Branch | |
| This file gives your app its **AI assistant powers**. It's responsible for: | |
| - Talking to Groq's LLaMA 3.3 model via LangChain | |
| - Generating code explanations, debugging suggestions, and summaries | |
| - Managing a memory-aware chat history | |
| - Handling narration of responses using Edge TTS | |
| - Controlling how chatbot responses are shown (Markdown + CSS) | |
| - Making sure your assistant sounds human-like, helpful, and context-aware | |
| Itโs the most dynamic and intelligent part of the app โ and beautifully modular. | |
| --- | |
| ### ๐ฟ `layout.py` โ The Skin and Styling Layer | |
| This file controls the **aesthetic** of your app. It defines: | |
| - Light and dark themes | |
| - Custom CSS injected into Streamlit | |
| - Fonts, button styles, scroll behavior, sidebar visuals | |
| - Consistent layout feel across components | |
| Whenever the user toggles dark mode, `layout.py` updates everything instantly. It makes your app look polished and consistent, like a professionally built product. | |
| --- | |
| ### ๐ฟ `utils.py` โ The Engine Room | |
| This is your appโs **execution engine**. | |
| It abstracts the messy stuff โ compiling, running, capturing outputs, handling errors โ so that the rest of the app stays clean. | |
| Responsibilities include: | |
| - Executing Python code using `exec()` with stdin override | |
| - Compiling and running C/C++ code via `gcc`/`g++` | |
| - Sending Java, JavaScript, and C# code to OneCompiler API | |
| - Gracefully falling back between API keys if one fails | |
| - Returning outputs, stderr, and exceptions for display | |
| If `code_editor.py` is the workbench, this file is the **machine under the hood**. | |
| --- | |
| ### ๐ฟ `requirements.txt` โ The DNA | |
| This file contains all the dependencies needed to run the app. | |
| From Streamlit to LangChain, Edge TTS to Groqโs SDK โ this file ensures your app has all the tools it needs to function. | |
| --- | |
| ### ๐ฑ Summary: A Living, Breathing System | |
| Every file has a job. Every module connects like a healthy tree: | |
| - `app.py` = Trunk (controls everything) | |
| - `layout.py` = Skin and theme | |
| - `code_editor.py` = Workbench for code | |
| - `utils.py` = Engine for execution | |
| - `chatbot.py` = Brain for intelligence | |
| - `requirements.txt` = Genetic blueprint | |
| This modular structure lets you: | |
| - Debug easily | |
| - Extend individual parts without breaking others | |
| - Understand how data flows | |
| - Keep your code organized and clean | |
| --- | |
| If youโre reading this to understand or contribute โ welcome aboard! The structure is made for developers like you. | |
| Feel free to explore each module and give feedback ๐ | |
| --- | |
| ## ๐ค Author | |
| **Vaibhav Shankar (vsj0702)** | |
| ๐ง Email: [vsj0702@gmail.com](mailto:vsj0702@gmail.com) | |
| ๐ LinkedIn: [vaibhavshankar](https://www.linkedin.com/in/vaibhavshankar?utm_source=share&utm_campaign=share_via&utm_content=profile&utm_medium=android_app) | |
| ๐ค Hugging Face: [@vsj0702](https://huggingface.co/vsj0702) | |
| --- | |
| ## ๐ License | |
| This project is licensed under the **GNU General Public License v3.0 (GVL-3)**. | |
| You are free to use, modify, and distribute the project under the terms of this license. | |
| --- | |
| Thanks for exploring **Pro Code Playground** ๐ป | |
| Let me know what you build with it! |