Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

23 Commits
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

CODEXA

A collaborative code editor and project management platform with AI assistance, designed for modern development workflows

License: MIT TypeScript React Express PostgreSQL

โœจ Features

  • GitHub Integration: Seamless OAuth authentication and repository management
  • AI-Powered Chat: Contextual AI assistance for coding queries and debugging
  • Project Management: Full-stack project organization with file versioning
  • Real-time Collaboration: Multi-user editor states and session management
  • File Snapshots: Version control with automatic snapshots and undo functionality
  • Web Container Sessions: Browser-based code execution environments
  • Smart Editor State: Persistent cursor position, open files, and layout preferences
  • AI Usage Tracking: Monitor AI model usage and costs across projects

๐Ÿš€ Quick Start

Prerequisites

  • Node.js 18+
  • PostgreSQL database
  • GitHub OAuth App (for authentication)
  • npm or yarn package manager

Installation

  1. Clone the repository

    git clone <repository-url>
    cd Codexa
  2. Set up the database

    # Create a PostgreSQL database
    createdb codexa_dev
  3. Configure environment variables

    # Create .env file in backend directory
    cd backend
    cp .env.example .env

    Update the .env file with:

    DATABASE_URL="postgresql://username:password@localhost:5432/codexa_dev"
    GITHUB_CLIENT_ID="your_github_client_id"
    GITHUB_CLIENT_SECRET="your_github_client_secret"
    GITHUB_CALLBACK_URL="http://localhost:3000/api/auth/github/callback"
    PORT=3000
  4. Install dependencies

    # Install backend dependencies
    cd backend
    npm install
    
    # Install frontend dependencies
    cd ../frontend
    npm install
  5. Set up the database schema

    cd backend
    npx prisma migrate dev
    npx prisma generate
  6. Start the development servers

    # Start the backend server (Terminal 1)
    cd backend
    npm run dev
    
    # Start the frontend server (Terminal 2)
    cd frontend
    npm run dev
  7. Access the application

    • Backend API: http://localhost:3000
    • Frontend: http://localhost:5173 (Vite default)

๐Ÿ“ Project Structure

