Skip to content
Mihir-RabariPublic

About

AI-Powered Supply Chain Threat Detection Platform

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

Β 

History

7 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ• CodeDog

AI-Powered Supply Chain Threat Detection Platform

AI Powered Real Time Security First

Node.js React Docker Ollama MongoDB Socket.IO


πŸš€ A cutting-edge full-stack application that analyzes GitHub repositories for security threats in real-time using local AI models and advanced threat detection algorithms

✨ Features

🧠 AI-Powered Analysis

  • Local LLM integration with Ollama
  • DeepSeek-R1 model for threat detection
  • Intelligent commit analysis
  • Automated vulnerability assessment

⚑ Real-Time Monitoring

  • Live log streaming via WebSocket
  • Instant threat alerts
  • Progress tracking
  • Dynamic dashboard updates

πŸ›‘οΈ Advanced Security

  • Docker container sandboxing
  • Network isolation
  • Resource limitations
  • Input sanitization

🎨 Modern Interface

  • Beautiful dark mode UI
  • Responsive design
  • Interactive analytics
  • Professional dashboards

πŸ—οΈ System Architecture

graph TB
    subgraph "Frontend Layer"
        A[React Dashboard] --> B[Socket.IO Client]
        A --> C[REST API Client]
    end
    
    subgraph "Backend Layer"
        D[Express Server] --> E[Socket.IO Server]
        D --> F[Analysis Engine]
        D --> G[AI Service]
    end
    
    subgraph "AI Layer"
        G --> H[Ollama Server]
        H --> I[DeepSeek-R1 Model]
    end
    
    subgraph "Data Layer"
        F --> J[MongoDB]
        F --> K[Job Queue]
    end
    
    subgraph "Security Layer"
        F --> L[Docker Engine]
        L --> M[Node.js Container]
        L --> N[Python Container]
    end
    
    B -.->|WebSocket| E
    C -.->|HTTP/REST| D
    
    style A fill:#61dafb,stroke:#000,color:#000
    style D fill:#339933,stroke:#000,color:#fff
    style H fill:#ff6b35,stroke:#000,color:#fff
    style J fill:#47a248,stroke:#000,color:#fff
    style L fill:#2496ed,stroke:#000,color:#fff
Loading

πŸš€ Quick Start

πŸ“‹ Prerequisites


Node.js 18+

Docker Desktop

Git

Ollama

πŸ› οΈ Installation

πŸ”§ Step-by-Step Setup Guide

1️⃣ Clone the Repository

git clone https://github.com/Mihir-Rabari/code-dog.git
cd code-dog

2️⃣ Setup Ollama & AI Model

# Install Ollama (if not already installed)
curl -fsSL https://ollama.ai/install.sh | sh

# Pull the DeepSeek-R1 model
ollama pull deepseek-r1:1.5b

# Verify installation
ollama list

3️⃣ Backend Setup

cd backend
npm install

# Create environment file
cp .env.example .env
# Edit .env with your configurations

4️⃣ Frontend Setup

cd ../frontend
npm install

# Create environment file
cp .env.example .env

5️⃣ Docker Images

cd ../docker
docker build -f Dockerfile.node -t threat-detector:node .
docker build -f Dockerfile.python -t threat-detector:python .

6️⃣ Database Setup

# Start MongoDB (using Docker)
docker run -d -p 27017:27017 --name codedog-mongo mongo:latest

# Or use MongoDB Atlas (cloud)
# Update your .env file with connection string

πŸƒβ€β™‚οΈ Running the Application

Backend Server

cd backend
npm run dev

Server runs on http://localhost:5000

Frontend Dashboard

cd frontend
npm run dev

Dashboard runs on http://localhost:3000

🎯 Quick Test

# Health check
curl http://localhost:5000/health

# Open dashboard
open http://localhost:3000

πŸ“Š How It Works

sequenceDiagram
    participant U as πŸ‘€ User
    participant F as πŸ–₯️ Frontend
    participant B as βš™οΈ Backend
    participant A as 🧠 AI Service
    participant D as 🐳 Docker
    participant DB as πŸ—„οΈ Database

    U->>F: Enter GitHub URL
    F->>B: POST /api/analyze-repo
    B->>DB: Create job record
    B->>D: Start sandbox container
    D->>D: Clone repository
    D->>D: Analyze dependencies
    D->>A: Send code for AI analysis
    A->>A: Process with DeepSeek-R1
    A->>B: Return threat assessment
    B->>F: WebSocket: Real-time logs
    B->>F: WebSocket: Risk score
    F->>U: Display results
