An AI-powered full-stack web application that helps developers work across programming languages. Write code once β translate, analyze, optimize, and understand it instantly using Google Gemini AI.
- π Code Translation β Convert code between C, C++, C#, Java, and Python
- π Complexity Analysis β Get time and space complexity with Big-O notation
- β‘ Code Optimization β AI-powered suggestions to improve performance
- π Code Explanation β Beginner-friendly plain English explanations
- π Email / Password Auth β Register and login with traditional credentials
- π Google SSO β One-click sign-in with Google OAuth
- π Operation History β Automatically save and browse past operations
- ποΈ Monaco Code Editor β Professional VS Code-style editor in the browser
- π¨ Modern UI β Sleek black & white glassmorphism design
Client (React + Vite)
β
Axios Interceptor (auto-attach JWT)
β
Express API Server
β
Auth Middleware (verify JWT β attach user)
β
Code Controller (validate input)
β
Service Layer (build prompt β call Gemini AI β clean response)
β
History Service (fire-and-forget save to MongoDB)
β
Response β { success: true, data: result }
- Node.js (v18+)
- MongoDB Atlas account (free tier available)
- Google Cloud Project with:
- Gemini API enabled
- OAuth 2.0 Client ID configured
- npm or yarn package manager
git clone https://github.com/rohazshaik/AI-Powered-Smart-Code-Translator.git
cd AI-Powered-Smart-Code-Translatorcd server
npm installCreate .env file (use .env.example as template):
cp .env.example .envUpdate .env with your credentials:
MONGODB_URI=mongodb+srv://username:password@cluster.mongodb.net/?retryWrites=true&w=majority
PORT=5000
CLIENT_URLs=http://localhost:5173,http://localhost:5174,http://localhost:5175
GOOGLE_CLIENT_ID=your-google-client-id
GEMINI_API_KEY=your-gemini-api-key
JWT_SECRET=your-secure-random-string
JWT_EXPIRES_IN=7dcd ../client
npm installCreate .env file (use .env.example as template):
cp .env.example .envUpdate .env:
VITE_API_URL=http://localhost:5000/api
VITE_GOOGLE_CLIENT_ID=your-google-client-idTerminal 1 - Backend Server:
cd server
npm run devServer will run on http://localhost:5000
Terminal 2 - Frontend Server:
cd client
npm run devFrontend will run on http://localhost:5173
- Create a free cluster at mongodb.com/cloud/atlas
- Create a database user
- Whitelist your IP in Network Access
- Copy connection string and update
MONGODB_URIin.env
- Go to Google Cloud Console
- Create a new project
- Enable Gemini API and Google+ API
- Create OAuth 2.0 Client ID (Web application)
- Add authorized origins:
http://localhost:5173 http://localhost:5174 http://localhost:5175 - Add authorized redirect URIs:
http://localhost:5173 http://localhost:5174 http://localhost:5175 - Copy Client ID and update both
.envfiles - For Gemini API, create an API Key and add to server
.env
βββ client/ # React Frontend
β βββ src/
β β βββ components/ # Reusable UI components
β β βββ pages/ # Page components
β β βββ services/ # API calls
β β βββ context/ # React context (Auth)
β β βββ constants/ # Languages, prompts
β β βββ styles/ # CSS files
β βββ public/ # Static assets
β
βββ server/ # Express Backend
β βββ src/
β β βββ config/ # Database & API config
β β βββ controllers/ # Request handlers
β β βββ middleware/ # Auth, error handling
β β βββ models/ # Mongoose schemas
β β βββ routes/ # API endpoints
β β βββ services/ # Business logic
β β βββ utils/ # Helpers (JWT, prompts)
β βββ package.json
β
βββ .gitignore # Git ignore rules
npm run dev # Start development server
npm run build # Build for production
npm run preview # Preview production build
npm run lint # Run ESLintnpm run dev # Start with auto-reload
npm start # Start production serverPOST /api/auth/registerβ Create new accountPOST /api/auth/email-loginβ Email/password loginPOST /api/auth/google-loginβ Google OAuth loginPOST /api/auth/logoutβ Logout
POST /api/code/translateβ Translate codePOST /api/code/analyzeβ Analyze complexityPOST /api/code/optimizeβ Optimize codePOST /api/code/explainβ Explain code
GET /api/historyβ Get user's history (paginated)DELETE /api/history/:idβ Delete specific operationDELETE /api/historyβ Clear all history
- Responsive Design β Works on desktop, tablet, and mobile
- Glassmorphism β Modern frosted glass effect
- Dark Theme β Black & white with opacity
- Smooth Animations β Hover effects and transitions
- Google Sans Font β Modern typography
- Accessibility β Keyboard navigation support
- JWT Authentication β Secure token-based auth
- Password Hashing β bcryptjs for secure storage
- CORS Protection β Configured for frontend origin
- Input Validation β Server-side validation on all inputs
- HTTP-only Cookies β (Optional enhancement)
- Rate Limiting β (Recommended for production)
cd client
npm run build
# Deploy 'dist' folder to Vercelcd server
npm install
git push heroku mainUpdate frontend .env with production API URL.
- React 18
- Vite
- Axios
- React Router
- Monaco Editor
- React Hot Toast
- Google OAuth
- Express.js
- MongoDB & Mongoose
- Google Gemini AI
- Google Auth Library
- JWT
- bcryptjs
- CORS
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit changes (
git commit -m 'Add amazing feature') - Push to branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License β see the LICENSE file for details.
Created with β€οΈ by Rohaz Shaik
Enjoy coding! π
- React 18 + Vite
- Monaco Editor (
@monaco-editor/react) - React Router v6
- Axios with JWT interceptor
- Google OAuth (
@react-oauth/google) - React Hot Toast
- Node.js + Express (ES Modules)
- MongoDB Atlas + Mongoose
- JSON Web Tokens (JWT)
- bcryptjs for password hashing
- Google Auth Library (SSO verification)
- Google Gemini 2.5 Flash AI
- Frontend: https://ai-powered-smart-code-translator.vercel.app
- Backend: https://ai-powered-smart-code-translator.onrender.com
| Operation | Endpoint | Input | Output |
|---|---|---|---|
| Translate | POST /api/code/translate |
code, sourceLanguage, targetLanguage | { translatedCode } |
| Analyze | POST /api/code/analyze |
code, language | { timeComplexity, spaceComplexity, explanation } |
| Optimize | POST /api/code/optimize |
code, language | { optimizedCode, suggestions } |
| Explain | POST /api/code/explain |
code, language | { explanation } |
User registers / logs in
β
Backend creates JWT token (contains user ID + email)
β
Frontend stores token in localStorage
β
Axios interceptor attaches token to every request
β
Auth middleware verifies token on protected routes
β
req.user available in all controllers
AI-Powered Smart Code Translator/
β
βββ client/ # Frontend (React + Vite)
β βββ src/
β βββ components/ # CodeEditor, Navbar, OutputPanel, etc.
β βββ constants/ # Language definitions, starter code
β βββ context/ # AuthContext (global auth state)
β βββ pages/ # LoginPage, HomePage, HistoryPage
β βββ services/ # API call functions (auth, code, history)
β βββ styles/ # CSS files
β
βββ server/ # Backend (Express + MongoDB)
βββ src/
βββ config/ # DB, Gemini, Google OAuth setup
βββ constants/ # Prompts, language definitions
βββ controllers/ # HTTP request handlers
βββ middleware/ # Auth, error handling
βββ models/ # Mongoose schemas (User, History)
βββ routes/ # API route definitions
βββ services/ # Business logic (translate, analyze, etc.)
βββ utils/ # JWT utilities, response parsers
- Node.js
- MongoDB Atlas account
- Google Gemini API key (aistudio.google.com)
- Google OAuth Client ID (console.cloud.google.com)
cd server
npm install
npm run devcd client
npm install
npm install react@18 react-dom@18
npm run devCreate .env inside server/:
PORT=5000
CLIENT_URL=http://localhost:5173
CLIENT_URLS=http://localhost:5173,https://ai-powered-smart-code-translator.vercel.app
MONGODB_URI=your_mongodb_atlas_connection_string
JWT_SECRET=your_super_secret_jwt_key
JWT_EXPIRES_IN=7d
GOOGLE_CLIENT_ID=your_google_oauth_client_id
GEMINI_API_KEY=your_gemini_api_keyCreate .env inside client/:
VITE_API_URL=http://localhost:5000/api
VITE_GOOGLE_CLIENT_ID=your_google_oauth_client_idFor Google sign-in, create a Google OAuth Web client and add these authorized JavaScript origins:
http://localhost:5173- your deployed frontend URL
For hosted deployments, set CLIENT_URLS on the backend to a comma-separated list of allowed frontend origins. Example:
CLIENT_URLS=http://localhost:5173,https://ai-powered-smart-code-translator.vercel.app- Email/password sign in and registration
- One-click Google SSO
- Monaco Editor with syntax highlighting
- 4 action tabs: Translate Β· Analyze Β· Optimize Β· Explain
- Language selector with swap button
- Real-time AI output panel
- Paginated list of all past operations
- Click any entry to view full input + output
- Delete individual entries or clear all history
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/auth/register |
Register new user |
| POST | /api/auth/login |
Login with email/password |
| POST | /api/auth/google |
Login with Google SSO |
| GET | /api/auth/me |
Get current user profile |
| POST | /api/auth/logout |
Logout |
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/code/translate |
Translate code |
| POST | /api/code/analyze |
Analyze complexity |
| POST | /api/code/optimize |
Optimize code |
| POST | /api/code/explain |
Explain code |
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/history |
Get paginated history |
| GET | /api/history/:id |
Get single history entry |
| DELETE | /api/history/:id |
Delete history entry |
| DELETE | /api/history/clear |
Clear all history |
- π Add more languages (Go, Rust, TypeScript, Kotlin)
- π Syntax error detection before sending to AI
- π Side-by-side diff view for optimized code
- π Shareable result links
- π¬ Conversation memory for multi-turn code sessions
- π± Mobile-responsive layout
Built with β€οΈ using React, Node.js, MongoDB, and Google Gemini AI.
Full-stack AI application featuring RAG-style prompt engineering, JWT authentication, Google OAuth, and the Monaco Editor.


