Experience
Projects
My Stack
Case studies
Contact me
Open my CV

·11 min read

Movix.ge: Token-Gated Streaming, Catalog Ingestion and Fast Search

Movix.ge is a Netflix-style streaming platform for a Georgian audience, and I created it. The site is built with Next.js, PostgreSQL and Prisma, and the video server ships as its own Docker image. Video is served behind token-gated access, the catalog fills itself through automated ingestion, and views, likes and bookmarks feed the popularity lists and a continue-watching carousel.

The source is private, so this is a tour of the decisions and the incidents I find most telling, not a code dump.

Role
Creator and developer
Period
Mar 2025 to Oct 2026
Status
Public site online
Stack
Next.js, TypeScript, PostgreSQL, Prisma, Express, MongoDB, video.js, Docker

The challenge

A video site has two jobs that pull against each other. Browsers must stream files with many range requests, and the files must not be a free download for anyone who copies the link. At the same time a small catalog in Georgian needs to be found by search engines and by people who type Georgian titles on English keyboards, and it has to stay current without me adding every film by hand.

Every decision also had to be something I could operate and reason about: one video server I could restart, one Next.js app, a deploy with few moving parts.

My responsibility

I designed and built all of it, and the commit history is my own:

  • the video server: tokens, range streaming, origin checks, clustering and the Docker image (from Mar 2025)
  • the Next.js and Express application, the Prisma schema, auth, the admin panel and comment moderation
  • catalog ingestion, search, SEO (sitemaps, canonicals, structured data) and the installable PWA
  • operating it: production fixes, security passes and browser-tested bug passes

Several recent commits carry an assistant co-author trailer. I reviewed and shipped them, but I mention it so the history reads honestly.

How I approached it

Two runtimes, one site

The web app is a Next.js project with an Express API next to it. Next serves the pages and rewrites /api/* to Express, so the browser only ever talks to one origin. Pages that matter for search engines, such as watch pages and actor pages, fetch data on the server and emit metadata, and actor pages add structured data. Middleware normalises URL case, so /Movie/Watch/12 and /movie/watch/12 do not become two pages.

Core data lives in PostgreSQL through Prisma. The part I like is the Source table: one playable file with a language and a quality, unique per title, language and quality. The quality ladder is data, not code, so adding a rendition is an insert.

Browserone origin only
Next.jspages, metadata, /api/* rewrite
Express APIhandles the rewritten calls
PostgreSQLthrough Prisma
Figure 1. The browser talks to one origin, and Next.js rewrites API calls to Express, which reads PostgreSQL through Prisma.

The player stack is video.js with its HTTP streaming module, which handles .m3u8 playlists, so a title can be an adaptive ladder where one exists and a single file where it does not.

Token-gated video

The video server is a separate small service. The player never gets a plain file URL. The client asks for a URL for a file and a type, watch or download. The server normalises the path so it cannot escape the video directory, checks the file exists, and issues a token.

The token is an HMAC over the filename, an expiry and random bytes. Because of the random part it is an opaque handle, not a self-verifying signature, so the server stores it with the requester's IP, the type and the expiry and looks it up on every request. That costs a database read, and in return I can see how long a session ran, count uses and revoke. Validation checks that the token exists, its type matches, the IP matches and it has not expired.

asks for URLchecks file existsissues tokenrange requestsvalidates, countsPlayervideo.jsVideo serverseparate Docker imageToken storeIP, type, expiryVideo filespath kept inside folder
Figure 2. The player asks the video server for a token, the server stores it with the requester's IP, and every range request is validated against that stored record before bytes are served.

The token is not consumed on first use. A video element issues many range requests while seeking, so a one-shot token would break playback. Each validation updates a usage counter and the elapsed watch time, and repeated requests for the same file, type and IP get the existing token back. The streaming handler implements Range properly: it rejects malformed or unsatisfiable ranges with the right status codes, streams only the requested slice, and sets Accept-Ranges, validators and no-store. A per-user request budget and a scheduled job that archives and deletes old tokens bound the abuse.

Note. This is access control by short-lived, IP-bound tokens. It stops casual hotlinking and link sharing. It is not DRM, and I do not describe it as one.

The token check that trusted the client

Two early details made the token check weaker than it looked. First, the requester's address came from a header the client itself sent, so a token bound to an IP was bound to whatever the caller claimed. On 14 Apr 2025 7b417f4 (Apr 2025) ("real IPs") switched the server to the forwarded client address set by the reverse proxy, added a dedicated CORS step for the watch route, and kept the origin and referer allow list in front of everything.

Second, validation did two address checks: the stored address had to match the request, and the request also had to equal one fixed address hard-coded in the code. Later that morning 69cb168 (Apr 2025) removed the second condition so the stored address is the only rule. In the same commit I renamed the counter from tries to times, because it only ever counted up, and stopped writing a watch time for downloads, which have none.

The next day 1b02bee (Apr 2025) split the Express app from the process that runs it and started one worker per CPU, respawning any worker that dies. Three small commits turned a server that worked on my machine into one that holds up behind a proxy.

One caveat I still hold: the forwarded header is trustworthy only when the proxy sets it. The server is meant to sit behind one, and I would not expose it directly.

Catalog ingestion

Users can request titles, and an ingestion service turns requests into catalog entries.

  1. 01

    Load details

    TMDB, in Georgian and English

  2. 02

    Check catalog

    normalised titles, year tolerance of one

  3. 03

    Match provider id

    IMDb id, TMDB id, then strict title and year

  4. 04

    Map genres and cast

    onto existing rows

  5. 05

    Create

    the movie, or the series with every season and episode

Figure 3. How one title request becomes a catalog entry.

Two choices keep it safe to run unattended. It has a dry run that returns what it would add, with a reason for every skip. And every outcome is reported per request: added, already in catalog, not found, missing poster or date. A title that fails strict matching is skipped, not guessed, because a wrong match is worse than a missing one. I tightened the same rule again on 22 Sep 2026 (0e855ee, 888f8b6) with a year-aware catalog match and stricter title and id matching for requests.

0

candidate rows at most

0

concurrent searches

0

layers in the service

Figure 4. The limits that keep search predictable.

Search is a single service. The query is lowercased and transliterated between Latin and Georgian letters, because people type Georgian titles on English keyboards. A Prisma query builds an OR of exact, prefix, contains and all-words conditions, with the candidate pool capped at 300 rows. Ranking happens in memory, a queue limits concurrent searches to two, and results are cached per query, page, size and role, with empty or error responses never cached.

lookupon a missstores good answersSearch querytyped by the userResult cachein process memoryQuery expansiontransliterate, splitSearch queuetwo at a timeCandidate fetchPrisma, cap 300Rankingin memory
Figure 5. A search checks the cache first, and on a miss the query is expanded, queued, matched against a capped candidate set, ranked in memory and cached only if the answer is good.

A bug taught me why ranking comes before paging. The global search once sorted by release date only, so exact title hits were buried past twenty loosely matched newer rows. 7275125 (Jul 2026) ranks title first, then genre or keyword, then fuzzy token match, before paginating. I quote the under 100 ms figure from the project page and do not benchmark it here.

Why I tried ISR and walked it back

In April 2026 I wanted popular watch pages served from cache. 1b6f6a4 (Apr 2026) added incremental static regeneration with an admin revalidate route, and 8d16cd4 restructured the catch-all route to support it. The next day I reverted that restructure (42101ae).

The root cause was small and structural. The site stores the chosen language in a cookie and reads it in the root layout and the page. Reading cookies opts a route into dynamic rendering, which collides with ISR. I first wrapped the reads in a try and catch to suppress the error (c238c10), and three minutes later decided that only hid the conflict. 53284af (Apr 2026) dropped the revalidate settings and the static params generator and set the page to force-dynamic.

The trade is deliberate. Every watch page is rendered per request, which is fine for one server and a bounded catalog, and the language cookie keeps working. If load grew, the fix is moving the language into the URL so pages could be cached, not forcing ISR through a cookie.

The service worker that reloaded the page forever

In June 2026 4c7dc43 (Jun 2026) fixed a loop. The installable PWA registers a service worker. Its install handler called skipWaiting() unconditionally, the activate handler claimed clients, and the app reloaded on controllerchange. Together that forced a reload mid-browse on every update, and it looped when different instances served different versions of the file.

The fix removed the unconditional skip so a new worker waits for the user to click the update banner, guarded both controllerchange listeners so the first-visit claim does not reload, and bumped the cache version. The lesson I took: an update path needs one owner. I deleted two of three.

Project journey

  1. Mar 2025

    Video server begins

    tokenised URLs from the second commit

  2. Apr 2025

    Token check fixed

    one-address leftover removed, proxy IPs, a worker per CPU

  3. May 2025

    Docker image

    video server packaged and run as a container

  4. Apr 2026

    Next.js repo, SEO and PWA

    sitemaps, canonicals, image caching, installable app

  5. Apr 2026

    ISR tried, reverted

    cookie language conflict, force-dynamic chosen

  6. Jun 2026

    Service worker loop fixed

    update waits for the banner click

  7. Oct 2026

    Browser-tested bug passes

    frontend regressions found and fixed

Figure 6. From a tokenised video server in 2025 to the Next.js site and its hardening in 2026.

Beyond the launch

After launch the work was mostly keeping search engines and phones happy. On 21 May 2026 I made the canonical URL derive from the URL itself (9535f7a), because re-deriving it from a title that could change made Google see a different canonical than the one it crawled, and I replaced the static sitemap with a dynamic one.

Not everything was tightened. On 26 Apr 2026 I disabled the referrer check on the image cache route (d04184b) to stop persistent 403 errors on mobile and the PWA, so poster images are no longer hotlink protected, while video stays token gated. On 21 Apr 2026 I replaced permanent IP bans with two minute timeouts (4a677aa). On 26 Jul 2026 I removed the taste feature from the public site (04230e6), so the language model feature I once described as an experiment is gone from the UI, with its admin view and routes left in place.

Open limit: the search and response caches live in process memory, which is fine for one instance and wrong for several. Moving them behind a shared store such as Redis is the first thing I would do before scaling horizontally.

The outcome

Movix.ge is online and served by the architecture described here. The repository history runs from the first video server commit on 15 Mar 2025 to a bug pass on 31 Oct 2026. I do not have audience numbers I can verify, and I have not benchmarked search or load tested the system, so I do not quote either.

Evidence

  • Local review of the site's web app, the video server and the catalog ingestion service, their architecture notes and commit histories, including the diffs described above. The source is private.
  • Product site: movix.ge
  • Video.js
  • Prisma documentation

Not verified: the under 100 ms search figure comes from the project page, and I did not benchmark search or test under load. I did not re-check the live site's behavior beyond seeing it respond.

#nextjs#postgresql#prisma#video-streaming

Keep reading

Have a project in mind?