Skip to content

sameer2210/CodeX

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

90 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

CodeX - Collaborative AI-Powered Code Editor

CodeX Logo

Project Overview

CodeX is a collaborative code workspace built for teams that need shared editing, live communication, and AI-powered feedback. It pairs a React + Vite frontend with an Express backend, MongoDB storage, Socket.IO collaboration, and Google Gemini code review integration.

Teams can create projects, join shared rooms, collaborate on code in real time, send messages inside project rooms, execute JavaScript code on the server, and request AI review for project code.

The app includes authenticated dashboards, project rooms, live presence tracking, and WebRTC signaling support for audio/video call workflows.

Notes from repository scan

  • The repository contains screenshot and demo assets in public/.
  • A hosted live deployment URL is not confirmed in source files.
  • The existing README referenced a YouTube demo and deployment link that are not verifiable from the codebase.

React Node Socket.IO Gemini

Demo video asset

Watch the demo video

Direct link: https://youtu.be/gB7qztH9BIg?si=hfeuMXsqUXkxoAHT

πŸ“Έ Screenshots

Landing Page Dashboard

Editor & Review Logout

Tech Stack

Frontend

Technology Purpose
React 19 UI framework
Vite Build tooling
Tailwind CSS Styling
Redux Toolkit State management
React Router DOM Client-side routing
@monaco-editor/react Code editor UI
Socket.IO Client Realtime collaboration
Framer Motion Animations
React Hook Form Form handling
Yup Validation
axios HTTP client
Sonner Notifications
Recharts Dashboard visuals

Backend

Technology Purpose
Node.js Server runtime
Express.js HTTP API framework
Mongoose MongoDB object modeling
Socket.IO Realtime socket server
JSON Web Tokens Authentication
Helmet Security headers
Morgan HTTP request logging
@google/generative-ai Gemini AI code review
node:vm Sandboxed JS execution

Database & Storage

Technology Purpose
MongoDB Primary data store
Mongoose Schema enforcement

Dev Tools & Deployment

Tool Purpose
Vite Frontend development
nodemon Backend reload
ESLint Linting
Prettier Formatting
Jest Backend tests
Vitest Frontend tests
Playwright E2E testing
cross-env Cross-platform env scripts

Project Structure

