When people talk about recommendation engines for hundreds of thousands of items, most engineers immediately picture a heavy ML stack: GPU clusters, Python services, external vector databases like Milvus or pgvector, and massive language models. It feels as if, without neural nets, a modern app is doomed to serve a boring "most popular" list. But what if I told you that you can run a fast recommendation engine over 895,000 movies—returning similar titles in 1–3 milliseconds—on a modest, couple-of-bucks-a-month VPS using plain JavaScript and embedded SQLite?
That is literally how the indie service KINO PARTY works. Its catalog covers nearly a million films, and the server runs a monolith on Node.js 24. No microservices, no overengineering, and no cloud bills to lose sleep over.
Let's pop the hood on this architecture: inspect the native node:sqlite module, look at the math behind normalized sparse vectors, see why an inverted index beats approximate graph search here, and check out the data-cleaning traps waiting in hundreds of thousands of raw rows.
Layer 1: The Infrastructure Paradox and a Local Stack Without External ML Databases
The biggest engineering illusion in search and ranking is assuming every problem needs neural-network embeddings. Teams grab 1,536-dimension dense vectors, ship them to a dedicated vector database, and then wonder why the database eats 16 GB of RAM just to maintain an HNSW graph while network round-trips burn tens of milliseconds.
In KINO PARTY, the database and the analytical engine live in the same address space. Storage is handled by embedded SQLite, accessed through the native node:sqlite module stabilized in Node.js 24. Previously, binary wrappers like better-sqlite3 were the default. They were fast, sure, but compiling C++ add-ons via node-gyp made Docker builds fragile and annoying. Having DatabaseSync built straight into the standard library eliminates that friction.
To keep the database flying without hitting disk bottlenecks, the app sets a few key pragmas on startup:
import { DatabaseSync } from 'node:sqlite';
const db = new DatabaseSync('./data/kinoparty.db');
// Enable WAL mode and allocate memory for the page cache
db.exec(`
PRAGMA journal_mode = WAL;
PRAGMA synchronous = NORMAL;
PRAGMA cache_size = -64000; -- 64 MB of RAM for the page cache
PRAGMA temp_store = MEMORY;
PRAGMA mmap_size = 2147483648; -- Memory-map 2 GB of the database file
`);
WAL mode lets read threads run without blocking write transactions: while a background job enriches movie cards with OMDb ratings, incoming HTTP requests read data instantaneously. The entire database file—including indexes and FTS5 virtual tables—takes up exactly 9 GB on disk. FTS5 full-text search handles title and actor queries, while the recommendation core in recommender.js is only about 650 lines of plain JavaScript.
Layer 2: Cleaning Dirty Data and Fighting ID Collisions
Algorithms look spotless on paper until they meet real-world data. KINO PARTY's catalog was assembled by merging exports from TMDB, OMDb, and historical Kinopoisk dumps—and that's where the surprises began.
The first headache was primary key collisions. Movie IDs in old Kinopoisk dumps overlapped with TMDB API IDs. For example, ID 603 belongs to The Matrix in TMDB, but in Kinopoisk it pointed to a Polish drama (The Double Life of Véronique / Salon Veroniki). A naive join on id produced absurd recommendations. The fix was separating external keys (tmdbId, kinopoiskId, imdbId) and validating release dates with a tolerance of no more than one year.
The second headache was fake localizations. Out of 762,000 movies with populated descriptions, 669,416 rows had no Cyrillic characters in the Russian column—when a translation was missing, TMDB silently copied the English synopsis over. Translating 670,000 blurbs via an API would cost a fortune. Instead, the author carved out a "golden core" of 26,880 popular titles and translated only those, building features for the rest from their original markers.
On top of that, machine translation injected zero-width spaces (U+200B) and non-breaking spaces into the dataset, breaking checksums and FTS5 tokenization. A mandatory text-sanitizing pass before writing to SQLite solved it.
Layer 3: Linear Algebra in Memory: Inverted Index and Similarity Scoring
How do you find 50 similar movies out of nearly a million in a couple of milliseconds? A naive heuristic scan over the whole database would peg the CPU with just five concurrent users.
Infographic blueprint of the KINO PARTY sparse inverted index with feature vectors and the cosine similarity formula.
The solution relies on a vector feature model. Each movie is represented as a sparse vector where only a couple dozen attributes are non-zero:
- Genres (
g:): maximum weight 3.6 due to minimal entropy; - Keywords (
k:): weightTF-IDF × 0.42with stop-word filtering; - Emotional tone (
m:): weight from 0.7 to 1.2; - Narrative engine (
n:): weight around 0.9; - Release decade (
d:): weight 0.55; - Country of production (
c:): weight 0.5.
Feature vectors undergo L2 normalization right as they are stored: ||v|| = 1. Because of that, cosine similarity between two movies collapses into a simple dot product:
Here is what the inverted index and similarity lookup look like in code:
export class FastRecommender {
constructor() {
this.invertedIndex = new Map(); // token -> Array<[movieId, weight]>
this.profiles = new Map(); // movieId -> Array<[token, weight]>
}
addMovie(id, rawFeatures) {
let sumSquares = 0;
for (const w of Object.values(rawFeatures)) sumSquares += w * w;
const norm = Math.sqrt(sumSquares) || 1;
const profile = [];
for (const [token, weight] of Object.entries(rawFeatures)) {
const normalized = weight / norm;
profile.push([token, normalized]);
if (!this.invertedIndex.has(token)) this.invertedIndex.set(token, []);
this.invertedIndex.get(token).push([id, normalized]);
}
this.profiles.set(id, profile);
}
findSimilar(targetId, limit = 20) {
const targetProfile = this.profiles.get(targetId);
if (!targetProfile) return [];
const scores = new Map();
for (const [token, targetWeight] of targetProfile) {
const postings = this.invertedIndex.get(token);
if (!postings) continue;
for (let i = 0; i < postings.length; i++) {
const [candId, candWeight] = postings[i];
if (candId === targetId) continue;
scores.set(candId, (scores.get(candId) || 0) + targetWeight * candWeight);
}
}
return Array.from(scores.entries())
.sort((a, b) => b[1] - a[1])
.slice(0, limit)
.map(([id, score]) => ({ id, score: Number(score.toFixed(4)) }));
}
}
The inverted index shrinks the search space immediately: the algorithm only inspects titles that actually share tokens with the target film.
When the author first tried loading 50,000 movies into memory, the Node.js process hit heavy garbage-collection pauses and started throwing 504 errors. So the in-memory index was capped at 15,000 core films, while profiles for the remaining 880,000 titles are fetched on the fly from SQLite in fractions of a millisecond.
That same trade-off shows up in how engineers design workspace automation tools for Claude, where context isolation keeps memory from getting overloaded.
Layer 4: Real-Time Group Picks and Surviving Production
Picking a movie for a group is much harder than picking for one person. KINO PARTY works like a collaborative movie-swiping room.
If you just average everyone's preferences, the group ends up with a bland compromise that nobody actually wants to watch. To avoid that, the service uses a Valence-Arousal psychological model with an asymmetric penalty factor:
Group Valence = Mean(Valence) + (Min(Valence) - Mean(Valence)) × 1.6
The most tired or dissatisfied participant gets a ×1.6 penalty weight, and veto lists are combined with a logical OR: a left swipe from any single person removes that genre from the shared pool.
Instead of heavy WebSocket connections, real-time updates run over Server-Sent Events (SSE). The server broadcasts room state while clients vote via ordinary POST requests. That gives you native reconnection on smartphones without the overhead of maintaining persistent WebSocket sessions.
Finally, there is protection against SEO Thin Content penalties. Out of 900,000 pages, 868,000 don't have enough text to rank on their own. Those pages return an X-Robots-Tag: noindex, follow header—keeping internal links intact without polluting search indexes. Meanwhile, the public sitemap strictly includes 27,000 core pages that have descriptions of at least 100 characters, a poster, and ratings.
KINO PARTY is a great reminder that clear engineering thinking, algorithmic discipline, and a solid standard library can deliver fast, capable services without blowing up your infrastructure budget.

![Node.JS [ru]](/api/digests/it_development/daily/20261026/assets/sources/we-use-js.jpg?v=5116af75ef3f6a4049958f0a351a3b6a927b26be38099627548e7524071578b8)
