Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

5 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸŽ₯ Trace β€” Agentic CCTV Indexing Engine

Watch Demo

An intelligent video search platform built with Replit Agent during Ship it Hacks 2026. Upload surveillance footage, let AI automatically index every frame, then search for anything using natural language.

Find anything in any footage. Search across hours of video in seconds. Just describe what you're looking for.

✨ Core Features

  • πŸš€ One-Click Video Upload β€” Upload .mp4 or .mov files and let the indexing begin
  • 🧠 Intelligent Frame Analysis β€” Automatically extracts frames every 2 seconds and analyzes each with GPT-5 vision
  • πŸ” Semantic Search β€” Find exactly what you're looking for using natural language (e.g., "person wearing red shirt", "suspicious activity")
  • ⚑ Real-Time Indexing Progress β€” Watch the AI analyze your videos in real-time
  • πŸ“Š Dashboard β€” Manage videos, view indexing stats, and search history

πŸ—οΈ Architecture

Video Indexing Pipeline

  1. Upload β†’ User uploads video to cloud storage (GCS) via presigned URL
  2. Extract β†’ Backend downloads and splits video into frames (every 2 seconds)
  3. Analyze β†’ Each frame sent to GPT-5-mini vision model for semantic description
  4. Store β†’ Frame descriptions indexed in PostgreSQL for fast retrieval
  5. Search β†’ User queries matched against frame database using semantic matching

Natural Language Search

  • Query the entire database or search within specific videos
  • GPT-5-mini semantically matches user queries against stored frame descriptions
  • Results ranked by relevance with match explanations
  • Includes timestamp and thumbnail preview

πŸ› οΈ Tech Stack

Layer Technology
Frontend React 19 + Vite + TailwindCSS + shadcn/ui
Backend Express 5 + TypeScript
Database PostgreSQL + Drizzle ORM
AI/Vision OpenAI GPT-5-mini via Replit AI Integrations
Storage GCS via Replit Object Storage
Video Processing ffmpeg
Monorepo pnpm workspaces
Build esbuild

πŸ“¦ Project Structure

trace/
β”œβ”€β”€ artifacts/
β”‚   β”œβ”€β”€ api-server/          # Express backend (REST API)
β”‚   β”œβ”€β”€ cctv-search/         # React + Vite frontend
β”‚   └── mockup-sandbox/      # Component preview sandbox
β”œβ”€β”€ lib/
β”‚   β”œβ”€β”€ api-spec/            # OpenAPI specification
β”‚   β”œβ”€β”€ api-zod/             # Zod validation schemas
β”‚   β”œβ”€β”€ api-client-react/    # Generated API client hooks
β”‚   β”œβ”€β”€ db/                  # Database schema & migrations
β”‚   └── integrations-openai-ai-*/ # AI integration packages
└── scripts/                 # Utilities

πŸš€ Quick Start

Prerequisites

  • Node.js 24+
  • pnpm (package manager)
  • PostgreSQL database
  • GCS bucket for video storage
  • OpenAI API key (via Replit AI Integrations)

Setup

# Install dependencies
pnpm install

# Setup environment variables
cp .env.example .env
# Edit .env with your database, storage, and API credentials

# Run database migrations
pnpm --filter @workspace/db run push

# Start development servers
# Terminal 1 - API server
pnpm --filter @workspace/api-server run dev

# Terminal 2 - Frontend
pnpm --filter @workspace/cctv-search run dev

Build & Deploy

# Full typecheck and build
pnpm run build

# Regenerate API client from OpenAPI spec
pnpm --filter @workspace/api-spec run codegen

πŸ”Œ API Endpoints

Method Endpoint Description
GET /api/videos List all uploaded videos
POST /api/videos Upload new video
GET /api/videos/:id Get video details
POST /api/videos/:id/index Start indexing process
GET /api/videos/:id/index-status Check indexing progress
POST /api/search Semantic search across frames
GET /api/search/history View search history

πŸ“‹ Database Schema

Videos Table

  • id β€” Unique identifier
  • name β€” Video filename
  • objectPath β€” GCS storage path
  • status β€” pending | indexing | indexed | error
  • totalFrames β€” Extracted frame count
  • indexedFrames β€” Analyzed frame count
  • durationSeconds β€” Video length
  • errorMessage β€” Error details (if failed)

Frames Table

  • id β€” Unique identifier
  • videoId β€” Reference to video
  • timestampSeconds β€” Frame position in video
  • objectPath β€” GCS storage path of frame image
  • description β€” AI-generated frame description

Search History Table

  • Tracks user search queries and results

πŸŽ“ How It Works

  1. Upload a video β†’ Creates pending video record
  2. Trigger indexing β†’ Background job starts processing
  3. Frame extraction β†’ ffmpeg splits video into snapshots
  4. AI analysis β†’ Each frame analyzed with GPT-5-mini vision model
  5. Storage β†’ Frame descriptions saved to database
  6. Search β†’ Submit natural language query β†’ semantic matching β†’ ranked results with timestamps

Example search flow:

Query: "person wearing red jacket"
     ↓
GPT-5-mini compares against 1000+ frame descriptions
     ↓
Returns top 10 matching frames with timestamps
     ↓
Click result β†’ Jump to video at exact timestamp

πŸ† Hackathon Context

Built during Ship it Hacks 2026 using the Replit Agent platform. This project demonstrates:

  • Full-stack agentic development with AI-driven architecture
  • Seamless integration of vision AI (GPT-5) with web applications
  • Real-time processing and semantic search capabilities
  • Production-ready TypeScript monorepo patterns

πŸ” Security & Privacy

  • Videos stored in private GCS buckets
  • Database uses authenticated PostgreSQL connections
  • API-key protected endpoints
  • Frame processing happens server-side (no client-side video processing)
  • Search queries logged to database for analytics

πŸ“ Environment Variables

# Database
DATABASE_URL=postgresql://...
PGHOST=...
PGUSER=...
PGPASSWORD=...

# AI Integration
AI_INTEGRATIONS_OPENAI_BASE_URL=https://...
AI_INTEGRATIONS_OPENAI_API_KEY=...

# Object Storage
DEFAULT_OBJECT_STORAGE_BUCKET_ID=...
PRIVATE_OBJECT_DIR=videos/
PUBLIC_OBJECT_SEARCH_PATHS=frames/

# Server
PORT=3000
BASE_PATH=/
SESSION_SECRET=...

🀝 Contributing

This is a hackathon project. Feel free to fork and extend!

πŸ“œ License

MIT


Trace β€” Because every frame tells a story. Make them searchable.

About

Agentic CCTV Indexing and Search Engine | πŸ₯ˆ 2nd Place @ Ship It Hacks '26 (powered by Replit)

Resources

Stars

2 stars

Watchers

0 watching

Forks

Contributors

Languages