Skip to content

apon133/CodeDroid

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

153 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

CodeDroid โ€” Mobile Code Execution Engine for Android & iOS

Rust Leptos Axum WASM Tauri Flutter

Android iOS Termux Web Git License: GPL v3

GitHub Stars GitHub Forks GitHub Issues Last Commit PRs Welcome

Free, open-source mobile IDE and code execution engine โ€” write, compile, run, and debug Python, Rust, Go, JavaScript, Java, C++, and 13+ languages directly on your Android or iOS device. No laptop needed, running with bare-metal performance.

Live Demo Termux Setup GitHub Setup Contributing Discord Telegram YouTube


๐Ÿ“– Table of Contents

  1. What is CodeDroid?
  2. Application Preview
  3. Key Capabilities & Features
  4. Ecosystem & Architectural Blueprints
  5. Native Wrapper Applications (Tauri & Flutter)
  6. Supported Languages & Setup Directory
  7. Smart Code Suggestions & AI Rule Engine
  8. Termux Android Installation Details
  9. Cross-Device & iOS Network Connectivity
  10. LSP Binary Executable Path Resolution
  11. Upcoming Features & Roadmap
  12. Contributing
  13. License

CodeDroid is a high-performance mobile programming environment that compiles and runs your code directly on-device with zero virtualization. It is built as three integrated modules:

  1. codedroid_api (Backend Engine): A lightweight, multi-threaded server written in Rust (Axum). It directly invokes system compilers (rustc, gcc, kotlinc, javac, etc.), manages asynchronous execution streams, coordinates multiple concurrent Language Server Protocol (LSP) instances, and handles local dependency installation.
  2. codedroid_frontend (Web IDE): A reactive, mobile-first IDE built using the Leptos web framework and compiled to WebAssembly (WASM). It runs entirely inside any web browser (Safari, Chrome, Firefox) and utilizes high-performance code-rendering pipelines to provide syntax highlighting, bracket matching, file drawers, autocomplete drop-downs, and compiler error overlays.
  3. apps (Native Wrappers): Cross-platform native wrappers bundling the WebAssembly frontend. Includes Tauri for desktop platforms (macOS, Windows, Linux) and Flutter for mobile platforms (Android) running a lightweight, local web server background task to bypass browser WebAssembly restrictions.

Unlike typical cloud-based sandboxes or emulated JS runtimes, CodeDroid exposes the real filesystem and real binaries of your host device (like a Termux Android shell or local macOS/Linux installation).


๐Ÿ“ฑ Application Preview

Create a New Project Add Dependencies
Create Project Add Dependency
Auto Completion & Suggestions Error Diagnostics Hover Documentation
Code Suggestion Error Suggestion Code Documentation
In-File Search Global Project Search
In-File Search Global Search

