Skip to content

naim1405/visionguard

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

VisionGuard.ai 🛡️

An AI-powered theft detection and security monitoring system with real-time video processing

Next.js FastAPI TypeScript Python


📋 Table of Contents


🎯 Overview

VisionGuard.ai is a comprehensive security monitoring solution that combines cutting-edge AI technology with real-time video processing to detect suspicious activities and potential theft. The system features a modern web interface for monitoring multiple camera feeds, reviewing alerts, and managing security across multiple shop locations.

Key Capabilities

  • Real-time AI Detection: Process video feeds in real-time using advanced AI models for anomaly detection
  • WebRTC Streaming: Low-latency video streaming directly to web browsers
  • Multi-shop Management: Support for multiple locations with role-based access control
  • Telegram Integration: Instant notifications and remote monitoring via Telegram bot
  • Persistent WebSocket Connections: Real-time alerts with automatic reconnection and heartbeat monitoring
  • Authentication & Authorization: Secure JWT-based authentication with owner and manager roles

✨ Features

Frontend Features

  • 📊 Real-time Dashboard - Monitor system metrics, active cameras, and detection accuracy
  • 📹 Live Feed - WebRTC camera streaming with AI processing
  • 🚨 Suspicious Activity - Review, filter, and manage detected security events
  • 🏪 Shop Management - Multi-location support with shop-specific configurations
  • 🔔 Real-time Notifications - Instant alerts via WebSocket connections
  • 🎨 Modern UI - Dark/light theme with gradient accents and smooth animations
  • 📱 Responsive Design - Seamless experience across desktop, tablet, and mobile
  • 🔐 Secure Authentication - JWT-based auth with role-based access control

Backend Features

  • AI Video Processing - Real-time frame processing with configurable AI models
  • WebRTC Signaling - SDP offer/answer exchange for peer connections
  • WebSocket Support - Persistent connections for real-time notifications
  • Telegram Bot - Bi-directional communication and remote control
  • Database Management - PostgreSQL with Alembic migrations
  • RESTful API - OpenAPI 3.0 compliant endpoints
  • CORS Support - Configurable cross-origin resource sharing
  • Health Monitoring - Connection tracking and health check endpoints
  • Training Data Collection - Reinforcement learning data storage

🏗️ Architecture

┌─────────────────────────────────────────────────────────────────────┐
│                         VisionGuard.ai System                        │
└─────────────────────────────────────────────────────────────────────┘

┌──────────────────┐                                 ┌──────────────────┐
│  Next.js Client  │                                 │  FastAPI Backend │
│    (Frontend)    │                                 │    (Python)      │
│                  │         WebRTC Video            │                  │
│  ┌────────────┐  │◄────────(Encrypted)────────────┤  ┌────────────┐  │
│  │  Live Feed │  │                                 │  │  Signaling │  │
│  │   (WebRTC) │  │                                 │  │   Router   │  │
│  └────────────┘  │         WebSocket               │  └────────────┘  │
│                  │◄──────(Notifications)───────────┤                  │
│  ┌────────────┐  │                                 │  ┌────────────┐  │
│  │ Dashboard  │  │         REST API                │  │ AI Stream  │  │
│  │  & Alerts  │  │◄──────(JSON Data)──────────────┤  │   Track    │  │
│  └────────────┘  │                                 │  └──────┬─────┘  │
│                  │                                 │         │        │
│  ┌────────────┐  │                                 │  ┌──────▼─────┐  │
│  │   Auth &   │  │                                 │  │    AI      │  │
│  │   Shops    │  │                                 │  │ Processor  │  │
│  └────────────┘  │                                 │  └──────┬─────┘  │
└──────────────────┘                                 │         │        │
                                                     │  ┌──────▼─────┐  │
┌──────────────────┐                                 │  │ PostgreSQL │  │
│  Telegram Bot    │◄────────(Polling)───────────────┤  │  Database  │  │
│  (Notifications) │                                 │  └────────────┘  │
└──────────────────┘                                 └──────────────────┘

