An advanced, offline-first local RAG (Retrieval-Augmented Generation) customer support mobile application. (For example, configured to parse and answer queries using ConnectWise support documentation).
The system runs 100% locally on your machine—ensuring complete data privacy, offline capabilities, and zero API usage costs.
- Frontend Client (Expo App): Built with React Native Expo (SDK 51), featuring a complete navigation stack, React Query caching, and custom markdown support. It includes a native PDF document picker that reads and uploads files as base64 streams directly inside active chat bubbles.
- Backend Server (Node.js & Express): Serves as the middle layer, hosting PostGraphile middleware to dynamically reflect database schemas as GraphQL schemas, and custom Express REST endpoints for user authentication.
- GraphQL Schema Plugin: Custom PostGraphile plugin extending the schema with high-performance
askQuestion(RAG pipeline) anduploadDocumentmutations. - Vector Database (PostgreSQL 17): Core database managing tables for users, chat sessions, and messages. Employs the
pgvectorextension to index 768-dimension text chunk embeddings using a high-speed HNSW index optimized for L2 distance matching. - Local AI Server (Ollama): Houses offline generative and embedding runners:
nomic-embed-text: Generates embeddings for document chunks and queries.gemma2:2b: Generates natural, helpful customer support answers.
- File Pick: Technicians select a local PDF file via the paperclip button on the chat input bar.
- Base64 encoding: Client converts the file stream and calls the
uploadDocument(name, base64Data)GraphQL mutation. - Chunking: Backend decodes the PDF, extracts text page-by-page, and splits it into semantic chunks of ~1000 characters.
- Embedding: Backend calls Ollama's local
nomic-embed-textAPI to convert each text chunk into a 768-dimension vector. - PG Indexing: Stores chunks and vectors in PostgreSQL, instantly updating the HNSW vector search index.
- Instant Feedback: Inserts a system confirmation message bubble directly into the chat session feed.
- Question: User submits a support query (e.g. "What is Backstage mode?").
- Embed: Backend embeds the question using Ollama's local embeddings API.
- Vector Search: Executes an L2 distance (
<->) similarity query against PostgreSQL embeddings:SELECT content, metadata FROM embeddings ORDER BY embedding <-> $1::vector ASC LIMIT 5;
- Prompt Engineering: Combines the aggregated top 5 context chunks, system instructions (representative persona, strict no-hallucination rules), and the user's question.
- Inference: Local
gemma2:2bprocesses the prompt and returns a response. - Output: Response is post-processed, user history is updated, citation references are resolved, and the bubble is pushed to the user.
The app is styled using a curated, premium color scheme:
Primary (Blue):#29389A(Brand Identity Example)Secondary (Dark Navy):#0D1025(Headlines & Dark Elements)Tertiary (Lime Green):#C5E654(Accent badges & highlights)Neutral (Light Grey):#F6F6F6(App-wide background)
Install the following local dependencies:
Open a terminal and pull the required models:
ollama pull nomic-embed-text
ollama pull gemma2:2b
ollama serveCreate a .env file in the /server folder matching server/.env.example:
PORT=5000
DATABASE_URL=postgresql://<DB_USER>:<DB_PASSWORD>@localhost:5432/knowledge_bot
JWT_SECRET=your_jwt_secret_key_hereCreate a .env file in the /client folder matching client/.env.example:
EXPO_PUBLIC_API_URL=http://<YOUR_MACHINE_LOCAL_IP>:5000(Replace <YOUR_MACHINE_LOCAL_IP> with your computer's local network IPv4 address so physical devices running Expo Go can communicate).
Run the automated initialization script:
cd server
npm install
npm run setup-dbThis script enables standard extensions (vector, uuid-ossp), creates the database schema, indexes all preloaded PDFs in /docs, and computes HNSW vectors.
npm run devOpen a new terminal:
cd client
npm install
npx expo start -cScan the QR code in your terminal using the Expo Go app on your physical mobile device to test.
This project is licensed under the MIT License - see the LICENSE file for details.