โœจ Key Capabilities & Features

  • Mobile-First Touch Architecture: Designed specifically for small touchscreens (320pxโ€“768px). Features a slide-out file explorer overlay drawer, auto-collapsing sidebar upon opening files, persistent touch targets for closing tabs, and custom layout controls utilizing CSS 100dvh to prevent keyboard resize clipping.
  • Universal Drag-to-Resize Layout: Dynamically adjust sidebars, bottom terminal consoles, and active editor split panes using intuitive touch-and-drag handle borders. Panel dimensions are persistently saved to LocalStorage for continuity across sessions.
  • Interactive Web Terminal: Run shell commands directly using a fully connected terminal console (backed by real system PTY shells) with raw stream capturing, exit code detection, and custom termination controls.
  • Integrated Git Console: Stage or unstage workspace changes, view line-by-line colored diff overlays directly inside the editor, generate commit messages with AI suggestions, clone repositories, and push/pull updates directly from the IDE sidebar. See the GitHub Setup Guide for credentials configuration.
  • Live Reload Development Server: Spin up a local static server inside any project directory that monitors folder modifications and dynamically injects hot-reloading scripts, bypassing manual browser refresh cycles.
  • Rich Media & Document Viewers: Native tab views to render images, video playback, and audio files directly, alongside a side-by-side Markdown layout editor and previewer.
  • LSP-powered IntelliSense: Floating completion panels, in-line diagnostics, hover tooltips, definition lookups, and references. Automatically hides bloated metadata subpanels on narrow screens to prevent viewport clipping.
  • Save-Triggered Synchronization: Supports immediate file-writing to the host disk on save, triggering automatic LSP change notifications (textDocument/didChange & textDocument/didSave) which instantly update error diagnostics.
  • Modern Web Framework Scaffolding: Bootstrap web apps with optimized templates for React (Vite), Vue (Vite), Svelte (Vite), Next.js (App Router), Remix, Angular, and Blank templates.
  • Live Web Preview & Cross-Device Refresh: Automatically scans development server stdout logs (e.g. Vite, Next.js) for local addresses, launches an in-IDE browser viewport with manual/auto reload, and translates local loops (127.0.0.1) into LAN IPs so iOS and tablet clients can access previews.
  • Advanced File Manager: Create, copy, paste, delete, move, or rename files and directories. Full recursive operations synchronized instantly to local disk and LocalStorage states.
  • Persistent Editor State: Restores open file tabs, split views, active cursor position, and panel visibility structures when reloading.
  • Offline Fallback Mode: Works entirely offline with local-first file caching. If the LSP is unavailable, CodeDroid falls back to an internal regex token parser to provide syntax-matching autocomplete suggestions.

๐Ÿ—๏ธ Ecosystem & Architectural Blueprints

Codebase Directory Structures & Module Overview

The full repository tree (backend, client-side frontend, native wrapper apps, and scripts) is documented in PROJECT_STRUCTURE.md.

Flow Diagram: Document Sync & Compilation Lifecycle

flowchart TD
    A["Web IDE (Client)"]
    B["Axum Backend (Server)"]
    C["LSP Client (Stdio/RPC)"]
    D["Local File System (/sdcard/...)"]

    A -- "1. Save (Ctrl+S)" --> B
    A -- "2. notify_file_changed()" --> C
    B -- "3. Sync to disk" --> D
    C -- "JSON-RPC" --> D
    B -- "4. Return JSON diagnostics" --> A
Loading

Flow Diagram: Diagnostic Polling Loops

sequenceDiagram
    autonumber
    actor Client as Client (Web IDE)
    participant Backend as Axum Backend
    participant LSP as Target LSP

    Client->>Backend: POST /diagnostics (Wait for version update)
    Backend->>LSP: didChange / didSave
    LSP-->>Backend: publishDiagnostics (Async stderr stream)
    Backend-->>Client: Return Diagnostics (JSON range & severity)
Loading

๐Ÿ“ฑ Native Wrapper Applications (Tauri & Flutter)

CodeDroid offers native client wrappers that bundle the codedroid_frontend WebAssembly package directly into target app environments.

๐Ÿ”„ Asset Synchronization Flow

Whenever the Leptos frontend code is modified, it must be compiled and synchronized to both the Flutter and Tauri directories. An automated build script is provided:

# Run from repository root
./apps/sync_assets.sh

This script builds codedroid_frontend in release mode and mirrors the static outputs to both application directories automatically.

โš™๏ธ Cross-Compiling Rust API for Android/Linux

The Android Flutter application bundles pre-compiled static Musl ELF binaries of codedroid_api (aarch64 and x86_64) to run the backend server inside the local environment (PRoot/Alpine).

To cross-compile and deploy the latest backend binary updates from a macOS/Linux machine to the Flutter assets:

  1. Ensure you have the musl-cross toolchain (specifically aarch64-linux-musl-gcc and x86_64-linux-musl-gcc) installed on your host system.
  2. Run the automated compilation, stripping, and deployment script from the repository root:
    ./build_android_binaries.sh
  3. Rebuild the Flutter Android application:
    cd apps/flutter_android
    flutter build apk --split-per-abi

๐Ÿ“ฑ Flutter (Android) Wrapper

