A full-stack Retrieval-Augmented Generation chatbot with a NestJS API, React/Vite UI, local MiniLM embeddings, PostgreSQL + pgvector retrieval, and OpenRouter generation.
document-rag/— NestJS API and RAG pipelinedocument-rag-ui/— React + Vite frontendDockerfile— production multi-stage build serving the UI and API togetherrender.yaml— Render Blueprint for the app with an external PostgreSQL database
- Start PostgreSQL with pgvector:
cd document-rag
docker compose up -d- Create
document-rag/.env:
DB_HOST=localhost
DB_PORT=5432
DB_USER=rag_user
DB_PASSWORD=rag_password
DB_NAME=rag_db
OPENROUTER_API_KEY=your_key_here- Start the API:
cd document-rag
npm ci
npm run start:dev- Start the UI in another terminal:
cd document-rag-ui
npm ci
VITE_API_URL=http://localhost:3000/api npm run dev- Create a PostgreSQL database that supports pgvector, for example on Neon. Choose a region close to the Render service and copy the connection string from the database's Connect dialog.
- Open Render Blueprints and select this repository.
render.yamlcreates only the Docker web service; it does not provision a Render database. - Set
DATABASE_URLto the external database connection string and enterOPENROUTER_API_KEY.DB_SSL=trueis already set in the Blueprint. - For an existing Render service, update
DATABASE_URLunder Environment, keepDB_SSL=true, then save and redeploy the latest commit. Changing the Blueprint alone does not replace an existing service's database credentials. - Verify
/apiand/api/documentsreturn successful responses, then upload a document and test a hybrid-search question. The UI and API are served from one HTTPS domain; the API lives under/api.
The production startup script creates the vector extension before NestJS synchronizes the schema. After synchronization, startup backfills missing search vectors and creates the GIN index, including on a completely new database.
Render's free PostgreSQL databases expire after 30 days. Using an external database avoids that Render database expiry; the web service can remain on Render. External free plans still have usage limits; check Neon's current allowances.
Switching DATABASE_URL starts with the contents of the replacement database; it does not migrate old documents. Restore a backup if available, or re-upload the source documents. Keep the suspended database until any needed data has been recovered.