CodeX/
β”œβ”€β”€ Backend/
β”‚   β”œβ”€β”€ package.json
β”‚   β”œβ”€β”€ server.js
β”‚   └── src/
β”‚       β”œβ”€β”€ app.js
β”‚       β”œβ”€β”€ config/
β”‚       β”‚   └── config.js
β”‚       β”œβ”€β”€ controllers/
β”‚       β”‚   β”œβ”€β”€ auth.controllers.js
β”‚       β”‚   β”œβ”€β”€ message.controllers.js
β”‚       β”‚   └── project.controllers.js
β”‚       β”œβ”€β”€ db/
β”‚       β”‚   └── db.js
β”‚       β”œβ”€β”€ middlewares/
β”‚       β”‚   └── authMiddleware.js
β”‚       β”œβ”€β”€ models/
β”‚       β”‚   β”œβ”€β”€ message.model.js
β”‚       β”‚   β”œβ”€β”€ project.model.js
β”‚       β”‚   └── team.model.js
β”‚       β”œβ”€β”€ routes/
β”‚       β”‚   β”œβ”€β”€ auth.routes.js
β”‚       β”‚   β”œβ”€β”€ message.routes.js
β”‚       β”‚   β”œβ”€β”€ project.routes.js
β”‚       β”‚   └── webrtc.routes.js
β”‚       β”œβ”€β”€ services/
β”‚       β”‚   β”œβ”€β”€ ai.service.js
β”‚       β”‚   β”œβ”€β”€ auth.service.js
β”‚       β”‚   β”œβ”€β”€ call.service.js
β”‚       β”‚   β”œβ”€β”€ message.service.js
β”‚       β”‚   └── project.service.js
β”‚       └── tests/
β”‚           β”œβ”€β”€ auth.test.js
β”‚           └── project.test.js
β”œβ”€β”€ Frontend/
β”‚   β”œβ”€β”€ package.json
β”‚   β”œβ”€β”€ index.html
β”‚   β”œβ”€β”€ vite.config.js
β”‚   └── src/
β”‚       β”œβ”€β”€ App.jsx
β”‚       β”œβ”€β”€ main.jsx
β”‚       β”œβ”€β”€ index.css
β”‚       β”œβ”€β”€ api/
β”‚       β”‚   β”œβ”€β”€ config.jsx
β”‚       β”‚   └── project.api.js
β”‚       β”œβ”€β”€ components/
β”‚       β”‚   β”œβ”€β”€ CallingPage.jsx
β”‚       β”‚   β”œβ”€β”€ ErrorBoundary.jsx
β”‚       β”‚   β”œβ”€β”€ HUD.jsx
β”‚       β”‚   β”œβ”€β”€ layout/
β”‚       β”‚   β”‚   β”œβ”€β”€ Layout.jsx
β”‚       β”‚   β”‚   β”œβ”€β”€ Navigation.jsx
β”‚       β”‚   β”‚   └── Sidebar.jsx
β”‚       β”‚   β”œβ”€β”€ page/
β”‚       β”‚   β”‚   β”œβ”€β”€ ActiveMember.jsx
β”‚       β”‚   β”‚   β”œβ”€β”€ ActiveMemberPage.jsx
β”‚       β”‚   β”‚   β”œβ”€β”€ Help.jsx
β”‚       β”‚   β”‚   β”œβ”€β”€ Meeting.jsx
β”‚       β”‚   β”‚   β”œβ”€β”€ Notification.jsx
β”‚       β”‚   β”‚   └── Settings.jsx
β”‚       β”‚   └── ui/
β”‚       β”‚       β”œβ”€β”€ Button.jsx
β”‚       β”‚       └── ResizableContainer.jsx
β”‚       β”œβ”€β”€ context/
β”‚       β”‚   └── ThemeContext.jsx
β”‚       β”œβ”€β”€ lib/
β”‚       β”‚   β”œβ”€β”€ notify.js
β”‚       β”‚   └── sounds.js
β”‚       β”œβ”€β”€ routes/
β”‚       β”‚   └── Routes.jsx
β”‚       β”œβ”€β”€ services/
β”‚       β”‚   └── dashboardService.jsx
β”‚       β”œβ”€β”€ store/
β”‚       β”‚   β”œβ”€β”€ hooks.js
β”‚       β”‚   β”œβ”€β”€ socketMiddleware.js
β”‚       β”‚   β”œβ”€β”€ store.js
β”‚       β”‚   └── slices/
β”‚       β”‚       β”œβ”€β”€ authSlice.js
β”‚       β”‚       β”œβ”€β”€ callSlice.js
β”‚       β”‚       β”œβ”€β”€ projectSlice.js
β”‚       β”‚       └── socketSlice.js
β”‚       β”œβ”€β”€ tests/
β”‚       β”‚   β”œβ”€β”€ Login.test.jsx
β”‚       β”‚   └── setup.js
β”‚       β”œβ”€β”€ views/
β”‚       β”‚   β”œβ”€β”€ Dashboard.jsx
β”‚       β”‚   β”œβ”€β”€ Landing.jsx
β”‚       β”‚   β”œβ”€β”€ NotFound.jsx
β”‚       β”‚   β”œβ”€β”€ auth/
β”‚       β”‚   β”‚   β”œβ”€β”€ Login.jsx
β”‚       β”‚   β”‚   └── Register.jsx
β”‚       β”‚   β”œβ”€β”€ create-project/
β”‚       β”‚   β”‚   └── CreateProject.jsx
β”‚       β”‚   └── home/
β”‚       β”‚       └── project/
β”‚       β”‚           β”œβ”€β”€ Project.jsx
β”‚       β”‚           └── components/
β”‚       β”‚               β”œβ”€β”€ ChatSection.jsx
β”‚       β”‚               β”œβ”€β”€ CodeEditor.jsx
β”‚       β”‚               β”œβ”€β”€ OutputPanel.jsx
β”‚       β”‚               └── ReviewPanel.jsx
β”‚       └── webrtc/
β”‚           β”œβ”€β”€ callManager.js
β”‚           β”œβ”€β”€ media.js
β”‚           └── peer.js
β”œβ”€β”€ public/
β”‚   β”œβ”€β”€ code.png
β”‚   β”œβ”€β”€ codeXDemo.mp4
β”‚   β”œβ”€β”€ dashboard.png
β”‚   β”œβ”€β”€ demo.png
β”‚   β”œβ”€β”€ logo.png
β”‚   β”œβ”€β”€ logout.png
β”‚   └── og-image.png
β”œβ”€β”€ tests/
β”‚   β”œβ”€β”€ playwright.config.js
β”‚   β”œβ”€β”€ e2e/
β”‚   β”‚   └── flow.spec.js
β”‚   └── load/
β”‚       └── simulation.js
β”œβ”€β”€ package.json
└── Readme.md