Located in apps/flutter_android/. It launches a background InAppLocalhostServer on port 8080 to serve the static assets offline.

  • Why Localhost? Modern mobile WebViews block WebAssembly streaming compile calls if executed over the file:// protocol. The local server enables WebAssembly and provides cookies/LocalStorage persistence.
  • Theme & Style: Tailored with a custom Material 3 Dark theme matching the web IDE, featuring matching system bar colors and transparent status integrations.
  • For run and build instructions, see the Flutter Android README.

๐Ÿ’ป Tauri (Desktop) Wrapper

Located in apps/tauri_desktop/. It uses Tauri to pack the WebAssembly interface into native desktop clients.

  • Ultra-lightweight: Compiles to under 20MB, utilizing the native system web engines (Webkit2GTK / WebView2) to reduce RAM usage.
  • Cross-Platform: Supports native macOS, Windows, and Linux window environments.
  • For run and build instructions, see the Tauri Desktop README.

๐Ÿ“Š Supported Languages & Setup Directory

This guide details exactly how to configure compilers, runtimes, and auto-suggestion language servers (LSP) for each language. All shell operations are to be run in your Termux or system shell.


๐Ÿฆ€ Rust

Get a full, desktop-grade Rust development environment on your phone.

  • Compiler & Tools: Install rust and cargo:
    pkg install rust
  • Language Server (LSP): Install rust-analyzer for real-time completions, diagnostics, and hover hints:
    pkg install rust-analyzer
  • Enable Completions: Start the API server, open any .rs file in the IDE, and start typing. CodeDroid automatically hooks into rust-analyzer.

๐Ÿ Python

Set up Python script execution and IntelliSense formatting.

  • Python Runtime: Install Python and pip:
    pkg install python
  • Language Server (LSP): Install python-lsp-server (pylsp) via pip:
    pip install python-lsp-server
  • Usage: Create any .py file. CodeDroid automatically runs completions and highlights syntax.

๐Ÿน Go

Full Go compilation toolchain and suggestions on-device.

  • Go Compiler: Install the Go programming toolset:
    pkg install golang
  • Language Server (LSP): Install gopls (Go Please) to enable completions:
    pkg install gopls
  • Usage: Open any folder containing go.mod, edit .go files, and completions will populate.

๐ŸŒ JavaScript & TypeScript

Supports Node.js tools, React, Vue, Svelte, and Next.js.

  • Runtime: Install Node.js LTS:
    pkg install nodejs-lts
  • Language Server (LSP): Install the TypeScript LSP globally using npm:
    npm install -g typescript-language-server typescript
  • JS Projects: Create a jsconfig.json or tsconfig.json at your project root to assist type-inference resolutions.

๐Ÿงก Svelte

Scaffold and edit Svelte/Vite templates with custom diagnostics.

  • Language Server (LSP): Install Svelte tools:
    npm install -g svelte-language-server typescript
  • Usage: Open any .svelte file inside a Vite-scaffolded directory for autocomplete in markup, <script>, and <style> blocks.

๐Ÿ’š Vue

Support Vue 3 SFC files.

  • Language Server (LSP): Install Volar Vue language tools:
    npm install -g @vue/language-server typescript
  • Usage: Create or open a .vue project. Hybrid type resolutions are managed automatically by the backend.

โ˜• Java

Compile and run Java class hierarchies.

  • Java Runtime & Compiler: Install the OpenJDK package:
    pkg install openjdk-17
  • Language Server (LSP): Install the Eclipse JDT Language Server (jdtls):
    pkg install jdtls
  • Usage: Edit .java files; classes compile automatically inside CodeDroid's runner on run.

๐Ÿ›ก๏ธ C & C++

High-performance native coding using LLVM tools.

  • Compiler Toolchain: Install LLVM/Clang and make:
    pkg install clang build-essential
  • Language Server (LSP): Install clangd for diagnostics and completions:
    pkg install clangd
  • Usage: Create a .c or .cpp file. clangd acts as the back-end analyzer.

