Overview
MeshAI is a full-stack retrieval-augmented generation (RAG) app. Users upload PDF documents to a personal knowledge base, and MeshAI answers questions in a chat interface using only the content of those documents.
Problem
Questions about your own documents should be answered from those documents, not from a model’s general knowledge.
Solution
Embed each uploaded PDF in chunks, retrieve the chunks most similar to the question, and have the model answer from that context only, saying so when it is not enough.
- Upload: parse the PDF, split it into 500-character chunks and embed each chunk with Qwen3-Embedding-8B.
- Store: save documents, chunks and embeddings in MongoDB, scoped to the user who uploaded them.
- Ask: embed the question, rank chunks by cosine similarity and send the top 5 as context to Qwen3-30B-A3B-Instruct.
- Answer: reply from the provided context only, and save the chat history per conversation.
Architecture
- Browser (React + Vite)
- Caddy reverse proxy (automatic HTTPS)
- Express API (Node.js + TypeScript)
- MongoDBNebius Token Factory (Qwen3 models)
Technology
Key Features
- PDF upload to a personal knowledge base, with a list of documents and delete
- Chat answers grounded in the five most relevant chunks, with history saved per conversation
- Accounts with JWT authentication and bcrypt-hashed passwords; documents are private to each user
- Rate-limited registration and login
- One-off questions against the knowledge base through the API
Technical Challenges
- Keeping answers grounded: the model answers from the retrieved context only and says when it is not enough
- Serving the frontend and API from one domain with automatic HTTPS, with ZeroSSL as a fallback when Let’s Encrypt is rate-limited
Engineering Decisions
- Store embeddings in MongoDB and rank them by cosine similarity in the API instead of adding a separate vector database
- Use the OpenAI SDK against Nebius’s OpenAI-compatible API for both the embedding and chat models
- Cache each user’s document list in memory for 30 seconds and invalidate it on upload or delete
- Log through Winston and Morgan, with console output disallowed by ESLint
- Run MongoDB, the API, the frontend and Caddy with Docker Compose; GitHub Actions builds and lints client and server
Result
Live at mesh-ai.crabdance.com, deployed with Docker Compose behind Caddy.