Database Models

Project

Field Type Notes
name String Required
teamName String Required, lowercase
code String Project source text
review String AI review output

Message

Field Type Notes
projectId ObjectId References Project
teamName String Required
username String Required
message String Required
type String user, system, or notification
metadata Object Optional edit/reply tracking

Team

Field Type Notes
teamName String Required, unique, lowercase
password String Hashed
members Array Member objects with activity state

API Reference

Auth β€” /api/auth

Method Endpoint Description
POST /register Register a new team and admin user
POST /login Login and receive JWT
GET /verify Verify current token
POST /logout Logout and mark member inactive
GET /team/:teamName/members Get team member list
PUT /team/:teamName/member/:username/activity Update member active status
GET /team/:teamName/messages Fetch team messages

Projects β€” /api/projects

Method Endpoint Description
POST /create Create a new project
GET /get-all List all team projects
GET /:id Get project details
PUT /:id Update project code
POST /:id/execute Execute JavaScript code
POST /:id/review Run AI review for project code

Messages β€” /api/messages

Method Endpoint Description
GET /project/:projectId Fetch project chat messages
GET /project/:projectId/unread Get unread message count

WebRTC β€” /api/webrtc

Method Endpoint Description
GET /turn Fetch STUN/TURN ICE server config

Pages & Routes

Page Route Description
Landing / Public landing page
Login /login Team login form
Register /register Team signup form
Dashboard /dashboard, /projects, /team, /activity Main authenticated workspace
Create Project /create-project New project creation page
Project Room /project/:id Project collaboration and editor room
Meeting /meeting, /meeting/:projectId Call / meeting interface
Active Members /active-members Team presence view
Settings /settings User settings page
Help /help Help and documentation page
Notifications /notifications Team notification feed
Not Found /not-found 404 fallback page

Authentication & Authorization

  • Auth strategy: JWT bearer tokens
  • Token storage: localStorage under codex_token
  • Protected frontend routes: PrivateRoute in Frontend/src/routes/Routes.jsx
  • Backend protection: verifyToken middleware in Backend/src/middlewares/authMiddleware.js
  • Team-scoped checks: checkTeamAccess middleware for team-specific auth routes
  • Admin flag: isAdmin included in JWT payload

Third-Party Integrations

Service Purpose Library
Google Gemini AI code review generation @google/generative-ai
Socket.IO Realtime collaboration and signaling socket.io, socket.io-client
Monaco Editor Code editor UX @monaco-editor/react
STUN/TURN WebRTC NAT traversal Browser RTC + backend config
axios HTTP API requests axios

Repository Notes

  • Demo and screenshot assets exist under public/ (demo.png, dashboard.png, code.png, logout.png, codeXDemo.mp4).
  • The old README referenced a live deployment URL and YouTube embed; those are not verifiable from repository source files and are noted as not found in code.
  • The root package.json contains only runtime dependencies for jsonwebtoken and socket.io-client.

πŸ”Œ Database Models

Project Model

{
  name: String (required),
  teamName: String (required),
  code: String (default: ""),
  review: String (default: ""),
  timestamps: true
}