🛠️ Tech Stack

Frontend

  • Framework: Next.js 14 (App Router)
  • Language: TypeScript
  • Styling: Tailwind CSS
  • Charts: Recharts
  • Icons: Lucide React
  • Animations: Framer Motion
  • AI Models: TensorFlow.js with COCO-SSD
  • HTTP Client: Axios
  • State Management: React Context API

Backend

  • Framework: FastAPI 0.121.0
  • Language: Python 3.8+
  • WebRTC: aiortc 1.14.0
  • Video Processing: OpenCV, PyAV
  • AI/ML: TensorFlow 2.x, Keras
  • Database: PostgreSQL with Alembic migrations
  • Authentication: JWT (PyJWT)
  • Real-time: WebSockets
  • Telegram: python-telegram-bot
  • CORS: FastAPI CORS middleware

📦 Prerequisites

System Requirements

  • Node.js: 18+
  • Python: 3.8 or higher
  • PostgreSQL: 13+
  • FFmpeg: Required for video processing
  • Git: For version control

Optional

  • Telegram Bot Token: For notification features
  • CUDA: For GPU-accelerated AI processing (optional)

🚀 Installation

1. Clone the Repository

git clone <repository-url>
cd visionguard

2. Setup Backend & Frontend

For detailed installation instructions:


⚙️ Configuration

For detailed configuration instructions:


🏃‍♂️ Running the Application

Quick Start

Backend: cd backend-visionguard-ai && python main.pyhttp://localhost:8000
Frontend: cd visionguardai-frontend && npm run devhttp://localhost:3000

For detailed instructions including Telegram bot setup and production deployment:


📁 Project Structure

visionguard/
├── backend-visionguard-ai/         # Python FastAPI Backend
│   ├── app/                        # Application code
│   │   ├── ai/                     # AI models and processors
│   │   ├── api/                    # API endpoints
│   │   ├── core/                   # Core utilities
│   │   ├── db/                     # Database configuration
│   │   ├── models/                 # SQLAlchemy models
│   │   └── schemas/                # Pydantic schemas
│   ├── docs/                       # Backend documentation
│   ├── main.py                     # Application entry point
│   └── README.md                   # Backend documentation
│
├── visionguardai-frontend/         # Next.js Frontend
│   ├── app/                        # Next.js app directory
│   ├── components/                 # React components
│   ├── context/                    # React contexts
│   ├── hooks/                      # Custom hooks
│   ├── lib/                        # API and services
│   └── README.md                   # Frontend documentation
│
└── README.md                       # This file

For detailed project structure:


📚 API Documentation

Once the backend is running, visit:

For detailed API endpoint documentation, see:


🔐 Authentication & Authorization

VisionGuard uses JWT-based authentication with role-based access control:

Roles

  • OWNER: Full access to all features, can manage shops and users
  • MANAGER: Limited access to shop management and monitoring

Token Flow

  1. User logs in with credentials
  2. Server returns access token (30 min) and refresh token
  3. Access token is sent with each API request
  4. Refresh token is used to get new access token when expired

🔔 Real-time Features

WebSocket Notifications

  • Persistent connection with exponential backoff reconnection
  • Heartbeat mechanism (30s ping/pong)
  • Automatic stale connection cleanup
  • Real-time anomaly alerts

WebRTC Video Streaming

  • Low-latency peer-to-peer video streaming
  • STUN server configuration for NAT traversal
  • Automatic connection management
  • Frame-by-frame AI processing

📱 Telegram Integration

The system includes a Telegram bot for remote monitoring:

  • Receive instant alerts for detected anomalies
  • View camera snapshots
  • Check system status
  • Remote shop management

🧪 Testing

For testing instructions, see:


📖 Additional Documentation

For more detailed information, see:

About

AI powered shop lifting detection

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors