Skip to content

YADUNANDAN-SINGH/GlassBox-Rust-SVD-recommendation-system

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

7 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ”ฎ GlassBox

See Through The Algorithm.

No Tracking. No Servers. Just Math.


Rust Leptos SurrealDB WebAssembly Docker


Every recommendation you see on Netflix, YouTube, or Spotify is decided by a black-box algorithm running on their servers, trained on your data, sold to advertisers.

GlassBox is the antithesis. A fully transparent, privacy-first recommendation engine that runs entirely in your browser. The algorithm is open. The data is yours. The math is all you need.


โœจ Key Features

Feature Description
๐Ÿ”’ Zero-Knowledge Architecture Your watch history, preferences, and interactions never leave your device. Data is stored in an embedded SurrealDB instance running inside your browser via IndexedDB. No servers. No telemetry. No exceptions.
๐Ÿง  Client-Side SVD Engine Recommendations are powered by a Singular Value Decomposition (SVD) algorithm compiled to WebAssembly. The linear algebra runs at near-native speed, directly in the browser โ€” no API calls to a recommendation server.
๐Ÿ” Universal Search Search the entire TVMaze catalog of movies and shows. Results are fetched from the open TVMaze API (no authentication required), and every interaction feeds back into your local recommendation model.
โšก Rust + WASM Performance Built with Leptos and compiled to WebAssembly. The entire application โ€” UI, routing, database, and AI โ€” ships as a single static bundle. No JavaScript frameworks. No runtime overhead.

๐ŸŽฌ Demo

๐Ÿ”‘ Login & Signup

Create an account and sign in โ€” all credentials are hashed and stored locally in the browser. No server ever sees your password.

Login and Signup Demo

๐Ÿง  Search & SVD Recommendations

Search for movies, save them to your library, and watch the SVD engine build your personalized feed in real-time โ€” entirely client-side.

Search and Recommendation Engine Demo

๐Ÿ—๏ธ Architecture

GlassBox replaces opaque server-side recommendation pipelines with a transparent, client-side algorithm:

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                        YOUR BROWSER                             โ”‚
โ”‚                                                                 โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”‚
โ”‚  โ”‚ TVMaze   โ”‚โ”€โ”€โ”€โ–ถโ”‚ Vectorizationโ”‚โ”€โ”€โ”€โ–ถโ”‚  User Profile (SVD)   โ”‚  โ”‚
โ”‚  โ”‚   API    โ”‚    โ”‚  (19-dim     โ”‚    โ”‚  Weighted genre vector โ”‚  โ”‚
โ”‚  โ”‚ (Search) โ”‚    โ”‚  genre vec)  โ”‚    โ”‚  from watch history   โ”‚  โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ”‚
โ”‚                                                  โ”‚              โ”‚
โ”‚                                                  โ–ผ              โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”‚
โ”‚  โ”‚ Ranked   โ”‚โ—€โ”€โ”€โ”€โ”‚   Scoring    โ”‚โ—€โ”€โ”€โ”€โ”‚  Candidate Filtering  โ”‚  โ”‚
โ”‚  โ”‚   Feed   โ”‚    โ”‚  (Dot Prod)  โ”‚    โ”‚  (Remove watched)     โ”‚  โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ”‚
โ”‚                                                                 โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”   โ”‚
โ”‚  โ”‚           SurrealDB (IndexedDB / In-Browser)             โ”‚   โ”‚
โ”‚  โ”‚           โ”€ Watch History โ”€ User Sessions โ”€              โ”‚   โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜   โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                    โ–ฒ
                    โ”‚  NOTHING leaves this box.

How Recommendations Work

  1. Vectorization โ€” Each movie is converted into a 19-dimensional genre vector (Action, Drama, Sci-Fi, etc.)
  2. User Profiling โ€” Your watch history is aggregated into a weighted user preference vector, scaled by ratings
  3. Scoring โ€” Candidate movies are scored via dot product against your user vector
  4. Ranking โ€” Results are sorted by score, filtered against already-watched titles, and displayed

๐Ÿ“ Project Structure

