An open API service indexing awesome lists of open source software.

https://github.com/europanite/client_side_rag

Client-Side Browser-Based RAG.
https://github.com/europanite/client_side_rag

browser client-side docker docker-compose embeding expo gpu ingestion llm natural-language-processing nlp rag react react-native retrieval-augmented-generation typescript web-gpu web-llm webgpu webllm

Last synced: 2 months ago
JSON representation

Client-Side Browser-Based RAG.

Awesome Lists containing this project

README

          

# [Client Side RAG](https://github.com/europanite/client_side_rag "Client Side RAG")

[![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
![OS](https://img.shields.io/badge/OS-Linux%20%7C%20macOS%20%7C%20Windows-blue)
[![CI](https://github.com/europanite/client_side_rag/actions/workflows/ci.yml/badge.svg)](https://github.com/europanite/client_side_rag/actions/workflows/ci.yml)
[![docker](https://github.com/europanite/client_side_rag/actions/workflows/docker.yml/badge.svg)](https://github.com/europanite/client_side_rag/actions/workflows/docker.yml)
[![GitHub Pages](https://github.com/europanite/client_side_rag/actions/workflows/deploy-pages.yml/badge.svg)](https://github.com/europanite/client_side_rag/actions/workflows/deploy-pages.yml)

![React Native](https://img.shields.io/badge/react_native-%2320232a.svg?style=for-the-badge&logo=react&logoColor=%2361DAFB)
![TypeScript](https://img.shields.io/badge/typescript-%23007ACC.svg?style=for-the-badge&logo=typescript&logoColor=white)
![Jest](https://img.shields.io/badge/-jest-%23C21325?style=for-the-badge&logo=jest&logoColor=white)
![Expo](https://img.shields.io/badge/expo-1C1E24?style=for-the-badge&logo=expo&logoColor=#D04A37)

!["web_ui"](./assets/images/web_ui.png)

[PlayGround](https://europanite.github.io/client_side_rag/)

Client-side, browser-based Retrieval-Augmented Generation (RAG) playground.

Everything runs in the browser using Expo / React Native for Web with an optional local LLM powered by WebLLM (WebGPU). No custom backend service is required; the RAG index is served as static JSON.

---

## Features

- ⚡ **Pure client-side RAG**
- Retrieval runs entirely in the browser against a static JSON index (`corpus_chunks.json` and optional `corpus_embeddings.json`).
- 🤖 **Optional local LLM via WebLLM**
- If WebGPU is available, the app initializes WebLLM in the browser and uses it to generate answers conditioned on retrieved context.
- If initialization fails or WebGPU is missing, the UI switches to a fallback mode and shows only retrieved chunks.
- There is no application server: only static hosting. Any API base env vars are for compatibility with other setups.

---

## RAG Data

The RAG corpus lives under:

frontend/app/public/rag/corpus_chunks.json

optionally, frontend/app/public/rag/corpus_embeddings.json

corpus_chunks.json

This is a JSON array of chunks:
```json
[
{
"id": "doc1",
"text": "This project is a client-side RAG playground. It runs on React Native for Web and GitHub Pages without any backend.",
"source": "README"
},
{
"id": "doc2",
"text": "RAG stands for Retrieval Augmented Generation. The app retrieves relevant chunks from local JSON files and optionally uses a local LLM.",
"source": "docs"
}
]
```

---

## 🚀 Getting Started

### 1. Prerequisites
- [Docker Compose](https://docs.docker.com/compose/)

### 2. Build and start all services:

```bash
# set environment variables:
export REACT_NATIVE_PACKAGER_HOSTNAME=${YOUR_HOST}

# Build the image
docker compose build

# Run the container
docker compose up
```

### 3. Test:
```bash
docker compose \
-f docker-compose.test.yml up \
--build --exit-code-from \
frontend_test
```

---

# License
- Apache License 2.0