Skip to content
Foxmayn
All case studiesFoxmayn AI

Foxmayn AI: a RAG platform we built

Teams upload documents and get answers with cited sources. We built the platform end to end: API, indexing worker, vector search and web app. It is in development.

The problem

Companies hold their knowledge in PDFs, Word files and web pages. People search them by hand, or ask a colleague. A chat model can answer questions, but it does not know your documents, and it will make things up when it does not know.

Retrieval-augmented generation (RAG) fixes this. The system finds the relevant passages in your documents and gives them to the model. The answer then comes with its sources, so a reader can check it.

We wanted to build the whole thing ourselves, to learn where the hard parts are before we put RAG into client projects.

What we built

Foxmayn AI is a RAG platform. Teams upload documents. The platform indexes them and answers questions with cited sources.

  • Document upload for txt, md, html, pdf, doc and docx files, up to 10 MB each.
  • Background indexing with a progress bar from 5 to 100 percent.
  • Cited answers, streamed to the screen with the sources sent first.
  • RAG profiles. Each profile sets the chat model, embedding model, number of passages retrieved, score threshold, chunk size, temperature and system prompt.
  • Credits that pay for indexing and questions.
  • Organizations, users and API keys, with admin user management.
  • A documented API with an OpenAPI spec and a Scalar reference page.

How it works

The code is a TypeScript monorepo on Node 24, built with Turborepo and pnpm. It has an API, a worker and a web app, plus shared packages for the database, the model client and the vector store.

Indexing. An upload goes to the API through oRPC. The API queues a job in BullMQ on Redis. The worker splits the text into chunks with LangChain's recursive splitter (500 characters with a 50-character overlap by default). It requests embeddings through OpenRouter in batches of 20 and stores the vectors in Qdrant, one collection per embedding size. A job retries up to three times with exponential backoff. If it fails for good, the worker removes the vectors and rows it created, so no half-indexed document stays behind.

Answering. A question is embedded and searched in Qdrant by cosine similarity. By default the top 5 passages above a score of 0.3 go to the model. The default chat model is Gemini 2.5 Flash Lite through OpenRouter. The API streams the answer from an oRPC generator and sends the sources first, so the interface can show them while the text arrives.

Credits. The platform reserves credits before it does any work, settles the real cost afterwards and refunds the reservation if the work fails. A single atomic SQL check protects the balance. Top-ups are done by an admin.

Stack. Hono for the API, oRPC for the contract, better-auth for sign-in and organizations, Drizzle ORM on PostgreSQL, and React 19 with TanStack Router and Vite for the web app.

Where it stands

Foxmayn AI is in development, built between November 2025 and March 2026. It has no releases and no deployment that we run for others yet. We run it locally and in Docker.

Each user's documents stay their own: retrieval, vectors and RAG profiles are scoped to the document owner, document filters check ownership, the queue dashboard is admin-only and request size is capped.

Some things are still missing:

  • Automated tests and CI.
  • A payment integration for credit top-ups.
  • Sharing documents across an organization.

What it shows about our work

The platform is a reference for how we approach AI on business data. Indexing runs as a job that can fail and recover. Money-like resources, here credits, are accounted for carefully. Answers carry their sources. Models and retrieval settings are configuration, not code.

Next

Organization-level isolation comes first. Then tests and CI, then a first real deployment with a pilot team. If you want RAG on your own documents or on your ERP, see our services. The repository is at github.com/nasroykh/foxmayn_ai.

All case studies

A desktop and web front end for Frappe and ERPNext that re-implements the screens end users touch. Early and in development. We built it to learn what a better client takes.
Read the case study

Have a Frappe project?

Tell us what runs today and what should change.

Or email us at[email protected]

We only use your details to reply to you.