Skip to content

VashuVats/AI_Security_Code_Collab

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SecCollab - Collaborative Code Security Auditing Platform

SecCollab is a real-time collaborative development environment with AI-powered security analysis. Built with the MERN stack, it allows teams to write, review, and secure code together.

🚀 Features

  • Real-time Collaboration: Multiple developers can work on the same project simultaneously
  • AI Security Auditor: Powered by Google Gemini AI to detect security vulnerabilities
  • In-Browser Code Execution: Run Node.js applications directly in the browser using WebContainer
  • Live Code Editor: Multi-file editing with syntax highlighting
  • Project Management: Create and manage multiple projects with team members
  • Secure Authentication: JWT-based authentication with bcrypt password hashing
  • Message History: Persistent chat and collaboration history

🛡️ Security Features

The AI security auditor (SECURE-AI) analyzes code for:

  • JWT handling issues
  • Missing authentication checks
  • MongoDB injection vulnerabilities
  • XSS and CSRF vulnerabilities
  • Unsafe eval usage
  • Weak cryptography
  • Secret leakage
  • Input validation issues

📋 Prerequisites

  • Node.js (v18 or higher)
  • MongoDB (v5 or higher)
  • Redis (optional - will use in-memory fallback)
  • Google Gemini API key (for AI features)

🔧 Installation

Backend Setup

  1. Navigate to the backend directory:
cd backend
  1. Install dependencies:
npm install
  1. Create .env file from example:
cp .env.example .env
  1. Update .env with your configuration:

    • Set MONGODB_URI to your MongoDB connection string
    • Set JWT_SECRET to a strong random string
    • Set GOOGLE_AI_KEY to your Google Gemini API key
    • (Optional) Configure Redis credentials
  2. Start the backend server:

npm run run

The backend will run on http://localhost:3000

Frontend Setup

  1. Navigate to the frontend directory:
cd frontend
  1. Install dependencies:
npm install
  1. Create .env file from example:
cp .env.example .env
  1. Update .env if needed (default points to http://localhost:3000)

  2. Start the development server:

npm run dev

The frontend will run on http://localhost:5173

🎯 Usage

Getting Started

  1. Register an Account: Navigate to /register and create a new account

    • Password must be at least 8 characters with uppercase, lowercase, and numbers
  2. Create a Project: Click "New Project" on the home page

  3. Invite Collaborators: Click "Add collaborator" to invite team members

  4. Start Coding:

    • Create files using the "+" button in the file explorer
    • Edit code in the editor
    • Files auto-save on blur
  5. Run Your Code: Click "Run" to execute your Node.js application in the browser

  6. Request Security Analysis: Type @ai [your request] in the chat to trigger AI security analysis

AI Security Analysis

Example commands:

  • @ai analyze this code for security issues
  • @ai check for SQL injection vulnerabilities
  • @ai review authentication implementation

The AI will:

  • Analyze your code
  • Identify security issues with severity levels
  • Suggest fixes
  • Automatically apply safe fixes to your file tree

🏗️ Architecture

Backend Stack

  • Express.js: Web framework
  • MongoDB: Database for projects, users, and messages
  • Mongoose: ODM for MongoDB
  • Socket.IO: Real-time communication
  • Redis: Token blacklisting and rate limiting
  • Google Gemini AI: Security analysis
  • JWT: Authentication
  • bcrypt: Password hashing

Frontend Stack

  • React 19: UI framework
  • Vite: Build tool
  • TailwindCSS: Styling
  • Socket.IO Client: Real-time updates
  • WebContainer API: In-browser Node.js runtime
  • Axios: HTTP client
  • React Router: Navigation
  • highlight.js: Syntax highlighting
  • markdown-to-jsx: Markdown rendering

🔒 Security Improvements

Recent security enhancements:

  • ✅ Rate limiting on authentication and file operations
  • ✅ Strong password requirements (min 8 chars, complexity)
  • ✅ Input validation and sanitization
  • ✅ File size limits (1MB per file, 10MB total)
  • ✅ CORS configuration
  • ✅ Redis token blacklisting
  • ✅ Error boundaries for graceful error handling
  • ✅ Memory leak prevention (socket and process cleanup)

📁 Project Structure

Ai_Dev/
├── backend/
│   ├── controllers/      # Request handlers
│   ├── models/          # Database models
│   ├── routes/          # API routes
│   ├── services/        # Business logic
│   ├── middleware/      # Auth, validation, rate limiting
│   ├── db/             # Database connection
│   ├── server.js       # Socket.IO server
│   └── app.js          # Express app
├── frontend/
│   ├── src/
│   │   ├── components/  # Reusable components
│   │   ├── screens/     # Page components
│   │   ├── context/     # React context
│   │   ├── config/      # Configuration files
│   │   ├── routes/      # Route definitions
│   │   └── auth/        # Authentication guards
│   └── public/
└── README.md

🚦 API Endpoints

Authentication

  • POST /users/register - Register new user
  • POST /users/login - Login user
  • GET /users/logout - Logout user
  • GET /users/profile - Get user profile
  • GET /users/all - Get all users

Projects

  • POST /projects/create - Create new project
  • GET /projects/all - Get user's projects
  • GET /projects/get-project/:id - Get project by ID
  • PUT /projects/add-user - Add collaborators
  • PUT /projects/update-file-tree - Update project files
  • POST /projects/add-message - Add message (deprecated - use socket)

AI

  • Socket event: project-message with @ai prefix triggers analysis

🎨 Theme

SecCollab uses a dark terminal aesthetic with green accents:

  • Background: #050805, #0a0f0a, #0d140d
  • Primary text: #d1f7c4
  • Accent: #7CFFA1
  • Borders: #133113
  • Interactive: #0f3d0f, #145214

🤝 Contributing

Contributions are welcome! Please follow these steps:

  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 ISC License.

👨‍💻 Author

Vashu

🙏 Acknowledgments

  • Google Gemini AI for security analysis capabilities
  • WebContainer team for in-browser Node.js runtime
  • The open-source community for amazing tools and libraries

📞 Support

For issues, questions, or suggestions, please open an issue on the GitHub repository.


Built with ❤️ for secure collaborative development

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages