All work

Case study

Internal Operations Platform

The company's own back office in one app (leads, finance, tasks, media, chat and assets), with multimodal semantic search over the media library running on an in-process CLIP model.

ClientLink, in-house platform
EmployerINK IN CAPS
PeriodAug 2026 – Present
RoleSoftware Development Engineer
1024-dmultimodal embeddings, text + image
2apps in one monorepo: API + media worker
~37API modules on one data layer
1280×720HD gate at upload

The problem

Link is where the company actually runs: leads come in from email and IVR, projects move from quotation to invoice to payment, assets are issued to people, and thousands of images from client shoots need to be found again months later. Each of those used to live in inboxes, spreadsheets and people's heads. The engineering problem is breadth with sharp edges: dozens of modules sharing one data layer, where a visibility rule in finance or a broken media contract can leak or lose real company data.

Architecture

A NestJS 12 monorepo on native ESM with two deployable apps: the API (around 37 modules over one MongoDB, Redis for cache and BullMQ, and one S3 bucket) and a separate asset-optimizer process that consumes the media queues and does the CPU-heavy ffmpeg, sharp and transcription work, so a video transcode never competes with an API request. Chat message bodies live in an external service; Link owns membership, notifications and the push layer. Uploads go direct to S3 through presigned multipart URLs, and the API only finalises them.

Vault upload, embedding, and multimodal searchCompleted uploads pass an HD gate, then fan out to the optimizer for thumbnails and to an embedding queue that stores one CLIP vector per image. Text or image queries are embedded by the same model, cached as a Redis search session, and answered by Atlas vector search joined back to live media.Complete Uploadper-file, partial OKHD Gatesharp, ≥ 1280×720Optimizerthumbs + compressionEmbedding QueueCLIP Modeljina-clip-v2 · 1024-dAtlasvector indexSearch Querytext or imageRedis Sessionvector + cursorResults$lookup live mediaupsertembedcache$vectorSearch

Searching the media library

The vault holds the company's photo and video library in a nested folder tree. Folder names and tags don't find 'the red stage shot from that launch', so I added semantic search that takes either a sentence or an example image.

  • Every completed image upload enqueues an embedding job; a worker downloads the original, runs it through jina-clip-v2 (quantised, 1024-dimensional) and upserts one vector per media item. Deleting the media deletes the vector.
  • Text and image queries go through the same model into the same vector space, then into MongoDB Atlas $vectorSearch, joined back to live media and filtered by IST date range.
  • The query embedding is cached in Redis behind a search session, and the cursor carries the last score, media id and depth, so paging never re-embeds the query.
  • Post-search filters can drop hits, so each page oversamples candidates and grows the $vectorSearch limit as the user pages deeper, capped at Atlas's 10,000-candidate ceiling.
  • The model loads lazily on first use, is reference-counted so it's never freed mid-request, and unloads after ten idle minutes: gigabytes of weights aren't held by an API instance nobody is searching on.

Upload pipeline

Completing an upload is per-file and partial-success tolerant rather than all-or-nothing, because a batch of forty images shouldn't fail on one bad file.

  • An HD gate reads image dimensions with sharp from the first 256 KB of the object, falling back to the full file, and rejects anything under 1280×720, deleting both the S3 object and the row.
  • Accepted files fan out to the right queues: thumbnails and compression for the optimizer, embeddings for search. Rejected files come back in a separate list, so the response is 200 with both lists unless nothing succeeded.
  • Folders are a materialised tree (parent, ancestors and depth, three levels deep and twenty children per folder), so deleting a folder soft-deletes its whole subtree and its media in two queries.

Finance, access and assets

Beyond media, most of my work has been in the modules where a wrong rule has real consequences.

  • Finance: proforma invoices and purchase orders that cover several milestones each, partial invoicing with milestone locking, an invoiced / outstanding / requested summary, project drafts, vendor approval flows with proof-of-payment uploads, and pending-payment reminders delivered to chat and email.
  • Visibility: project and budget access driven by explicit per-project visibility lists and sub-module grants rather than by department alone, so finance data is shown only to the people a project names.
  • Auth: removed the public sign-up route so accounts are created only by HR and admins, added email OTP at login, and moved token lifetimes and CORS origins (including regex patterns) into validated config.
  • Assets: inventory and workstation activity logs, product IDs from a shared atomic counter, and barcode and product-key sheets generated for selected assets.
  • Push: kept FCM tokens deduplicated and in sync with chat membership, pruned unregistered tokens, scoped new-chat socket events to members instead of every connected user, and gave group pushes a click target that opens the chat.

Decisions

Keep the model in-process, but lazy

Embedding inside the API avoided a new service and a network hop for a feature with bursty, low traffic. The cost, a large model in API memory, is paid only while someone is searching, because the model loads on demand and unloads when idle. If the box can't hold it, the embedding step can move to the optimizer without changing the search contract.

Cursor sessions instead of offset paging

Vector search has no stable offset: results are ranked by score and filtered after the fact. Caching the query vector in a short-lived Redis session and paging on (score, id) gives stable pages without re-embedding the query or re-ranking from scratch.

Reject at the door, not downstream

The HD check runs at complete-upload, before any job is queued, so low-resolution files never consume optimizer or embedding time and never show up in search.

Visibility as data, not department

Finance visibility reads explicit per-project lists and sub-module grants, so giving or revoking access is a data change an admin makes, not a code change, and not an accident of which department someone sits in.

Stack

Service
NestJS 12TypeScript 6Native ESMMongoDBMongoose 9
Search
jina-clip-v2Transformers.jsAtlas $vectorSearchRedis sessions
Async
BullMQRedisSeparate optimizer processCron
Media
S3 multipart presignedsharpffmpegDeepgram
Auth
JWTEmail OTPCASLSub-module grants
Notifications
Socket.IOFirebase FCMEmail
Quality
Vitestmongodb-memory-serveroxlintConventional commits