Skip to content

oussssaman/codouss

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Codouss - Interactive Code Execution Platform

Codouss Logo

Write, Execute, and Share Code Instantly in Your Browser

MIT License Python React TypeScript Flask

🌟 Overview

Codouss is a comprehensive web-based REPL (Read-Eval-Print Loop) platform that enables instant code execution across multiple programming languages directly in your browser. Built with modern technologies and a focus on user experience, it provides a VS Code-like coding environment with powerful features for learning, prototyping, and collaboration.

✨ Features

🎯 Complete Implementation - All 4 Project Steps

βœ… Step 1: Basic REPL

  • Monaco Editor Integration: Full VS Code editing experience in browser
  • Multi-Language Support: Python, JavaScript, TypeScript
  • Instant Code Execution: Client-side execution with Pyodide for Python
  • Real-time Output: Live execution results with comprehensive error handling
  • Syntax Highlighting: Language-specific syntax highlighting and autocomplete

βœ… Step 2: Script Management

  • Create & Save Scripts: Persistent script storage with cloud synchronization
  • Script Library: Organized dashboard with search and filtering
  • Auto-save: Never lose your work with automatic saving
  • Script Operations: Edit, delete, duplicate, and organize scripts
  • Import/Export: Download scripts and import existing code

βœ… Step 3: User Authentication & Cross-Device Access

  • Secure Authentication: JWT-based login system with encrypted passwords
  • User Registration: Quick and easy account creation
  • Cross-Device Sync: Access your scripts from anywhere
  • Session Management: Secure session handling with auto-refresh
  • Password Security: Secure password hashing and change functionality

βœ… Step 4: Multi-Language Support

  • Python: Full Python 3 with NumPy, Pandas, Matplotlib libraries
  • JavaScript: Modern ES6+ features, async/await, Promise support
  • TypeScript: Type-safe JavaScript with full TypeScript compilation
  • Extensible Architecture: Easy to add more programming languages

🎨 Modern User Interface

Dark Coding Theme

  • Optimized for Coding: Eye-friendly dark theme designed for long coding sessions
  • Syntax Highlighting: Beautiful, accurate syntax highlighting for all languages
  • Terminal-style Output: Realistic terminal appearance with color-coded output
  • Responsive Design: Works perfectly on desktop, tablet, and mobile devices

Intuitive Navigation

  • Clean Dashboard: Beautiful card-based script management interface
  • Smart Search: Find scripts by name, content, or programming language
  • Activity Stats: View your coding activity and favorite languages
  • Quick Actions: Fast access to common operations

πŸ‘€ Comprehensive User Management

Profile Management

  • User Profile Page: Complete profile management with avatar and stats
  • Activity Statistics: Track your coding activity and progress
  • Account Information: View and edit username, email, and account details
  • Data Export: Download all your scripts and data in JSON format
  • Account Security: Secure account deletion with confirmation

Settings & Preferences

  • Editor Customization: Font size, theme, tab size, line numbers
  • Code Preferences: Default language, auto-save, word wrap, minimap
  • Privacy Controls: Public profile, activity visibility settings
  • Security Settings: Password change, notification preferences
  • Data Management: Export data, reset settings, account controls

πŸ”§ Advanced Features

Smart Script Management

  • Duplicate Prevention: Intelligent handling of duplicate script names
  • Script Forking: Create copies of scripts with auto-generated unique names
  • Validation: Real-time validation with helpful error messages
  • Bulk Operations: Select and manage multiple scripts at once

Code Execution Engine

  • Secure Execution: Client-side code execution eliminates server security risks
  • Performance Optimized: Fast execution with WebAssembly (Pyodide)
  • Error Handling: Comprehensive error capture and display
  • Output Formatting: Clean, readable output with proper formatting

Developer Experience

  • Monaco Editor: Full VS Code editing experience with IntelliSense
  • Live Collaboration Ready: Architecture supports future real-time features
  • Extensible Plugin System: Ready for custom language plugins
  • API-First Design: RESTful API for all operations

πŸš€ Technology Stack

Frontend Architecture

  • React 18 with TypeScript for type-safe development
  • Vite for lightning-fast development and optimized builds
  • TailwindCSS for modern, responsive styling
  • Monaco Editor for professional code editing experience
  • Pyodide for secure client-side Python execution
  • Framer Motion for smooth animations and transitions
  • React Query for efficient API state management
  • React Router for seamless navigation

Backend Architecture

  • Flask web framework with RESTful API design
  • SQLAlchemy ORM for database operations
  • JWT Authentication for secure user sessions
  • SQLite database (easily upgradeable to PostgreSQL/MySQL)
  • CORS for secure cross-origin requests
  • Werkzeug for password hashing and security