glassbox/
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ main.rs              # App entry point, router, DB init
โ”‚   โ”œโ”€โ”€ api/                  # TVMaze API integration
โ”‚   โ”‚   โ””โ”€โ”€ search.rs        # Video search via TVMaze
โ”‚   โ”œโ”€โ”€ model/               # Core engine
โ”‚   โ”‚   โ”œโ”€โ”€ svd.rs           # โญ SVD recommendation algorithm
โ”‚   โ”‚   โ”œโ”€โ”€ video.rs         # Video data model + DB persistence
โ”‚   โ”‚   โ”œโ”€โ”€ db.rs            # SurrealDB (IndexedDB) initialization
โ”‚   โ”‚   โ”œโ”€โ”€ session.rs       # Client-side session management
โ”‚   โ”‚   โ”œโ”€โ”€ users.rs         # Local user management
โ”‚   โ”‚   โ””โ”€โ”€ history.rs       # Watch history tracking
โ”‚   โ”œโ”€โ”€ components/          # Reusable UI components
โ”‚   โ”‚   โ”œโ”€โ”€ feed.rs          # Recommendation feed (uses SVD)
โ”‚   โ”‚   โ”œโ”€โ”€ search.rs        # Search interface
โ”‚   โ”‚   โ””โ”€โ”€ movie_modal.rs   # Movie detail view
โ”‚   โ”œโ”€โ”€ pages/               # Route-level pages
โ”‚   โ”‚   โ”œโ”€โ”€ home.rs          # Home page
โ”‚   โ”‚   โ”œโ”€โ”€ login.rs         # Login page
โ”‚   โ”‚   โ””โ”€โ”€ signup.rs        # Registration page
โ”‚   โ”œโ”€โ”€ cards/               # Card components
โ”‚   โ””โ”€โ”€ navbar/              # Navigation bar
โ”œโ”€โ”€ assets/                   # CSS, JS, favicon
โ”œโ”€โ”€ Cargo.toml                # Rust dependencies
โ”œโ”€โ”€ Trunk.toml                # WASM build configuration
โ”œโ”€โ”€ Dockerfile                # Multi-stage production build
โ”œโ”€โ”€ nginx.conf                # Production server config
โ””โ”€โ”€ index.html                # HTML shell

๐Ÿš€ Getting Started

Prerequisites

Tool Version Install
Rust Nightly rustup default nightly
WASM Target โ€” rustup target add wasm32-unknown-unknown
Trunk Latest cargo install trunk --locked

Installation

# Clone the repository
git clone https://github.com/YADUNANDAN-SINGH/GlassBox-Rust-SVD-recommendation-system.git
cd GlassBox-Rust-SVD-recommendation-system

# Install dependencies (automatic with first build)
trunk serve

Development Server

# Start the dev server with hot-reload
trunk serve
# โ†’ App available at http://localhost:8080

Production Build

# Build optimized WASM bundle
trunk build --release
# โ†’ Output in ./dist/

๐Ÿณ Docker

Build and run a production-ready container in two commands:

# Build the image
docker build -t glassbox .

# Run the container
docker run -d -p 8080:80 --name glassbox glassbox

Open http://localhost:8080 โ€” the app is served via Nginx with gzip compression and SPA routing.


๐Ÿงฌ Tech Stack

Layer Technology Why
Language Rust Memory safety, zero-cost abstractions, WASM compilation
Framework Leptos 0.8 Reactive, fine-grained UI with client-side rendering
Database SurrealDB (IndxDB) Embedded in-browser database โ€” no external servers
Algorithm SVD / Dot Product Linear algebra for content-based filtering
Data Source TVMaze API Open, free, no-auth movie/show metadata
Build Trunk WASM bundler with asset pipeline
Production Docker + Nginx Lightweight, cacheable, static deployment

๐Ÿ›ก๏ธ Privacy Promise

GlassBox is built on a simple principle: your data belongs to you.

  • โŒ No cookies sent to external servers
  • โŒ No analytics or tracking scripts
  • โŒ No user data ever transmitted off-device
  • โœ… All data stored in IndexedDB (browser-local)
  • โœ… All recommendations computed client-side
  • โœ… Full source code visibility

Built with โค๏ธ & ๐Ÿฆ€ Rust โ€” because your recommendations should be transparent, not your privacy.

โฌ† Back to Top

About

A client-side recommendation engine using Singular Value Decomposition (SVD) built with Rust, Leptos, WebAssembly, and SurrealDB. Zero-server architecture all data stays in the browser.

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors