YashashviAlva's picture
Initial commit for HF Spaces deploy
7b4f5dd
## πŸ›‘οΈ CodeSentry Frontend β€” AI Security Copilot
> AMD Developer Hackathon 2026 β€” Track 1: AI Agents & Agentic Workflows
**CodeSentry** is an enterprise-grade AI security intelligence platform. Built for the modern agentic workflow, it orchestrates multiple specialized AI agents to scan, analyze, and remediate security threats in real-time.
---
## ⚑ Why CodeSentry?
In an era of AI-generated code, vulnerabilities move faster than human reviewers. CodeSentry provides:
- **Agentic Intelligence**: Not just a static scanner. Three specialized agents (Security, Performance, Fix) reason over your code like a senior security team.
- **Cinematic Experience**: A futuristic SOC-style dashboard designed for high-stakes security monitoring.
- **AMD MI300X Live Metrics**: Real-time hardware telemetry (GPU Util, VRAM, Temp, Power, Bandwidth) streamed directly to the dashboard.
- **CUDA β†’ ROCm Migration Advisor**: Scans code for CUDA-specific patterns and provides actionable ROCm migration guidance with an AMD Compatibility Score.
- **Privacy-First**: Optimized for the AMD ecosystem, ensuring high-performance local inference. Your proprietary code never leaves your network.
- **Instant Remediation**: Don't just find bugsβ€”fix them. Get PR-ready patches in seconds.
---
## ✨ Demo Flow
1. **Clone** this repo
2. **Run** `npm install && npm run dev`
3. **Open** `http://localhost:5173`
4. **Click** "Launch Security Scan" β€” demo runs in mock mode with no backend needed. You will see simulated AMD metrics and migration findings!
---
## πŸ—οΈ Architecture
```
Frontend (Vite + React) Backend (FastAPI + Python)
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Landing Page β”‚ β”‚ POST /api/scan β”‚
β”‚ Analysis View ───┼─SSE──│ GET /api/scan/stream β”‚
β”‚ Report Page β”‚ β”‚ β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ Security Agent β”‚
β”‚ Performance Agent β”‚
β”‚ AMD Migration Advisor β”‚
β”‚ Fix Agent β”‚
β”‚ AMD Metrics Collector β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
```
## πŸ€– AI Agents & Tools
| Component | Responsibilities | Output |
|-----------|-----------------|--------|
| **Security Agent** | SQL injection, hardcoded secrets, unsafe eval, pickle deserialization, weak hashing | CWE-mapped findings with severity |
| **Performance Agent** | N+1 queries, memory leaks, GPU inefficiencies, FP32 waste | Optimization suggestions |
| **Fix Agent** | Generates before/after patches for all fixable findings | Downloadable diffs |
| **AMD Migration Advisor** | Detects CUDA APIs (nvidia-smi, cudnn, etc) | Compatibility score + ROCm fixes |
| **AMD Metrics Collector**| Polls `rocm-smi` every 2s for hardware stats | Real-time GPU telemetry |
---
## πŸš€ Quick Start
### Frontend Only (Mock Mode β€” demo-safe)
```bash
npm install
npm run dev
# Open http://localhost:5173
# VITE_MOCK_MODE=true by default
```
### Full Stack (Frontend + Backend)
```bash
# Terminal 1 β€” Frontend
npm install && npm run dev
# Terminal 2 β€” Backend
cd backend
pip install -r requirements.txt
uvicorn main:app --reload --port 8000
# Then set in .env:
# VITE_MOCK_MODE=false
```
---
## πŸ”§ Environment Variables
| Variable | Default | Description |
|----------|---------|-------------|
| `VITE_MOCK_MODE` | `true` | Use mock data (no backend needed) |
| `VITE_API_URL` | `http://localhost:8000` | Backend API URL |
---
## πŸ”’ Privacy-First Design
- **Zero data retention** β€” no code stored after session
- **Local inference** β€” all analysis on-device via vLLM
- **No external API calls** β€” code never leaves your machine
- **Session data wiped** on completion
- **Cryptographic Audit** β€” signed ZDR certificates generated
---
## 🎨 Tech Stack
| Layer | Technology |
|-------|-----------|
| Frontend | Vite + React 18 |
| Styling | Vanilla CSS with custom design system (`index.css`) |
| Charts | Chart.js + react-chartjs-2 |
| Fonts | Syne (headings) + JetBrains Mono (code) |
| Streaming | Server-Sent Events (SSE) |
---
## πŸ“ Project Structure
```
codesentry-frontend/
β”œβ”€β”€ src/
β”‚ β”œβ”€β”€ components/
β”‚ β”‚ β”œβ”€β”€ LandingPage.jsx # Hero + inputs
β”‚ β”‚ β”œβ”€β”€ AnalysisView.jsx # Live analysis split-panel
β”‚ β”‚ β”œβ”€β”€ ReportView.jsx # Full report + exports
β”‚ β”‚ β”œβ”€β”€ AgentCard.jsx # Agent status card
β”‚ β”‚ β”œβ”€β”€ FindingCard.jsx # Expandable finding
β”‚ β”‚ β”œβ”€β”€ SeverityBadge.jsx # Severity indicator
β”‚ β”‚ β”œβ”€β”€ SeverityChart.jsx # Donut chart
β”‚ β”‚ β”œβ”€β”€ PrivacyCertificate.jsx
β”‚ β”‚ β”œβ”€β”€ AMDMetricsCard.jsx # Live GPU telemetry card
β”‚ β”‚ β”œβ”€β”€ AMDMigrationPanel.jsx # ROCm compatibility report
β”‚ β”‚ └── ParticleBackground.jsx
β”‚ β”œβ”€β”€ context/
β”‚ β”‚ └── ScanContext.jsx # Global state + SSE reducers
β”‚ β”œβ”€β”€ services/
β”‚ β”‚ β”œβ”€β”€ scanService.js # SSE client
β”‚ β”‚ └── mockService.js # Mock replay engine (simulates AMD data)
β”‚ └── index.css # Cyberpunk design system
β”œβ”€β”€ public/
β”‚ β”œβ”€β”€ mock_analysis.json # Demo data payload
β”‚ └── background.png # Cyberpunk UI background
└── .env # Environment config
```