Message Model

{
  projectId: ObjectId (Project),
  teamName: String,
  username: String,
  message: String,
  type: "user" | "system" | "notification",
  metadata: { edited, editedAt, replyTo },
  timestamps: true
}

Team Model

{
  teamName: String (unique),
  password: String (hashed),
  members: [{ username, isAdmin, lastLogin, joinedAt, isActive }],
  createdAt: Date,
  updatedAt: Date
}

πŸš€ Getting Started

Prerequisites

  • Node.js (v18 or higher)
  • MongoDB database
  • Google Gemini API key

Backend Setup

cd Backend
npm install
npm start

Frontend Setup

cd Frontend
npm install
npm run dev

Environment Variables

Create a .env file in Backend/:

PORT=8000
MONGODB_URI=your_mongodb_connection_string
JWT_SECRET=your_jwt_secret
GOOGLE_API_KEY=your_gemini_api_key
FRONTEND_URLS=http://localhost:5173,https://your-frontend-domain.com
STUN_URLS=stun:stun.l.google.com:19302
TURN_URLS=turn:your-turn-host:3478?transport=udp,turn:your-turn-host:3478?transport=tcp
TURN_USERNAME=your_turn_username
TURN_CREDENTIAL=your_turn_credential

Create a .env file in Frontend/:

VITE_BACKEND_URL=http://localhost:8000

Node VM sandboxed code execution: Present

Uses node:vm and runs user code inside a VM context with timeout in project.service.js (line 3), project.service.js (line 37), project.service.js (line 65), project.service.js (line 68), project.service.js (line 70).

STUN/TURN config for WebRTC: Present

Backend exposes ICE config in webrtc.routes.js (line 13), reads env in config.js (line 20), config.js (line 23).

Frontend uses STUN/TURN and RTCPeerConnection in peer.js (line 17), peer.js (line 20), peer.js (line 65), and fetches backend TURN config at peer.js (line 95).

Playwright + Jest + Vitest: Present

Playwright config/spec in playwright.config.js (line 1), flow.spec.js (line 1).

Jest in backend test setup/deps: package.json (line 12), package.json (line 42).

Vitest in frontend scripts/deps: package.json (line 12), package.json (line 51), setup file setup.js (line 3).

Monaco Editor: Present

Dependency in package.json (line 16).

Editor component usage and mount/commands in CodeEditor.jsx (line 2), CodeEditor.jsx (line 182), CodeEditor.jsx (line 575).

πŸ”§ Development Workflow

1. Project Creation

  1. User navigates to /create-project
  2. Enters project name
  3. Backend creates MongoDB document
  4. User is redirected to project workspace

2. Collaborative Coding

  1. Multiple users join the same project
  2. Each user connects via Socket.io
  3. Code changes are broadcasted to all users
  4. Chat messages are synchronized in real-time

3. AI Code Review

  1. Developer clicks "Get Review"
  2. Current code is sent to Gemini AI service
  3. AI analyzes code and provides feedback
  4. Review is displayed in markdown

πŸ§ͺ Testing

  • Backend: cd Backend && npm test
  • Frontend: cd Frontend && npm run test
  • E2E: npx playwright test (from repo root)

πŸš€ Deployment

Backend Deployment

  • Deploy to Render, Railway, Heroku, or AWS
  • Set production environment variables
  • Ensure MongoDB connection is accessible

Frontend Deployment

  • Build with npm run build
  • Deploy to Vercel, Netlify, or any static hosting
  • Point VITE_BACKEND_URL to production API

πŸ”’ Security Considerations

  • JWT-based authentication
  • CORS allow-list configuration
  • Input validation in controllers
  • Secure API key storage in environment variables

πŸ‘¨β€πŸ’» Developer

Sameer Khan

Full Stack Developer (MERN)

Portfolio LinkedIn GitHub Email


**Happy Coding with CodeX! **

About

Write code together. Review smarter. Ship faster. live code sync, team chat, and AI-driven code reviews to streamline modern development teams.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages