How lamnhan/rag-demo works
Project type and purpose
• This is a full-stack Retrieval-Augmented Generation (RAG) demo web application.
• The README says: “A RAG system using SurrealDB, tRPC and Lit.”
• Purpose: ingest raw JSON samples into SurrealDB, index or query them via tRPC API, augment user prompts with retrieved data, and render an interactive chat UI in the browser using Lit components.
File structure
• Top-level directories:
• client/ – the front-end UI built with Lit (TypeScript, CSS, Vite).
• server/ – the back-end logic using tRPC, SurrealDB client, OpenAI calls.
• database/ – raw JSON samples + SurrealDB schema setup.
• scripts/ – CLI commands (download, insert, query, setup) to manage data ingestion and DB schema.
• shared/ – TypeScript types and transformer logic reused by client, server, and scripts.
• Config & build files: tsconfig.json (root, client, server), vite.config.ts, package.json, pnpm-lock.yaml.
• server/procedures/ and server/router.ts implement business logic and tRPC routing.
• scripts/commands/*.ts sequence through data ingestion and testing workflows.
README for additional insights
• Retrieve relevant JSON snippets from SurrealDB.
• Possibly transform them (shared/transformer.ts) into prompt context.
• Send combined prompt to OpenAI via server/openai.ts.
• Return generated responses to the client through tRPC endpoints.