Loading

🎯 Usage Workflow

Step Action Description
1️⃣ Input Enter GitHub repository URL
2️⃣ Configure Select project type (Node.js/Python)
3️⃣ Analyze Click "Start Analysis" button
4️⃣ Monitor Watch real-time logs and progress
5️⃣ Review Examine risk score and threats
6️⃣ Export Download detailed security report

πŸ›‘οΈ Security Architecture

πŸ”’ Container Isolation

  • Sandboxed Docker environments
  • No network access during analysis
  • Resource limits (CPU/Memory)
  • Temporary filesystem

πŸ› οΈ Input Validation

  • URL format verification
  • Repository accessibility checks
  • Malicious payload detection
  • Rate limiting protection

πŸ” Threat Detection

  • Suspicious commit patterns
  • Dependency vulnerabilities
  • Typosquatting detection
  • Runtime behavior analysis

πŸ“Š Risk Assessment

  • 0-100 risk scoring system
  • Severity categorization
  • Confidence metrics
  • Actionable recommendations

πŸ§ͺ Testing & Quality Assurance

πŸ”¬ Test Suite Overview

Backend Testing

cd backend
npm test                    # Run all tests
npm run test:unit          # Unit tests only
npm run test:integration   # Integration tests
npm run test:coverage      # Coverage report

Frontend Testing

cd frontend
npm test                   # Jest + React Testing Library
npm run test:e2e          # Cypress end-to-end tests
npm run test:coverage     # Coverage report

Docker Testing

# Test container builds
docker-compose -f docker-compose.test.yml up --build

# Security scan
docker scout cves threat-detector:node

πŸ“š API Documentation

πŸ”— REST API Endpoints

Method Endpoint Description Parameters
POST /api/analyze-repo Start repository analysis repoUrl, projectType
GET /api/job/:jobId/status Get job status jobId
GET /api/job/:jobId/details Get detailed job info jobId
GET /api/jobs List all jobs limit (optional)
GET /health Health check -

πŸ”Œ WebSocket Events

Incoming Events

  • join - Join job room
  • disconnect - Leave room

Outgoing Events

  • log - Real-time analysis logs
  • alert - Security threat alerts
  • progress - Analysis progress
  • done - Final summary

πŸ“‹ Request/Response Examples

πŸ” API Examples

Start Analysis

curl -X POST http://localhost:5000/api/analyze-repo \
  -H "Content-Type: application/json" \
  -d '{
    "repoUrl": "https://github.com/user/repo",
    "projectType": "nodejs"
  }'

Response

{
  "jobId": "job_1234567890_abc123",
  "status": "running",
  "message": "Analysis started successfully"
}

Get Job Status

curl http://localhost:5000/api/job/job_1234567890_abc123/status

WebSocket Connection

const socket = io('http://localhost:5000');
socket.emit('join', 'job_1234567890_abc123');
socket.on('log', (data) => console.log(data));

🎬 Demo & Presentation

πŸš€ Perfect for Hackathons!

🎯 Demo Script

  1. Setup - Show the sleek dashboard
  2. Input - Enter a suspicious repo URL
  3. Real-time - Watch live log streaming
  4. AI Analysis - Highlight AI-powered detection
  5. Results - Present risk score & threats
  6. Export - Download security report

πŸ† Key Selling Points

  • ⚑ Real-time analysis
  • 🧠 Local AI (no API costs)
  • πŸ›‘οΈ Advanced security
  • 🎨 Beautiful dark UI
  • πŸ“Š Professional reports
  • 🐳 Docker sandboxing

🌟 Showcase

πŸ“Έ Screenshots

Coming soon - Add your amazing dashboard screenshots here!

πŸŽ₯ Demo Video

Add a link to your demo video here

Demo Video

🀝 Contributing

We welcome contributions from the community!

Contributors Issues Pull Requests

πŸ› οΈ Development Setup

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests
  5. Submit a pull request

πŸ“ Code Style

  • ESLint + Prettier for JavaScript
  • Follow existing patterns
  • Add JSDoc comments
  • Write meaningful commit messages

πŸ“„ License

MIT License - see LICENSE file for details


Made with Love Built for Hackathons Powered by AI

⭐ Star this repo if you found it helpful!

About

AI-Powered Supply Chain Threat Detection Platform

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages