A full-stack, AI-powered browser-based development platform.
Generate, edit, run, and collaborate on code β all inside your browser.
Codex AI Code Editor is a powerful, full-stack development environment that runs entirely in the browser. It combines Google Gemini AI for intelligent code generation, WebContainers for real Node.js execution without leaving the browser, and Socket.io for real-time multi-user collaboration β all built on the MERN stack.
Simply describe what you want to build, and the AI generates a complete, runnable project structure for you. Collaborate with teammates in real time, explore the file tree, edit code, and see it run β live.
- Integrated with Google Gemini (
@google/genai+@google/generative-ai) - Mention
@aiin the project chat to trigger AI assistance - AI parses natural language prompts and returns a structured file tree with complete code
- Responses are rendered with syntax highlighting (via
highlight.js) and Markdown (viamarkdown-to-jsx)
- Powered by Socket.io (v4) β users in the same project share a real-time room
- Project chat with live message broadcasting
- AI responses are emitted to all connected users simultaneously
- Uses WebContainers (
@webcontainer/api) to run a full Node.js environment in the browser - Live terminal output and filesystem emulation β no server-side sandbox needed
- Integrated File Explorer and Code Editor components for intuitive navigation
- JWT (JsonWebToken) based stateless auth with
bcryptpassword hashing - Persistent sessions via HTTP-only cookies and
cookie-parser - Input validation via
express-validator - Protected API routes and Socket.io middleware
- Create and manage multiple coding projects per user
- Each project has its own isolated workspace, file tree, and collaboration room
- Add/remove collaborators to shared projects
- Built with React 19 + Vite for blazing-fast HMR
- Styled with Tailwind CSS v3 and PostCSS
- Smooth transitions with Framer Motion
- Icons from Remix Icon
- Responsive design with a clean, dark-themed aesthetic
| Technology | Purpose |
|---|---|
| React 19 + Vite | UI framework & dev server |
| Tailwind CSS v3 | Utility-first styling |
| Framer Motion | Animations & transitions |
| Socket.io Client | Real-time communication |
| WebContainers API | In-browser Node.js runtime |
| Axios | HTTP requests |
| React Router DOM v7 | Client-side routing |
| highlight.js | Syntax highlighting |
| markdown-to-jsx | Markdown rendering |
| Remix Icon | Icon library |
| Technology | Purpose |
|---|---|
| Node.js + Express 5 | REST API server |
| MongoDB + Mongoose | Database & ODM |
| Socket.io | WebSocket server for real-time events |
| Google Generative AI SDK | Gemini AI integration |
Redis (ioredis) |
Caching layer |
| jsonwebtoken | JWT authentication |
| bcrypt | Password hashing |
| express-validator | Input validation |
| Morgan | HTTP request logging |
| dotenv | Environment variable management |
Codex/
βββ backend/
β βββ src/
β β βββ config/ # Database & Cache connection (db.js, cache.js)
β β βββ controllers/
β β β βββ ai.controller.js # AI prompt handler
β β β βββ auth.controller.js # Register / Login / Logout / Profile
β β β βββ project.controller.js # CRUD + collaborator management
β β βββ middleware/ # JWT auth & Redis Blacklist middleware
β β βββ models/
β β β βββ user.model.js # User schema (Mongoose)
β β β βββ project.model.js # Project schema with collaborators
β β βββ routes/
β β β βββ auth.routes.js # /api/auth/*
β β β βββ project.routes.js # /projects/*
β β β βββ ai.routes.js # /ai/*
β β βββ services/
β β β βββ ai.service.js # Gemini AI generation logic
β β β βββ auth.service.js # Auth business logic
β β β βββ project.service.js # Project business logic
β β βββ validators/ # express-validator rule sets
β β βββ app.js # Express app setup & middleware
β βββ server.js # HTTP server + Socket.io setup
β βββ package.json
β
βββ frontend/
β βββ src/
β β βββ app/ # Application Entry and Routing
β β β βββ routes/ # React Router route definitions (AppRoutes.jsx)
β β β βββ App.jsx # Main application wrapper
β β β βββ index.css # Global Tailwind CSS
β β βββ features/ # 4-Layer Architecture Implementation
β β β βββ components/ # UI Layer: Reusable UI (Protected, CodeEditor)
β β β βββ context/ # State Layer: Global state (UserContext)
β β β βββ hooks/ # Hooks Layer: Logic orchestration (useAuth, useProject)
β β β βββ pages/ # UI Layer: Main route pages
β β β β βββ auth/ # Login.jsx, Register.jsx
β β β β βββ project/ # Home.jsx, Project.jsx
β β β βββ services/ # API Layer: Backend communication (auth.api.js, project.api.js)
β β β βββ config/ # Socket.io, WebContainers, and Axios configs
β β βββ main.jsx # React DOM entry point
β βββ public/ # Static assets
β βββ index.html
β βββ vite.config.js
β βββ tailwind.config.js
β βββ package.json
β
βββ Readme.md
Make sure you have the following installed:
- Node.js v18 or higher (
node -v) - npm v8+ (bundled with Node.js)
- MongoDB (local installation or MongoDB Atlas free tier)
- Redis (local installation or Upstash cloud instance)
- A Google Gemini API Key β get one free at ai.google.dev
git clone <repository-url>
cd saascd backend
npm installCreate a .env file inside the backend/ directory:
# Server
PORT=3000
# Database
MONGO_URI=mongodb://localhost:27017/codex-ai-db
# Auth
JWT_SECRET=your_super_secret_jwt_key
# Google Gemini AI
GOOGLE_AI_KEY=your_gemini_api_key
# Redis
REDIS_HOST=localhost
REDIS_PORT=6379
REDIS_PASSWORD=your_redis_passwordStart the backend server:
# Development (with auto-reload via nodemon)
npm run dev
# Production
node server.jsThe backend will start at
http://localhost:3000
Open a new terminal and run:
cd frontend
npm install
npm run devThe frontend will start at
http://localhost:5173
Navigate to http://localhost:5173 in your browser.
- Register a new account
- Create a project from the Home dashboard
- In the project workspace, type
@ai <your prompt>in the chat to generate code - Browse the generated file tree, open files in the code editor, and run the project in the WebContainer terminal
| Method | Endpoint | Description |
|---|---|---|
POST |
/register |
Register a new user |
POST |
/login |
Log in and receive a JWT cookie |
GET |
/logout |
Clear the auth cookie and log out |
GET |
/profile |
Get the logged-in user's profile |
| Method | Endpoint | Description |
|---|---|---|
POST |
/create |
Create a new project |
GET |
/all |
Get all projects for the current user |
GET |
/:projectId |
Get a single project by ID |
PUT |
/add-user |
Add a collaborator to a project |
| Method | Endpoint | Description |
|---|---|---|
GET |
/get-result |
Send a prompt and receive an AI-generated file tree |
Contributions, issues, and feature requests are welcome!
- Fork the repository
- Create a feature branch:
git checkout -b feature/your-feature-name - Commit your changes:
git commit -m "feat: add your feature" - Push to the branch:
git push origin feature/your-feature-name - Open a Pull Request
Please follow conventional commit messages and ensure your code passes linting before submitting.
This project is a personal/educational implementation of an AI-powered code editor, inspired by similar SaaS development tools. It uses Google Gemini API for AI features β a valid API key is required for the AI functionality to work. Usage of the Gemini API is subject to Google's Terms of Service and data usage policies.
Made with β€οΈ using the MERN Stack + Google Gemini AI