๐ŸŽฏ Dart

Build Dart CLI programs and scripts.

  • Runtime & Toolset: Install Dart SDK:
    pkg install dart
  • Language Server (LSP): Dart includes its language server inside the SDK. No separate installation required. CodeDroid resolves it automatically.

๐Ÿ’Ž Ruby

Execute scripts and resolve Gems.

  • Ruby Runtime: Install ruby:
    pkg install ruby
  • Language Server (LSP): Install the Solargraph gem:
    gem install solargraph

๐ŸŽ Swift

Develop Swift scripts inside Termux.

  • Swift Runtime: Install Swift:
    pkg install swift
  • Language Server (LSP): Swift includes the sourcekit-lsp binary. Ensure Xcode default toolchains are active if hosting on macOS.

๐Ÿงฌ Kotlin

Run compiled Kotlin bytecode.

  • Compiler: Install Kotlin compiler packages:
    pkg install kotlin
  • Language Server (LSP): Install kotlin-language-server from your system package manager.

๐Ÿงช Haskell, R, Perl, Pascal & Scala

Other supported scripting languages compile and run using their default packages:

  • Haskell: Run pkg install ghc to compile .hs scripts.
  • R: Run pkg install r-base to execute .R formulas.
  • Perl: Run pkg install perl to execute .pl files.
  • Pascal: Run pkg install fpc to compile .pas code with the Free Pascal Compiler.
  • Scala: Run pkg install scala to run JVM-based Scala programs.

๐Ÿง  Smart Code Suggestions & AI Rule Engine

CodeDroid's suggestion engine in error_suggestions.rs parses compiler diagnostics and provides contextual explanations and code replacements.

Suggestions Rules Mapping

Rule Trigger Matching Criteria Code Replacements Expected Result
Rust E0384 (Mutability) cannot mutate immutable variable, cannot assign to immutable Adds mut after the variable declaration let Variable is marked mutable; compiler error resolves on save.
Rust Unused Variable unused variable Prepends an underscore _ to the identifier Silences compiler warning flags.
Rust Type mismatch (String) expected String, found &str Appends .to_string() or .into() Casts string literal to owned String struct.
Rust Borrow String expected &str, found String Prepends borrow operator & or appends .as_str() Converts owned String reference to sliced slice.
Rust Integer mismatch Mismatches of usize/u32/i32 Appends as usize or as _ Casts number types dynamically.
Rust Missing Imports cannot find type/struct in scope for collections/sync Inserts use std::collections::* or use std::sync::* at Line 0 Resolves undefined scope structures.
Rust Move Violations cannot move out of shared reference Appends .clone() Creates owned duplicate data segment.
Python Indentation IndentationError, unexpected indent Informational alignment warning Alerts layout tabs vs spaces anomalies.
Python Scope Resolution NameError: name is not defined Spell-checks declared symbols Identifies typos or missing scope values.
JS / TS Scope Errors cannot find name Identifies missing export tags Flags typos and missing package imports.

๐Ÿ› ๏ธ Termux Android Installation Details

Termux serves as the native runtime engine on Android. For detailed steps, see TERMUX_SETUP.md.

  1. F-Droid Repository: Do not download Termux from the Google Play Store (outdated packages and security warnings). Use F-Droid or direct APK download options.
  2. Base Setup: Initialize Termux packages:
    pkg update && pkg upgrade -y
  3. Core Dependencies:
    pkg install git rust clang build-essential nodejs-lts python go -y
  4. Storage Integration: Connect storage paths to ensure files are visible inside download directories:
    termux-setup-storage
    This grants Termux filesystem read/write permissions to internal shared storage maps.

๐Ÿ“ก Cross-Device & iOS Network Connectivity

