CodeMorphix is a full-stack, AI-powered web application designed to translate source code seamlessly across multiple programming languages while preserving underlying code logic, structural semantics, and algorithmic functionality.
Driven by Google Gemini AI for high-accuracy translation and analysis, and integrated with the Piston API for real-time sandboxed code execution, CodeMorphix provides developers with an end-to-end platform to translate, execute, verify, explain, and debug code instantly in a modern, ultra-responsive SaaS UI.
- ๐ Multi-Language Code Translation: Effortless code translation across modern languages (Python, JavaScript, TypeScript, C++, Java, Rust, Go, C#, PHP, Ruby, etc.) preserving exact variable logic and patterns.
- ๐ง AI Code Understanding & Generation: Context-aware AST logic preservation powered by Google's Gemini API.
- โก Real-Time Sandboxed Code Execution: Run original and translated code side-by-side using isolated execution containers via the Piston API.
- โ
Output Verification: Compare output streams (
stdout,stderr) between source and target languages to confirm logical equivalence. - ๐ Error Detection & Suggestions: Automated static and semantic error detection with actionable fix recommendations.
- ๐ Code Explanation Feature: Get deep, line-by-line breakdown explanations of complex algorithms and language constructs.
- ๐ Secure Authentication: OAuth & Credentials authentication powered by Auth.js (NextAuth.js v5) with PostgreSQL user session management.
- ๐จ Modern SaaS UI: Glassmorphism design system built with Monaco Code Editor integration, responsive layouts, syntax highlighting, dark mode aesthetics, and micro-interactions.
- ๐ฅ Copy & Export Functionality: Quick 1-click clipboard copy and code snippet file download options.
- Framework: Next.js 16 (App Router)
- Library: React 19
- Code Editor: @monaco-editor/react
- Styling: Tailwind CSS v4
- Icons: Lucide React
- Runtime & API: Next.js API Routes / Server Actions (Node.js)
- Database ORM: Prisma 7.8
- Database Engine: PostgreSQL (Neon Serverless DB / Supabase)
- Authentication: Auth.js (
next-auth@v5) with@auth/prisma-adapter& bcryptjs
- AI Model: Google Gemini API (
@google/genai) - Code Execution: Piston Engine API
- Hosting: Vercel
flowchart TD
subgraph Client ["Client Interface (Next.js / React 19)"]
UI["Monaco Editor UI"]
Input["Source Code + Target Lang Selection"]
end
subgraph AuthLayer ["Security & Session"]
Auth["Auth.js (NextAuth v5)"]
DB[("Neon PostgreSQL via Prisma ORM")]
end
subgraph CoreEngine ["Backend Processing Pipeline"]
Router["Next.js Route Handlers / API Routes"]
Proxy["Proxy Handler / Sanitizer"]
end
subgraph ExternalServices ["External Engines & APIs"]
Gemini["Google Gemini AI API"]
Piston["Piston Code Execution Engine"]
end
UI -->|"1. Submit Source Code"| Input
Input -->|"2. Request via API"| Router
Router <-->|"Verify Session"| Auth
Auth <-->|"Query User / History"| DB
Router -->|"3. Forward Code Context"| Proxy
Proxy -->|"4. Request AI Translation"| Gemini
Gemini -->|"5. Return Translated Code & Explanation"| Proxy
Proxy -->|"6. Execute Output Verification"| Piston
Piston -->|"7. Send Execution Logs"| Proxy
Proxy -->|"8. Formulate Response"| Router
Router -->|"9. Render Translated Snippet & Results"| UI
- Source Code Input: The user inputs source code into the Monaco Editor and selects a target language.
- Contextual Analysis & Translation: The payload passes through Next.js proxy route handlers to the Google Gemini API, applying custom prompt engineering for strict code translation and logic retention.
- Sandboxed Code Execution: Input and generated code snippets are submitted to the Piston API to run in isolated micro-containers.
- Verification & Diff Analysis: Console output streams are collected, verified for correctness, and returned to the client alongside detailed code explanations.
code-morphix/
โโโ prisma/
โ โโโ schema.prisma # Database schema models (Users, Accounts, Sessions, History)
โ โโโ prisma.config.ts # Prisma Client & environment configuration
โโโ public/ # Static assets, icons, SVGs, and branding assets
โโโ src/
โ โโโ app/ # Next.js App Router (Pages, Layouts, API endpoints)
โ โ โโโ api/ # API route handlers (translation, execution, verify)
โ โ โโโ auth/ # Sign-in / Sign-up authentication pages
โ โ โโโ dashboard/ # Main translation workspace view
โ โ โโโ layout.tsx # Global root layout & providers
โ โ โโโ page.tsx # Landing page
โ โโโ components/ # Modular React components
โ โ โโโ editor/ # Monaco editor wrapper & controls
โ โ โโโ ui/ # Reusable UI elements (Buttons, Cards, Modals)
โ โ โโโ layout/ # Header, Sidebar, Navigation UI
โ โโโ lib/ # Core utility logic & service integration
โ โ โโโ gemini.ts # Google Gemini AI client & prompt helpers
โ โ โโโ piston.ts # Piston API execution service interface
โ โ โโโ db.ts # Prisma client instance
โ โ โโโ utils.ts # Helper utilities & class mergers
โ โโโ types/ # TypeScript type definitions & interfaces
โ โโโ auth.ts # Auth.js setup, providers & handlers
โ โโโ proxy.ts # API proxy and request parsing configuration
โโโ .env.example # Environment variables template
โโโ next.config.ts # Next.js configuration
โโโ package.json # Dependencies and build scripts
โโโ tsconfig.json # TypeScript compiler settings
โโโ README.md # Project documentation
Follow these step-by-step instructions to run CodeMorphix locally on your machine.
Ensure you have the following installed:
- Node.js:
v18.xor higher - npm (or pnpm / yarn)
- PostgreSQL Database: Local PostgreSQL instance, or a serverless database (e.g., Neon / Supabase)
- Google Gemini API Key: Obtainable from Google AI Studio
git clone https://github.com/your-username/codemorphix.git
cd codemorphixnpm installCreate a .env file in the root directory by copying .env.example:
cp .env.example .envOpen .env and fill in your credential values (see the Environment Variables section below).
Run the Prisma migrations to initialize your database schema:
npx prisma db pushGenerate the Prisma client:
npx prisma generatenpm run devOpen http://localhost:3000 in your browser to view the application.
Create a .env file in the project root with the following configuration:
# Database Connection URL (PostgreSQL / Neon / Supabase)
DATABASE_URL="postgresql://postgres:password@localhost:5432/code_translator?schema=public"
# Auth.js (NextAuth v5) Configuration
# Secret key generated via: npx auth secret
AUTH_SECRET="your-32-character-long-secret-key"
# Google OAuth Credentials (Optional: For Google Sign-In)
AUTH_GOOGLE_ID="your-google-client-id.apps.googleusercontent.com"
AUTH_GOOGLE_SECRET="your-google-client-secret"
# Application Public URL
NEXTAUTH_URL="http://localhost:3000"
# Google Gemini API Key (Required for AI Translations)
# Get your key at: https://aistudio.google.com/
GEMINI_API_KEY="AIzaSyYourGeminiApiKeyHere"- Paste or type your source code into the left Monaco Code Editor panel.
- Select your Source Language (or allow Auto-Detect) and your desired Target Language.
- Click "Translate Code".
- The translated code will appear in the right editor panel with syntax highlighting.
- Click "Run Code" to execute both the original and translated snippets side-by-side using the Piston API engine.
- Inspect output logs (
stdout/stderr) to verify that both codes yield identical logical output.
- Click "Explain Code" under any code panel.
- View a comprehensive, markdown-rendered explanation detailing algorithm steps, variables, and language-specific optimizations.
- Click "Copy" to copy the code directly to your clipboard.
- Click "Download" to save the translated code file with the appropriate extension (e.g.,
.py,.cpp,.rs).
(Add your application screenshots here)
| Landing Page | Translation Workspace |
|---|---|
| Live Execution & Logs | Code Explanation |
|---|---|
- Multi-File / Directory Translation: Support translating entire project repositories and multi-file structures.
- Custom AI Prompt Tuning: Allow users to select specific code optimization goals (e.g., Optimize for Memory, Optimize for Speed, Idiomatic Style).
- CLI Tool Integration: Develop an official
codemorphix-clinpm package to translate code directly from the command line. - VST/VS Code Extension: Bring CodeMorphix directly into IDEs via a VS Code extension.
- Team Workspaces & Shared History: Collaborative workspaces with saved translation history and snippet sharing.
Contributions, issues, and feature requests are welcome! Feel free to check out the Issues page.
- Fork the Project repository.
- Create your Feature Branch (
git checkout -b feature/AmazingFeature). - Commit your changes (
git commit -m 'Add some AmazingFeature'). - Push to the Branch (
git push origin feature/AmazingFeature). - Open a Pull Request.
Distributed under the MIT License. See LICENSE for more details.
Crafted with โค๏ธ for developers building with CodeMorphix