Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .changeset/ai-chat-feature.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
"create-docubase": minor
---

Add AI chat assistant with RAG-powered documentation search

- Add AskAnything component for homepage chat input
- Add ChatWidget floating chat button component
- Add dedicated chat page with conversation history
- Add chat API endpoint with Google Gemini integration
- Add Upstash Vector for semantic search
- Add index-content scripts for development and production
- Fix: XSS protection for AI-generated markdown links
- Fix: Proper SSE format for streaming responses
- Fix: Initialization guards for event listeners
5 changes: 5 additions & 0 deletions .changeset/plain-grapes-notice.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"create-docubase": minor
---

AI chat assistant with RAG-powered documentation search
8 changes: 8 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# AI Chat Feature - Get your free API keys:

# Upstash Vector (https://console.upstash.com/vector)
UPSTASH_VECTOR_REST_URL=
UPSTASH_VECTOR_REST_TOKEN=

# Google Gemini (https://aistudio.google.com/apikey)
GOOGLE_GENERATIVE_AI_API_KEY=
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
# build output
dist/
template/dist/

# generated types
.astro/

# dependencies
node_modules/
template/node_modules/

# logs
npm-debug.log*
Expand Down Expand Up @@ -54,6 +56,7 @@ coverage/
# Cache
.cache/
*.tsbuildinfo
.index-manifest.json

# Temporary files
tmp/
Expand Down
40 changes: 40 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Your site will be available at `http://localhost:4321`.
- **Content-First**: Write documentation in MDX with full component support
- **Framework-Agnostic**: Works with any UI library or none at all
- **Multiple Content Types**: Documentation, blog posts, and tutorials out of the box
- **AI Chat Assistant**: Built-in RAG-powered chat that answers questions about your docs
- **Static Site Generation**: Fast, SEO-friendly pages that deploy anywhere
- **Type-Safe**: Full TypeScript support with Astro Content Collections
- **Dark Mode**: Automatic dark mode support via CSS media queries
Expand All @@ -31,6 +32,8 @@ Your site will be available at `http://localhost:4321`.
- [MDX](https://mdxjs.com/) - Markdown with components
- [TypeScript](https://www.typescriptlang.org/) - Type safety
- [Tailwind CSS](https://tailwindcss.com/) - Styling
- [Google Gemini](https://ai.google.dev/) - AI chat responses
- [Upstash Vector](https://upstash.com/vector) - Vector search for RAG
- [Storybook](https://storybook.js.org/) - Component playground (optional)

## Installation
Expand Down Expand Up @@ -271,6 +274,43 @@ import Example from '../../components/Example.astro';
</Example>
```

## AI Chat Assistant

DocuBase includes a built-in AI chat assistant that uses RAG (Retrieval-Augmented Generation) to answer questions about your documentation.

### Setup

1. Copy the environment file:

```bash
cp .env.example .env
```

2. Add your API keys to `.env`:

```env
# Upstash Vector (https://console.upstash.com/vector)
UPSTASH_VECTOR_REST_URL=your_url_here
UPSTASH_VECTOR_REST_TOKEN=your_token_here

# Google Gemini (https://aistudio.google.com/apikey)
GOOGLE_GENERATIVE_AI_API_KEY=your_key_here
```

3. That's it! Content is automatically indexed on every build.

### How It Works

- Content is automatically indexed when you run `pnpm run build`
- Users can ask questions via the chat widget or "Ask Anything" input
- The AI searches your docs and provides relevant answers with sources
- No manual indexing required - just write docs and deploy

### Components

- **AskAnything**: Homepage input for starting a chat
- **ChatWidget**: Floating chat button (can be added to any layout)

## Storybook (Optional)

DocuBase includes an optional Storybook setup for developing and showcasing components:
Expand Down
2 changes: 2 additions & 0 deletions astro.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@ import { fileURLToPath } from 'node:url';

import tailwindcss from '@tailwindcss/vite';
import mdx from '@astrojs/mdx';
import vercel from '@astrojs/vercel';

const __dirname = path.dirname(fileURLToPath(import.meta.url));

export default defineConfig({
site: 'https://docubase-docs.vercel.app',
output: 'static',
adapter: vercel(),
srcDir: './template/src',
publicDir: './template/public',
vite: {
Expand Down
13 changes: 11 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"scripts": {
"dev": "astro dev",
"build": "astro build && pagefind --site dist",
"build:with-index": "pnpm run index-content && astro build && pagefind --site dist",
"preview": "astro preview",
"astro": "astro",
"test": "vitest run",
Expand All @@ -22,7 +23,9 @@
"version": "changeset version",
"release": "changeset publish",
"storybook": "storybook dev -p 6006",
"build-storybook": "storybook build"
"build-storybook": "storybook build",
"index-content": "npx tsx scripts/index-content.ts",
"index-content:watch": "npx tsx scripts/index-watch.ts"
},
"keywords": [
"documentation",
Expand All @@ -41,9 +44,14 @@
"dependencies": {
"@astrojs/check": "^0.9.6",
"@astrojs/mdx": "^4.3.13",
"@astrojs/vercel": "^8.0.0",
"@google/generative-ai": "^0.21.0",
"@tailwindcss/vite": "^4.1.18",
"@upstash/vector": "^1.1.0",
"astro": "^5.16.11",
"dotenv": "^16.4.0",
"fs-extra": "^11.2.0",
"gray-matter": "^4.0.3",
"iconify-icon": "^3.0.2",
"picocolors": "^1.1.1",
"prompts": "^2.4.2",
Expand All @@ -63,8 +71,9 @@
"@types/fs-extra": "^11.0.4",
"@types/node": "^25.0.10",
"@types/prompts": "^2.4.9",
"storybook": "^8.4.0",
"pagefind": "^1.4.0",
"storybook": "^8.4.0",
"tsx": "^4.19.0",
"vitest": "^3.0.0"
}
}
Loading
Loading