Development Tools

  • TypeScript for enhanced code quality and developer experience
  • ESLint & Prettier for code formatting and linting
  • Vitest for comprehensive testing
  • Concurrently for development server management

πŸ“ Project Structure

codouss/
β”œβ”€β”€ frontend/                 # React + TypeScript frontend
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ components/      # Reusable UI components
β”‚   β”‚   β”‚   └── ui/         # Core UI component library (40+ components)
β”‚   β”‚   β”œβ”€β”€ pages/          # Application pages
β”‚   β”‚   β”‚   β”œβ”€β”€ Auth.tsx    # Login/Register page
β”‚   β”‚   β”‚   β”œβ”€β”€ Dashboard.tsx # Script management dashboard
β”‚   β”‚   β”‚   β”œβ”€β”€ Editor.tsx  # Code editor with execution
β”‚   β”‚   β”‚   β”œβ”€β”€ Profile.tsx # User profile management
β”‚   β”‚   β”‚   β”œβ”€β”€ Settings.tsx # User preferences
β”‚   β”‚   β”‚   └── NotFound.tsx # 404 error page
β”‚   β”‚   β”œβ”€β”€ contexts/       # React contexts
β”‚   β”‚   β”‚   β”œβ”€β”€ AuthContext.tsx        # User authentication
β”‚   β”‚   β”‚   └── CodeExecutionContext.tsx # Code execution state
β”‚   β”‚   β”œβ”€β”€ lib/           # Utilities and API clients
β”‚   β”‚   β”‚   β”œβ”€β”€ api.ts            # API client functions
β”‚   β”‚   β”‚   β”œβ”€β”€ codeExecution.ts  # Pyodide integration
β”‚   β”‚   β”‚   β”œβ”€β”€ errorHandling.ts  # Error management
β”‚   β”‚   β”‚   └── utils.ts          # Utility functions
β”‚   β”‚   └── hooks/         # Custom React hooks
β”‚   β”œβ”€β”€ public/            # Static assets
β”‚   └── package.json       # Frontend dependencies
β”œβ”€β”€ backend/               # Flask backend API
β”‚   β”œβ”€β”€ app.py            # Main Flask application
β”‚   β”œβ”€β”€ config.py         # Configuration settings
β”‚   β”œβ”€β”€ requirements.txt  # Python dependencies
β”‚   └── .env.example      # Environment variables template
β”œβ”€β”€ package.json          # Root package.json for monorepo
β”œβ”€β”€ README.md            # This comprehensive documentation
└── START.md             # Quick start guide

πŸ› οΈ Installation & Setup

Prerequisites

  • Node.js 18+ and npm (for frontend)
  • Python 3.8+ and pip (for backend)
  • Git for version control

Quick Start

  1. Clone the Repository

    git clone <repository-url>
    cd codouss
  2. Install All Dependencies

    npm run install:all
  3. Set Up Environment Variables

    cd backend
    cp .env.example .env
    # Edit .env with your configuration
  4. Start Development Servers

    # From root directory - starts both frontend and backend
    npm run dev
  5. Access the Application

Manual Setup

Frontend Setup

cd frontend
npm install
npm run dev

Backend Setup

cd backend
pip install -r requirements.txt
python app.py

🎯 Usage Guide

Getting Started

  1. Create Account: Register with username, email, and password
  2. Dashboard: View your script library and activity statistics
  3. Create Script: Click "New Script" to start coding
  4. Choose Language: Select Python, JavaScript, or TypeScript
  5. Write Code: Use Monaco editor with full autocomplete and syntax highlighting
  6. Execute: Click "Run" to execute code instantly in your browser
  7. Save Script: Give your script a name and save for future access

Code Execution Environments

Python Environment

  • Libraries: NumPy, Pandas, Matplotlib pre-installed
  • Execution: Secure client-side execution via Pyodide
  • Features: Full Python 3 syntax, exception handling, output capture
  • Security: Sandboxed execution with no server-side risks

JavaScript Environment

  • Features: ES6+, async/await, modern JavaScript APIs
  • Execution: Direct browser execution in isolated scope
  • Capabilities: DOM manipulation, fetch API, Promise handling
  • Security: Controlled execution environment

TypeScript Environment

  • Features: Full TypeScript syntax with type checking
  • Compilation: Automatic transpilation to JavaScript
  • Type Safety: Real-time type error detection
  • IntelliSense: Advanced code completion and hints

Script Management

Dashboard Features

  • Script Library: View all saved scripts with thumbnails
  • Search & Filter: Find scripts by name, content, or language
  • Statistics: View coding activity and favorite languages
  • Quick Actions: Edit, delete, fork, or run scripts

