How nhipixel/comparavision-integration works
Project Type and Purpose
• This is a full-stack web application (“ComparaVision”) for benchmarking and comparing vision models (YOLO, EfficientNet, Detectron2, etc.) on accuracy, speed, memory, and environmental impact.
• The frontend is built with Next.js/React/TypeScript; the backend uses Node.js/Express; data is stored in Supabase (PostgreSQL); heavy AI workloads run on RunPod GPU containers and a Python “Vellum” integration.
File Structure
• Top-level:
• frontend/ — Next.js app with pages, API routes, React components, hooks, Tailwind CSS
• backend/ — Express server, local-server UI, Supabase setup, RunPod integration, Vellum Python module
• docker-compose.yml, deploy scripts (deploy.sh/.bat), root package.json
• backend/runpod/ contains Dockerfiles, worker scripts (vision_benchmark_worker.py, enhanced_vision_benchmark_worker.py), integration helpers, and helper-docs describing architecture.
• backend/vellum/ is a standalone Python package that implements additional AI capabilities.
README for Architecture Insights
• External services: RunPod (GPU compute), Supabase for real-time DB and authentication.
Main Components & Interactions
a. Frontend
• Next.js pages for upload, compare, dashboard, stats; React components + custom hooks.
• Communicates via REST/Fetch to Backend API at http://localhost:3001 (or Next.js API routes if proxied).
b. Backend API Server
• Express.js routes under backend/server.js (e.g., /api/models, /api/comparisons, /api/auth).
• Handles authentication (Supabase), model uploads, triggers RunPod jobs.
c. Supabase (PostgreSQL + Auth + Real-time)
• Stores user profiles, model metadata, comparison results.
• Backend uses backend/setup-database.js, supabase-schema.sql, seeds, and initSupabase.js.
• Frontend access via supabase.js library for real-time updates.
d. RunPod AI Processing
• Node.js integration (backend/runpod/runpod_integration.js & backend/runpod/backend_api_integration.js).
• Python workers (benchmark, validation, vision_benchmark_worker.py) run inside Docker containers.
• Workers load specified vision model, run benchmarks, measure metrics (accuracy, FPS, memory, CO2), and return results via API callback.
e. Vellum Integration
• Python package under backend/vellum/ invoked for complementary AI tasks or summarization.
f. Local Server Component (for testing/demo)
• backend/local-server.js with React dashboard components under backend/src/components/LocalServerDashboard.jsx.
• Hooks under backend/src/hooks pull real-time data.
g. Deployment & Orchestration
• docker-compose.yml orchestrates frontend, backend, Supabase (if self-hosted), and optionally worker containers.
• deploy.sh/.bat scripts build images and start services.
Architectural Patterns & Design Principles
• Separation of concerns: Frontend UI, Backend API, Database, AI compute are distinct.
• API-driven: REST endpoints for all operations, decoupling UI from compute.
• Containerization: Docker for consistent environments across local, dev, prod.
• Event-driven / real-time: Supabase real-time DB pushes updates to frontend.
• Polyglot: JavaScript/TypeScript for web layers; Python for heavy AI workloads.
1. Sketch a high-level flow: User → Frontend → Backend → (Supabase & RunPod) → Backend → Frontend.
• Frontend: pages, components, hooks
• Backend: auth, model management, comparison service
• AI Layer: Python + GPU container pool
3. Data stores: Supabase with tables for organizations, models, comparisons, results.
4. Environment variables/config (e.g., RUNPOD_API_KEY, SUPABASE_URL).