Back to Projects
Flarif AI
AI/ML

Flarif AI

Senior AI/Software Engineer & Tech Lead

Next.jsNestJSExpressQdrantLangChainOpenAIRAGSocket.ioGoLiveKitBullMQ

About the Project

Flarif AI lets individuals and businesses build secure, custom-trained AI assistants over their own documents. What began as a RAG product grew into an agentic platform, and then into two product lines: the AI platform itself, and Flarif Tech — the company site plus a live masterclass product with its own self-hosted media stack. Ten repositories, no monorepo. The defining piece is an orchestration layer that decides per turn whether a question needs retrieval, a live web search, a bounded multi-round research pass, a generated file or video, or nothing but the conversation so far. On top of that sits a long-term memory library that extracts facts from conversations, verifies them, consolidates them on a schedule, reconciles contradictions and can forget on request. I lead the engineering effort and own the architecture, the RAG and memory design, and developer onboarding.

What It's Made Of

API server & workers

Express 5 · ESM · Mongoose · BullMQ

Every REST endpoint under /api/v1 — auth, CRUD, plan gating, billing, email, S3/MinIO uploads — and no WebSockets at all. A second process off the same codebase runs the BullMQ consumers: knowledge-base URL crawling, file text extraction, resume formatting, and a Redis pub/sub subscriber that turns ingestion progress into KnowledgeBase and AiJob status updates. Authorization is permission-based rather than role-based: read:<module> / write:<module> keys are granted to roles or directly to users and resolved behind a 60-second Redis cache, so admin routes check a permission, never a role name.

Socket server — the AI engine

Socket.IO · Qdrant · BullMQ

Owns everything streaming and AI-facing. Socket.IO chat for the business widget, the AI Secretary, and agent, project and deployment conversations; the RAG pipeline over Qdrant with its own result cache and a sweep schedule; the LLM orchestration layer; the agent tool loop with argument validation, an SSRF guard, an approval store for tools that need a human yes, and a per-call audit trail. It also hosts the public webhook surface for every external channel and runs its own workers for embeddings, memory consolidation and video completion.

Long-term memory library

Qdrant · scheduled consolidation

A memory system rather than a transcript: facts are extracted from conversations, passed through guards and a verifier before they are trusted, written to their own vector collections, then consolidated on a schedule, reconciled when they contradict each other, and forgotten on request. Dirty-tracking means only changed subjects get reprocessed, and recall is intent-aware so a question pulls the preferences and resource profile that matter to it instead of everything ever stored.

Web app

Next.js 16 · React 19 · TypeScript

The product surface where users build assistants, manage knowledge bases, and hold conversations — personal chats, project workspaces, business widgets and deployments, each a distinct conversational mode with its own context assembly. Streaming answers arrive over Socket.IO rather than HTTP, so the client renders tool activity and research progress as it happens.

Masterclass platform

NestJS 11 · Next.js 16

A live teaching product: scheduling, access rules, the live room, chat, Q&A, raised hands, attendance, recording review as a draft-then-publish flow, replay payments, plus the blog and signup waitlist. The NestJS backend is the only owner of durable masterclass data; the learner and instructor UI talks to nothing else, and browsers connect to the media server directly using a join token the backend fetched on their behalf.

Media control plane

Go 1.26 · LiveKit · Redis · MinIO

A private service in front of self-hosted LiveKit that creates rooms, mints join tokens, applies host controls, runs breakouts and records sessions. It encrypts each recording segment with a per-recording key and uploads the segments, playlist and MP4 to a private bucket, deleting local copies only once the upload succeeds. It deliberately keeps no database and has no public domain — every durable record lives in the masterclass backend, which is the only caller, over a shared service key.

Company site & admin console

Next.js · MUI

The public Flarif Tech site reading blog and waitlist data from the masterclass backend, and the internal admin console for platform operations, user and permission management, content and masterclass administration. The console reuses the AI platform's permission catalogue over a service-to-service call rather than keeping its own copy.

Distribution — channels & plugins

HubSpot app · WordPress plugin · 7 messaging platforms

Assistants reach people where they already are: Slack, Telegram, Discord, Messenger, Instagram, X and WhatsApp, plus a HubSpot public app and a WordPress plugin. Each platform's inbound signature is verified at the socket server before anything is proxied inward, and all of them share one identity handshake — name and email, then a six-digit code — so a channel user is a known person before the assistant answers as a deployment.

Key Highlights

  • Built the orchestration layer: an LLM-driven classifier decides per turn whether to retrieve, search the web, generate a file or video, or run a bounded multi-round deep-research pass with a clarification step before spending tokens
  • Designed and implemented the full RAG pipeline — ingestion, chunking, embedding, Qdrant storage, retrieval, result caching — alongside a knowledge-graph service for relationship-aware answers
  • Built the long-term memory library: fact extraction with guards and a separate verifier, scheduled consolidation, contradiction reconciliation, intent-aware recall, and explicit forgetting
  • Implemented context compaction so long conversations stay inside the window, deliberately routed to a cheap fixed model independent of whichever model the conversation itself is using
  • Made knowledge-base ingestion a cross-process pipeline — backend queue to backend worker to socket queue to socket worker to Qdrant, with completion flowing back over Redis pub/sub — so a large crawl never blocks a request
  • Hardened the service-to-service boundary with two independent checks: an HMAC-SHA256 service key at the router and a user JWT at the route, with business API keys on a separate fail-closed path where missing scopes mean deny rather than allow
  • Shipped distribution beyond the web app — seven messaging platforms, a HubSpot app, a WordPress plugin, and embeddable business widgets — with human escalation when the agent should hand off

Technical Challenges

The hard problem stopped being retrieval quality and became knowing when to retrieve at all. Running search and deep research on every turn is slow and expensive; running them on none makes the assistant useless on anything current. So the decision itself became a classified step, with bounded rounds so a research pass terminates instead of spiralling. The cost discipline that follows from that is the part I would defend in review: background work — compaction, classification, titling — is pinned to a cheap model regardless of what the user's conversation is running on, because the user never sees that output and paying frontier prices for bookkeeping is money set on fire. Memory raised a different question. A model that believes everything it is told accumulates contradictions and confidently repeats them, so facts pass guards and a separate verifier before they are trusted, and consolidation runs as its own scheduled job rather than inline on a turn the user is waiting for.