Advanced Operations

  • Script Forking: Create copies with auto-generated unique names
  • Bulk Management: Select and operate on multiple scripts
  • Import/Export: Share scripts or backup your work
  • Version History: Track script modifications

Profile & Settings

Profile Management

  • Personal Information: Update username, email, and avatar
  • Activity Stats: View coding statistics and achievements
  • Data Export: Download all scripts and profile data
  • Account Security: Manage password and security settings

Editor Preferences

  • Theme Options: Dark, light, or high-contrast themes
  • Font Settings: Adjustable font size and family
  • Editor Features: Line numbers, minimap, word wrap, auto-save
  • Language Defaults: Set preferred programming language

πŸ”§ Configuration

Environment Variables

Create backend/.env file:

# Security Keys (CHANGE IN PRODUCTION)
SECRET_KEY=your-super-secret-key-here
JWT_SECRET_KEY=your-jwt-secret-key-here

# Database Configuration
DATABASE_URL=sqlite:///codouss.db
# For PostgreSQL: DATABASE_URL=postgresql://username:password@localhost/codouss
# For MySQL: DATABASE_URL=mysql://username:password@localhost/codouss

# CORS Settings
CORS_ORIGINS=http://localhost:3000,http://127.0.0.1:3000

# Environment
FLASK_ENV=development
FLASK_DEBUG=1

Database Configuration

Development (SQLite)

DATABASE_URL=sqlite:///codouss.db

Production (PostgreSQL)

DATABASE_URL=postgresql://username:password@host:port/database

Production (MySQL)

DATABASE_URL=mysql://username:password@host:port/database

πŸš€ Deployment

Frontend Deployment

Build for Production

cd frontend
npm run build

Deploy to Netlify/Vercel

  • Upload frontend/dist/ folder
  • Set build command: npm run build
  • Set publish directory: dist

Backend Deployment

Using Gunicorn

cd backend
pip install gunicorn
gunicorn -w 4 -b 0.0.0.0:5000 app:app

Docker Deployment

# Backend Dockerfile
FROM python:3.9-slim
WORKDIR /app
COPY backend/ .
RUN pip install -r requirements.txt
CMD ["gunicorn", "-w", "4", "-b", "0.0.0.0:5000", "app:app"]

Environment Variables for Production

SECRET_KEY=your-production-secret-key
JWT_SECRET_KEY=your-production-jwt-key
DATABASE_URL=your-production-database-url
CORS_ORIGINS=https://your-domain.com
FLASK_ENV=production

πŸ” Security Features

Code Execution Security

  • Client-side Execution: All code runs in user's browser (Pyodide for Python)
  • Sandboxed Environment: Isolated execution with limited system access
  • No Server-side Code Execution: Eliminates server security vulnerabilities
  • Input Validation: All user inputs validated and sanitized

Authentication Security

  • JWT Tokens: Stateless authentication with secure token handling
  • Password Hashing: Bcrypt password hashing with salt
  • Session Management: Secure session handling with auto-refresh
  • CORS Protection: Proper cross-origin request handling

Data Security

  • Input Sanitization: All inputs validated against XSS and injection
  • SQL Injection Prevention: Parameterized queries with SQLAlchemy
  • Secure Headers: Proper security headers implementation
  • Data Privacy: User data encrypted and properly handled

πŸ“Š Performance

Frontend Performance

  • Code Splitting: Optimized bundle sizes with lazy loading
  • Asset Optimization: Compressed images and minified code
  • Caching Strategy: Efficient browser caching for static assets
  • Loading States: Smooth user experience with loading indicators

Backend Performance

  • Database Indexing: Optimized queries with proper indexing
  • Connection Pooling: Efficient database connection management
  • Caching: Response caching where appropriate
  • API Optimization: Minimal response payloads and efficient endpoints

Code Execution Performance

  • Pyodide Optimization: Cached Python environment for faster execution
  • WebAssembly: Near-native execution speed for Python code
  • Memory Management: Efficient memory usage and cleanup
  • Concurrent Execution: Non-blocking code execution

πŸ—„οΈ Database Schema

Users Table

CREATE TABLE user (
    id VARCHAR(36) PRIMARY KEY,
    username VARCHAR(80) UNIQUE NOT NULL,
    email VARCHAR(120) UNIQUE NOT NULL,
    password_hash VARCHAR(200) NOT NULL,
    created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
    updated_at DATETIME DEFAULT CURRENT_TIMESTAMP
);

Scripts Table

CREATE TABLE script (
    id VARCHAR(36) PRIMARY KEY,
    title VARCHAR(200) NOT NULL,
    content TEXT DEFAULT '',
    language VARCHAR(50) DEFAULT 'python',
    user_id VARCHAR(36) NOT NULL,
    is_public BOOLEAN DEFAULT FALSE,
    created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
    updated_at DATETIME DEFAULT CURRENT_TIMESTAMP,
    FOREIGN KEY (user_id) REFERENCES user (id) ON DELETE CASCADE
);

πŸ“ˆ API Documentation

Authentication Endpoints

  • POST /api/auth/register - Register new user
  • POST /api/auth/login - User login
  • GET /api/auth/me - Get current user info

Script Management Endpoints

  • GET /api/scripts - Get user's scripts
  • POST /api/scripts - Create new script
  • GET /api/scripts/{id} - Get specific script
  • PUT /api/scripts/{id} - Update script
  • DELETE /api/scripts/{id} - Delete script
  • POST /api/scripts/{id}/fork - Fork script
  • POST /api/scripts/check-name - Check name availability

User Management Endpoints

  • GET /api/user/profile - Get user profile
  • PUT /api/user/profile - Update profile
  • PUT /api/user/password - Change password
  • GET /api/user/settings - Get user settings
  • PUT /api/user/settings - Update settings
  • GET /api/user/export - Export user data
  • DELETE /api/user/account - Delete account

Public Endpoints

  • GET /api/public/scripts - Get public scripts
  • GET /api/health - Health check

πŸ§ͺ Testing

Run Tests

# Frontend tests
cd frontend
npm test

# Backend tests (if implemented)
cd backend
python -m pytest

Test Coverage

  • Unit Tests: Core utility functions and API endpoints
  • Integration Tests: Full user workflows and authentication
  • E2E Tests: Complete user journeys from registration to execution

πŸ—ΊοΈ Development Roadmap

Current Features (v1.0)

  • βœ… Multi-language code execution (Python, JavaScript, TypeScript)
  • βœ… User authentication and account management
  • βœ… Script saving and management
  • βœ… Profile and settings pages
  • βœ… Dark theme optimized for coding
  • βœ… Responsive design for all devices
  • βœ… Comprehensive error handling
  • βœ… Data export and import

Planned Features (v2.0)

  • πŸ”„ Real-time collaboration and sharing
  • πŸ”„ Code sharing with public script library
  • οΏ½οΏ½ Plugin system for custom languages
  • πŸ”„ Advanced code analysis and linting
  • πŸ”„ Integration with GitHub/GitLab
  • πŸ”„ Mobile app (React Native)
  • πŸ”„ Team workspaces and collaboration
  • πŸ”„ Code completion and AI assistance

Future Enhancements (v3.0)

  • πŸ”„ Live collaboration editing
  • πŸ”„ Video chat integration for pair programming
  • πŸ”„ Advanced analytics and insights
  • πŸ”„ Custom themes and editor extensions
  • πŸ”„ Marketplace for code snippets
  • πŸ”„ Educational features and tutorials

🀝 Contributing

We welcome contributions! Here's how to get started:

Development Guidelines

  1. Fork the Repository
  2. Create Feature Branch: git checkout -b feature/amazing-feature
  3. Follow Code Standards: Use TypeScript for frontend, PEP 8 for backend
  4. Write Tests: Include tests for new features
  5. Update Documentation: Keep README and comments current
  6. Commit Changes: git commit -m 'Add amazing feature'
  7. Push to Branch: git push origin feature/amazing-feature
  8. Open Pull Request: Describe your changes clearly

Code Standards

  • Frontend: TypeScript, ESLint, Prettier formatting
  • Backend: Python PEP 8, type hints, docstrings
  • UI/UX: Follow existing design patterns and accessibility guidelines
  • Testing: Write tests for new functionality

πŸ†˜ Support & Troubleshooting

Common Issues

Pyodide Loading Problems

  • Check browser console for errors
  • Ensure stable internet connection (loads from CDN)
  • Try refreshing the page or clearing browser cache

Backend Connection Issues

  • Verify Flask server is running on port 5000
  • Check CORS settings in backend configuration
  • Ensure environment variables are properly set

Frontend Build Issues

  • Run npm install in frontend directory
  • Clear node_modules and reinstall if needed
  • Check Node.js version compatibility

Database Issues

  • Verify database connection string
  • Check file permissions for SQLite database
  • Ensure database migrations are applied

Getting Help

  • GitHub Issues: Report bugs and request features
  • Documentation: Check this README and START.md

πŸ“„ License

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

πŸ™ Acknowledgments

  • Monaco Editor team for the excellent web-based code editor
  • Pyodide project for bringing Python to the browser
  • React and Flask communities for robust frameworks
  • TailwindCSS for beautiful, utility-first styling
  • Radix UI for accessible component primitives

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published