CodeDroid allows you to use your iPad or iPhone as a code editor screen, while using an Android tablet or local PC running Termux/Rust as the compiler server.

 โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”         โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
 โ”‚  iPhone / iPad / Browser โ”‚โ”€โ”€WiFiโ”€โ”€โ–ถโ”‚  PC or Android (Termux Host)   โ”‚
 โ”‚                          โ”‚         โ”‚                                โ”‚
 โ”‚  Open in Safari/Chrome:  โ”‚         โ”‚  codedroid_api  โ†’ port 3030    โ”‚
 โ”‚  http://<HOST-IP>:8082   โ”‚         โ”‚  trunk serve    โ†’ port 8082    โ”‚
 โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜         โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

For detailed configurations, see NETWORK_ACCESS.md.

Step-by-Step Device Bridging

  1. Start Services with Open Bindings: On your hosting PC or Android tablet, boot the API:
    • Using Pre-compiled Binary (Direct Run):
      ./run.sh
      # OR run the binary directly:
      ./codedroid-api
    • Building from Source (Requires Rust/Cargo):
      cd codedroid_api && cargo run --release
    • Compiling Binary to Root (For Developers):
      ./run.sh --build
      This compiles the API and places it in the root for direct run. In another session, start the Trunk Web IDE specifying bindings:
    cd codedroid_frontend && trunk serve --port 8082 --address 0.0.0.0
  2. Locate Local IP Address: Find the hosting device's local routing IP on the network:
    • Android: Run ip addr show wlan0 (looks like 192.168.0.101).
    • macOS: Run ipconfig getifaddr en0.
    • Linux: Run hostname -I.
  3. Connect Remote Client: Open Safari or Chrome on your secondary iPad/iPhone and go to http://192.168.0.101:8082.
  4. Configure API Routing: Open settings (โš™๏ธ) inside the Web IDE and set the Backend Server path to http://192.168.0.101:3030. Tap Test to establish connection.

โš™๏ธ LSP Binary Executable Path Resolution

The backend implements custom lookup logic inside utils.rs (resolve_lsp_executable) to resolve compiler LSPs.

                  Start LSP Request
                          โ”‚
            Does executable exist in PATH?
                 (using which / where)
                 โ”œโ”€โ”€ Yes โ”€โ”€โ–บ Return binary command name
                 โ””โ”€โ”€ No
                          โ”‚
         Check Termux System Prefix ($PREFIX/bin/)
                 โ”œโ”€โ”€ Yes โ”€โ”€โ–บ Return path to Termux binary
                 โ””โ”€โ”€ No
                          โ”‚
       Check macOS Homebrew Binaries (/opt/homebrew/bin/)
                 โ”œโ”€โ”€ Yes โ”€โ”€โ–บ Return Homebrew path
                 โ””โ”€โ”€ No
                          โ”‚
        Check NPM Global Installations (~/.npm-global/bin/)
                 โ”œโ”€โ”€ Yes โ”€โ”€โ–บ Return global NPM binary
                 โ””โ”€โ”€ No
                          โ”‚
              Run default name fallback

๐Ÿ”ฎ Upcoming Features & Roadmap

We are expanding CodeDroid into a full-featured desktop-class editor on mobile:

  • Origin Private File System (OPFS): Integrate the File System Access API to edit local folders on your phone directly from the browser.
  • Collaborative Sessions: Support multi-client peer-to-peer pairing over WebRTC for pair programming.
  • Offline Native Compiler Toolchains: Bundle minimal compiler binaries inside wrapper apps to run code completely detached from an external API server.

๐Ÿค Contributing

We welcome contributions to CodeDroid. Please check CONTRIBUTING.md for details on making pull requests, code formatting (cargo fmt), and setting up your dev workspace.


๐Ÿ“„ License

CodeDroid is licensed under the GNU General Public License v3.0.


๐Ÿ’ฌ Community Channels


CodeDroid โ€” Because real developers code everywhere.

About

CodeDroid is a mobile-first programming environment with a Rust (Axum) backend and Leptos-based WASM IDE, bringing real compilers, IntelliSense, package managers, and live previews directly to Android via Termux.

Topics

Resources

License

Contributing

Stars

11 stars

Watchers

0 watching

Forks

Contributors

Languages