Prerequisites
Before you begin, make sure you have the following:- Node.js 20+ — Prism uses Next.js 16 with React 19
- Appwrite project — cloud or self-hosted; you need a project ID and a storage bucket
- Qdrant — Qdrant Cloud (free tier works) or a local Qdrant instance
- Google AI API key — for Gemini chat, RAG, and embedding generation; get one from Google AI Studio
Setup
Configure environment variables
Create a
.env.local file in the project root and add the following variables:.env.local
Where to find each value
Where to find each value
Appwrite (client-side)
NEXT_PUBLIC_APPWRITE_ENDPOINT— The API endpoint for your Appwrite instance. For Appwrite Cloud this ishttps://cloud.appwrite.io/v1. For self-hosted Appwrite, use your own domain.NEXT_PUBLIC_APPWRITE_PROJECT_ID— Found in your Appwrite Console under Settings → General.NEXT_PUBLIC_APPWRITE_BUCKET_ID— Create a storage bucket in Storage → Buckets, then copy the bucket ID.
APPWRITE_API_KEY— A server API key withusers.writeanddatabases.read/databases.writepermissions. Create one in Settings → API Keys in the Appwrite Console. This key is used by Next.js API routes (never exposed to the browser).NEXT_PUBLIC_APPWRITE_DATABASE_ID— The ID of the Appwrite Database where chat history is stored. Create a database in Databases and copy its ID.NEXT_PUBLIC_APPWRITE_CHAT_HISTORY_COLLECTION_ID— The ID of the collection within that database for storing chat sessions. Create a collection with fields:userId(string),title(string),messages(string),selectedDocument(string, nullable),createdAt(string),updatedAt(string).
QDRANT_CLUSTER_URL— Your Qdrant Cloud cluster URL (e.g.https://abc123.us-east4-0.gcp.cloud.qdrant.io), orhttp://localhost:6333for a local instance.QDRANT_API_KEY— Found in your Qdrant Cloud console under cluster details. Leave empty if using a local unauthenticated instance.
NEXT_PUBLIC_GEMINI_API_KEY— Generated in Google AI Studio. Prism usesgemini-2.5-flashfor chat and RAG, andtext-embedding-004for generating 768-dimensional embeddings.
Qdrant collection
Prism manages a single Qdrant collection namedprism_documents. On first use, it is created automatically with the following configuration:
| Setting | Value |
|---|---|
| Collection name | prism_documents |
| Vector size | 768 dimensions |
| Distance metric | Cosine |
| Indexing threshold | 10,000 vectors |
userId, documentId, documentType, and category to enable per-user filtering and type-based search. You do not need to create the collection manually.
If you point multiple Prism instances at the same Qdrant cluster, they will share the same collection. Per-user isolation is enforced at query time by filtering on
userId, but you should treat the cluster as single-tenant for now.Appwrite setup
Prism uses Appwrite for authentication and file storage. A few things to configure in your Appwrite project:- Auth providers — Enable Email/Password and optionally Google OAuth under Auth → Settings. For Google OAuth, set the success redirect to
http://localhost:3000/dashboardand the failure redirect tohttp://localhost:3000/auth/login?error=oauth_failed. - Storage bucket — Create a bucket and note its ID for
NEXT_PUBLIC_APPWRITE_BUCKET_ID. File permissions are set per-user on upload. - Server API key — The
/api/users/assign-planinternal route usesnode-appwritewith server-side credentials to assign plan labels to new users. Add a server API key withusers.writepermissions and set it asAPPWRITE_API_KEYin your environment if you want plan labels to work.
Running in production
To build and run a production bundle:.env.local are available in your deployment environment.