Codexa/
โ”œโ”€โ”€ README.md
โ”œโ”€โ”€ package.json        # Root package.json (if using monorepo)
โ”œโ”€โ”€ backend/            # Express.js API server
โ”‚   โ”œโ”€โ”€ index.ts        # Main server entry point
โ”‚   โ”œโ”€โ”€ package.json    # Backend dependencies
โ”‚   โ”œโ”€โ”€ package-lock.json
โ”‚   โ”œโ”€โ”€ prisma.config.ts    # Prisma configuration
โ”‚   โ”œโ”€โ”€ tsconfig.json   # TypeScript configuration
โ”‚   โ”œโ”€โ”€ config/
โ”‚   โ”‚   โ””โ”€โ”€ env.ts          # Environment configuration
โ”‚   โ”œโ”€โ”€ controllers/        # Request handlers
โ”‚   โ”‚   โ”œโ”€โ”€ auth.controller.ts
โ”‚   โ”‚   โ”œโ”€โ”€ ai.controller.ts
โ”‚   โ”‚   โ”œโ”€โ”€ file.controller.ts
โ”‚   โ”‚   โ”œโ”€โ”€ github.controller.ts
โ”‚   โ”‚   โ””โ”€โ”€ project.controller.ts
โ”‚   โ”œโ”€โ”€ generated/          # Generated Prisma client
โ”‚   โ”‚   โ””โ”€โ”€ prisma/         # Prisma client types and models
โ”‚   โ”œโ”€โ”€ lib/
โ”‚   โ”‚   โ””โ”€โ”€ prisma.ts       # Prisma client instance
โ”‚   โ”œโ”€โ”€ middleware/         # Express middleware
โ”‚   โ”‚   โ””โ”€โ”€ auth.middleware.ts
โ”‚   โ”œโ”€โ”€ prisma/             # Database schema and migrations
โ”‚   โ”‚   โ”œโ”€โ”€ schema.prisma   # Database schema definition
โ”‚   โ”‚   โ””โ”€โ”€ migrations/     # Database migration files
โ”‚   โ”œโ”€โ”€ routes/             # API endpoints
โ”‚   โ”‚   โ”œโ”€โ”€ auth.routes.ts
โ”‚   โ”‚   โ”œโ”€โ”€ ai.routes.ts
โ”‚   โ”‚   โ”œโ”€โ”€ file.routes.ts
โ”‚   โ”‚   โ”œโ”€โ”€ github.routes.ts
โ”‚   โ”‚   โ””โ”€โ”€ project.routes.ts
โ”‚   โ”œโ”€โ”€ services/           # Business logic
โ”‚   โ”‚   โ”œโ”€โ”€ auth.service.ts
โ”‚   โ”‚   โ”œโ”€โ”€ ai.service.ts           # AI integration service
โ”‚   โ”‚   โ”œโ”€โ”€ file.service.ts         # File management service
โ”‚   โ”‚   โ”œโ”€โ”€ project.service.ts      # Project management service
โ”‚   โ”‚   โ””โ”€โ”€ github.service.ts       # GitHub API integration
โ”‚   โ”œโ”€โ”€ types/              # TypeScript type definitions
โ”‚   โ”‚   โ””โ”€โ”€ express.d.ts
โ”‚   โ””โ”€โ”€ utils/              # Utility functions
โ”‚       โ””โ”€โ”€ jwt.ts
โ””โ”€โ”€ frontend/               # React application
    โ”œโ”€โ”€ package.json        # Frontend dependencies
    โ”œโ”€โ”€ package-lock.json   # Dependency lock file
    โ”œโ”€โ”€ vite.config.ts      # Vite configuration
    โ”œโ”€โ”€ tsconfig.json       # TypeScript configuration
    โ”œโ”€โ”€ tsconfig.app.json   # App TypeScript configuration
    โ”œโ”€โ”€ tsconfig.node.json  # Node TypeScript configuration
    โ”œโ”€โ”€ eslint.config.js    # ESLint configuration
    โ”œโ”€โ”€ index.html          # HTML entry point
    โ”œโ”€โ”€ public/             # Static assets
    โ””โ”€โ”€ src/
        โ”œโ”€โ”€ App.tsx         # Main React component
        โ”œโ”€โ”€ main.tsx        # React app entry point
        โ”œโ”€โ”€ App.css         # Global styles
        โ”œโ”€โ”€ index.css       # Base styles
        โ”œโ”€โ”€ api/            # API client services
        โ”‚   โ”œโ”€โ”€ ai.ts
        โ”‚   โ”œโ”€โ”€ auth.ts
        โ”‚   โ”œโ”€โ”€ client.ts
        โ”‚   โ”œโ”€โ”€ files.ts
        โ”‚   โ”œโ”€โ”€ github.ts
        โ”‚   โ””โ”€โ”€ projects.ts
        โ”œโ”€โ”€ assets/         # Static assets
        โ”œโ”€โ”€ components/     # Reusable React components
        โ”‚   โ”œโ”€โ”€ editor/
        โ”‚   โ”‚   โ”œโ”€โ”€ CodeEditor.tsx
        โ”‚   โ”‚   โ””โ”€โ”€ EditorTabs.tsx
        โ”‚   โ”œโ”€โ”€ layout/
        โ”‚   โ”‚   โ”œโ”€โ”€ Sidebar.tsx
        โ”‚   โ”‚   โ”œโ”€โ”€ StatusBar.tsx
        โ”‚   โ”‚   โ””โ”€โ”€ Topbar.tsx
        โ”‚   โ”œโ”€โ”€ modals/
        โ”‚   โ”‚   โ”œโ”€โ”€ LoginModal.tsx
        โ”‚   โ”‚   โ”œโ”€โ”€ NewFileModal.tsx
        โ”‚   โ”‚   โ””โ”€โ”€ NewProjectModal.tsx
        โ”‚   โ””โ”€โ”€ panels/
        โ”‚       โ”œโ”€โ”€ AIChat.tsx
        โ”‚       โ”œโ”€โ”€ FileExplorer.tsx
        โ”‚       โ”œโ”€โ”€ GitPanel.tsx
        โ”‚       โ”œโ”€โ”€ SearchPanel.tsx
        โ”‚       โ””โ”€โ”€ Terminal.tsx
        โ”œโ”€โ”€ pages/          # Page components
        โ”‚   โ”œโ”€โ”€ AuthCallback.tsx
        โ”‚   โ””โ”€โ”€ IDEPage.tsx
        โ”œโ”€โ”€ stores/         # State management
        โ”‚   โ”œโ”€โ”€ authStore.ts
        โ”‚   โ”œโ”€โ”€ editorStore.ts
        โ”‚   โ”œโ”€โ”€ projectStore.ts
        โ”‚   โ””โ”€โ”€ uiStore.ts
        โ””โ”€โ”€ utils/          # Utility functions
            โ”œโ”€โ”€ fileIcons.ts
            โ””โ”€โ”€ languages.ts

๐Ÿ”ง Development

Backend Development

The backend is built with TypeScript, Express.js, and Prisma:

cd backend
npm run dev        # Start development server with hot reload
npm run build      # Build TypeScript for production
npm start          # Start production server

Frontend Development

The frontend is built with React, TypeScript, and Vite:

cd frontend
npm run dev        # Start Vite development server
npm run build      # Build for production
npm run preview    # Preview production build locally
npm run lint       # Run ESLint

Database Operations

cd backend

# Generate Prisma client after schema changes
npx prisma generate

# Create and apply new migration
npx prisma migrate dev --name migration_name

# Reset database (development only)
npx prisma migrate reset

# View data in Prisma Studio
npx prisma studio

๐Ÿ—„๏ธ Database Schema

The application uses PostgreSQL with Prisma ORM. Key entities include:

  • Users: GitHub OAuth integration with session management
  • Projects: Code project organization with repository linking
  • Files: File management with versioning and snapshots
  • Chat Sessions: AI-powered coding assistance conversations
  • Editor States: Persistent editor preferences and configurations
  • AI Usage: Tracking of AI model consumption and costs
  • Web Container Sessions: Browser-based development environments

๐ŸŽฏ Key Features

GitHub Integration

  • OAuth authentication flow
  • Repository synchronization
  • Commit tracking and version management
  • User profile and avatar integration

AI-Powered Development

  • Chat Interface: Context-aware AI coding assistant
  • Usage Tracking: Monitor AI model consumption and costs
  • Referenced Files: AI responses with file context
  • Multi-role Conversations: User, assistant, and system messages

Web Container Development

  • Browser Environments: Run code directly in browser containers
  • Session Management: Persistent development environments per project
  • Multi-language Support: Execute various programming languages

๐Ÿ”’ Authentication & Security

GitHub OAuth Flow

  1. User initiates login via GitHub
  2. OAuth redirect to GitHub authorization
  3. Callback with authorization code
  4. Token exchange and user profile retrieval
  5. JWT token generation for session management

Security Features

  • Encrypted access and refresh tokens
  • Session-based authentication with expiration
  • IP address and user agent tracking
  • Cascade deletion for data consistency

๐Ÿ› ๏ธ Technology Stack

Backend

  • Runtime: Node.js with TypeScript
  • Framework: Express.js
  • Database: PostgreSQL with Prisma ORM
  • Authentication: GitHub OAuth + JWT
  • Environment: dotenv for configuration

Frontend

  • Framework: React 19 with TypeScript
  • Build Tool: Vite
  • Styling: Tailwind CSS v4
  • Linting: ESLint with React plugins

Development Tools

  • ORM: Prisma with automatic client generation
  • Hot Reload: nodemon for backend, Vite HMR for frontend
  • Type Safety: Full TypeScript coverage
  • Database Migrations: Prisma migrate

๐Ÿ“Š API Endpoints

Authentication

  • POST /api/auth/github - Initiate GitHub OAuth flow
  • GET /api/auth/github/callback - Handle OAuth callback
  • POST /api/auth/logout - End user session

Projects

  • GET /api/projects - List user projects
  • POST /api/projects - Create new project
  • GET /api/projects/:id - Get project details
  • PUT /api/projects/:id - Update project
  • DELETE /api/projects/:id - Delete project

Files

  • GET /api/projects/:id/files - List project files
  • POST /api/projects/:id/files - Create/upload file
  • PUT /api/files/:id - Update file content
  • GET /api/files/:id/snapshots - Get file version history

Chat

  • POST /api/projects/:id/chat - Start chat session
  • POST /api/chat/:id/messages - Send chat message
  • GET /api/chat/:id/history - Get chat history

AI Services

  • GET /api/ai/models - List available AI models
  • POST /api/ai/usage - Track AI model usage

๐Ÿ”ฎ Future Enhancements

  • Real-time collaborative editing with WebSockets
  • Advanced AI code completion and suggestions
  • Plugin system for custom extensions
  • Integrated debugging tools
  • Multi-language syntax highlighting
  • Code review and commenting system
  • Project templates and scaffolding
  • Advanced search and navigation
  • Performance analytics and monitoring
  • Mobile companion app

๐Ÿค Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

๐Ÿ“ License

This project is licensed under the MIT License - see the LICENSE file for details.

๐Ÿ™ Acknowledgments

  • Inspired by modern code editors like Cursor and VSCode
  • Built with the amazing React and Express.js ecosystems
  • Powered by Prisma for type-safe database operations
  • GitHub's OAuth platform for seamless authentication

Note: This project is currently in active development. Features and API endpoints may change as the platform evolves.

About

A modern, AI-powered code editor, designed for enhanced developer productivity

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages