@digilogiclabs/create-saas-app 1.17.0 โ 1.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +82 -0
- package/README.md +153 -12
- package/dist/.tsbuildinfo +1 -1
- package/dist/cli/commands/create.d.ts.map +1 -1
- package/dist/cli/commands/create.js +6 -2
- package/dist/cli/commands/create.js.map +1 -1
- package/dist/cli/index.js +1 -1
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/prompts/project-setup.d.ts.map +1 -1
- package/dist/cli/prompts/project-setup.js +4 -0
- package/dist/cli/prompts/project-setup.js.map +1 -1
- package/dist/generators/template-generator.d.ts.map +1 -1
- package/dist/generators/template-generator.js +13 -7
- package/dist/generators/template-generator.js.map +1 -1
- package/dist/templates/mobile/base/template/App.tsx +2 -0
- package/dist/templates/mobile/ui-auth-payments/template/app/(tabs)/index.tsx +85 -4
- package/dist/templates/mobile/ui-auth-payments/template/app/_layout.tsx +2 -0
- package/dist/templates/mobile/ui-auth-payments-ai/template/.env.example +23 -0
- package/dist/templates/mobile/ui-auth-payments-ai/template/README.md +254 -0
- package/dist/templates/mobile/ui-auth-payments-ai/template/app/(tabs)/_layout.tsx +169 -0
- package/dist/templates/mobile/ui-auth-payments-ai/template/app/(tabs)/ai.tsx +522 -0
- package/dist/templates/mobile/ui-auth-payments-ai/template/app/(tabs)/analytics.tsx +668 -0
- package/dist/templates/mobile/ui-auth-payments-ai/template/app/(tabs)/billing.tsx +743 -0
- package/dist/templates/mobile/ui-auth-payments-ai/template/app/(tabs)/index.tsx +676 -0
- package/dist/templates/mobile/ui-auth-payments-ai/template/app/(tabs)/orders.tsx +402 -0
- package/dist/templates/mobile/ui-auth-payments-ai/template/app/(tabs)/profile.tsx +580 -0
- package/dist/templates/mobile/ui-auth-payments-ai/template/app/_layout.tsx +127 -0
- package/dist/templates/mobile/ui-auth-payments-ai/template/app/auth/login.tsx +246 -0
- package/dist/templates/mobile/ui-auth-payments-ai/template/app/auth/signup.tsx +362 -0
- package/dist/templates/mobile/ui-auth-payments-ai/template/app/onboarding/index.tsx +193 -0
- package/dist/templates/mobile/ui-auth-payments-ai/template/app/tour/index.tsx +272 -0
- package/dist/templates/mobile/ui-auth-payments-ai/template/app.json +93 -0
- package/dist/templates/mobile/ui-auth-payments-ai/template/babel.config.js +23 -0
- package/dist/templates/mobile/ui-auth-payments-ai/template/eas.json +45 -0
- package/dist/templates/mobile/ui-auth-payments-ai/template/expo-env.d.ts +3 -0
- package/dist/templates/mobile/ui-auth-payments-ai/template/jest-setup.ts +74 -0
- package/dist/templates/mobile/ui-auth-payments-ai/template/metro.config.js +11 -0
- package/dist/templates/mobile/ui-auth-payments-ai/template/package.json +108 -0
- package/dist/templates/mobile/ui-auth-payments-ai/template/tsconfig.json +31 -0
- package/dist/templates/mobile/ui-auth-payments-ai-rag/template/README.md +655 -0
- package/dist/templates/mobile/ui-auth-payments-ai-rag/template/app/(tabs)/ai.tsx +683 -0
- package/dist/templates/mobile/ui-auth-payments-ai-rag/template/docs/MOBILE-SETUP.md +787 -0
- package/dist/templates/mobile/ui-auth-payments-ai-rag/template/hooks/useRAGSystem.ts +346 -0
- package/dist/templates/mobile/ui-auth-payments-ai-rag/template/lib/rag/config.ts +180 -0
- package/dist/templates/mobile/ui-auth-payments-ai-rag/template/package.json +113 -0
- package/dist/templates/mobile/ui-auth-payments-ai-rag/template/scripts/setup-rag.js +599 -0
- package/dist/templates/web/base/template/src/app/loading.tsx +45 -27
- package/dist/templates/web/base/template/src/components/providers/app-providers.tsx +2 -0
- package/dist/templates/web/ui-auth/template/src/app/loading.tsx +30 -12
- package/dist/templates/web/ui-auth/template/src/components/providers/app-providers.tsx +2 -0
- package/dist/templates/web/ui-auth/template/src/components/shared/header.tsx +43 -2
- package/dist/templates/web/ui-auth-ai/template/package.json +1 -1
- package/dist/templates/web/ui-auth-payments/template/src/components/providers/app-providers.tsx +2 -0
- package/dist/templates/web/ui-auth-payments-ai/template/src/components/providers/app-providers.tsx +2 -0
- package/dist/templates/web/ui-auth-payments-ai-rag/template/README.md +434 -0
- package/dist/templates/web/ui-auth-payments-ai-rag/template/components/rag/KnowledgeManager.tsx +642 -0
- package/dist/templates/web/ui-auth-payments-ai-rag/template/components/rag/RAGAnalytics.tsx +466 -0
- package/dist/templates/web/ui-auth-payments-ai-rag/template/components/rag/RAGChatInterface.tsx +393 -0
- package/dist/templates/web/ui-auth-payments-ai-rag/template/docs/GETTING-STARTED.md +457 -0
- package/dist/templates/web/ui-auth-payments-ai-rag/template/hooks/useRAGSystem.ts +478 -0
- package/dist/templates/web/ui-auth-payments-ai-rag/template/lib/rag/config.ts +250 -0
- package/dist/templates/web/ui-auth-payments-ai-rag/template/package.json +74 -0
- package/dist/templates/web/ui-auth-payments-ai-rag/template/scripts/setup-rag.js +622 -0
- package/dist/templates/web/ui-auth-payments-ai-rag/template/src/app/ai/page.tsx +396 -0
- package/dist/templates/web/ui-auth-payments-audio/template/src/components/providers/app-providers.tsx +2 -0
- package/dist/templates/web/ui-auth-payments-video/template/src/components/providers/app-providers.tsx +2 -0
- package/package.json +1 -1
- package/src/templates/mobile/base/template/App.tsx +2 -0
- package/src/templates/mobile/ui-auth-payments/template/app/(tabs)/index.tsx +85 -4
- package/src/templates/mobile/ui-auth-payments/template/app/_layout.tsx +2 -0
- package/src/templates/mobile/ui-auth-payments-ai/template/.env.example +23 -0
- package/src/templates/mobile/ui-auth-payments-ai/template/README.md +254 -0
- package/src/templates/mobile/ui-auth-payments-ai/template/app/(tabs)/_layout.tsx +169 -0
- package/src/templates/mobile/ui-auth-payments-ai/template/app/(tabs)/ai.tsx +522 -0
- package/src/templates/mobile/ui-auth-payments-ai/template/app/(tabs)/analytics.tsx +668 -0
- package/src/templates/mobile/ui-auth-payments-ai/template/app/(tabs)/billing.tsx +743 -0
- package/src/templates/mobile/ui-auth-payments-ai/template/app/(tabs)/index.tsx +676 -0
- package/src/templates/mobile/ui-auth-payments-ai/template/app/(tabs)/orders.tsx +402 -0
- package/src/templates/mobile/ui-auth-payments-ai/template/app/(tabs)/profile.tsx +580 -0
- package/src/templates/mobile/ui-auth-payments-ai/template/app/_layout.tsx +127 -0
- package/src/templates/mobile/ui-auth-payments-ai/template/app/auth/login.tsx +246 -0
- package/src/templates/mobile/ui-auth-payments-ai/template/app/auth/signup.tsx +362 -0
- package/src/templates/mobile/ui-auth-payments-ai/template/app/onboarding/index.tsx +193 -0
- package/src/templates/mobile/ui-auth-payments-ai/template/app/tour/index.tsx +272 -0
- package/src/templates/mobile/ui-auth-payments-ai/template/app.json +93 -0
- package/src/templates/mobile/ui-auth-payments-ai/template/babel.config.js +23 -0
- package/src/templates/mobile/ui-auth-payments-ai/template/eas.json +45 -0
- package/src/templates/mobile/ui-auth-payments-ai/template/expo-env.d.ts +3 -0
- package/src/templates/mobile/ui-auth-payments-ai/template/jest-setup.ts +74 -0
- package/src/templates/mobile/ui-auth-payments-ai/template/metro.config.js +11 -0
- package/src/templates/mobile/ui-auth-payments-ai/template/package.json +108 -0
- package/src/templates/mobile/ui-auth-payments-ai/template/tsconfig.json +31 -0
- package/src/templates/mobile/ui-auth-payments-ai-rag/template/README.md +655 -0
- package/src/templates/mobile/ui-auth-payments-ai-rag/template/app/(tabs)/ai.tsx +683 -0
- package/src/templates/mobile/ui-auth-payments-ai-rag/template/docs/MOBILE-SETUP.md +787 -0
- package/src/templates/mobile/ui-auth-payments-ai-rag/template/hooks/useRAGSystem.ts +346 -0
- package/src/templates/mobile/ui-auth-payments-ai-rag/template/lib/rag/config.ts +180 -0
- package/src/templates/mobile/ui-auth-payments-ai-rag/template/package.json +113 -0
- package/src/templates/mobile/ui-auth-payments-ai-rag/template/scripts/setup-rag.js +599 -0
- package/src/templates/web/base/template/src/app/loading.tsx +45 -27
- package/src/templates/web/base/template/src/components/providers/app-providers.tsx +2 -0
- package/src/templates/web/ui-auth/template/src/app/loading.tsx +30 -12
- package/src/templates/web/ui-auth/template/src/components/providers/app-providers.tsx +2 -0
- package/src/templates/web/ui-auth/template/src/components/shared/header.tsx +43 -2
- package/src/templates/web/ui-auth-ai/template/package.json +1 -1
- package/src/templates/web/ui-auth-payments/template/src/components/providers/app-providers.tsx +2 -0
- package/src/templates/web/ui-auth-payments-ai/template/src/components/providers/app-providers.tsx +2 -0
- package/src/templates/web/ui-auth-payments-ai-rag/template/README.md +434 -0
- package/src/templates/web/ui-auth-payments-ai-rag/template/components/rag/KnowledgeManager.tsx +642 -0
- package/src/templates/web/ui-auth-payments-ai-rag/template/components/rag/RAGAnalytics.tsx +466 -0
- package/src/templates/web/ui-auth-payments-ai-rag/template/components/rag/RAGChatInterface.tsx +393 -0
- package/src/templates/web/ui-auth-payments-ai-rag/template/docs/GETTING-STARTED.md +457 -0
- package/src/templates/web/ui-auth-payments-ai-rag/template/hooks/useRAGSystem.ts +478 -0
- package/src/templates/web/ui-auth-payments-ai-rag/template/lib/rag/config.ts +250 -0
- package/src/templates/web/ui-auth-payments-ai-rag/template/package.json +74 -0
- package/src/templates/web/ui-auth-payments-ai-rag/template/scripts/setup-rag.js +622 -0
- package/src/templates/web/ui-auth-payments-ai-rag/template/src/app/ai/page.tsx +396 -0
- package/src/templates/web/ui-auth-payments-audio/template/src/components/providers/app-providers.tsx +2 -0
- package/src/templates/web/ui-auth-payments-video/template/src/components/providers/app-providers.tsx +2 -0
|
@@ -1,20 +1,38 @@
|
|
|
1
|
-
import { Card } from '@digilogiclabs/saas-factory-ui'
|
|
1
|
+
import { Card, SkeletonCard, SkeletonText } from '@digilogiclabs/saas-factory-ui'
|
|
2
2
|
import { Loader2 } from 'lucide-react'
|
|
3
3
|
|
|
4
4
|
export default function Loading() {
|
|
5
5
|
return (
|
|
6
|
-
<div className="min-h-screen bg-gray-50 dark:bg-gray-900
|
|
7
|
-
<
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
<
|
|
11
|
-
|
|
12
|
-
</h2>
|
|
13
|
-
<p className="text-sm text-gray-600 dark:text-gray-300">
|
|
14
|
-
Please wait while we load your content...
|
|
15
|
-
</p>
|
|
6
|
+
<div className="min-h-screen bg-gray-50 dark:bg-gray-900">
|
|
7
|
+
<div className="container mx-auto px-4 py-8">
|
|
8
|
+
{/* Header skeleton */}
|
|
9
|
+
<div className="mb-8">
|
|
10
|
+
<SkeletonText className="h-8 w-64 mb-4" />
|
|
11
|
+
<SkeletonText className="h-4 w-96" />
|
|
16
12
|
</div>
|
|
17
|
-
|
|
13
|
+
|
|
14
|
+
{/* Cards grid skeleton */}
|
|
15
|
+
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6 mb-8">
|
|
16
|
+
{Array.from({ length: 6 }).map((_, i) => (
|
|
17
|
+
<SkeletonCard key={i} />
|
|
18
|
+
))}
|
|
19
|
+
</div>
|
|
20
|
+
|
|
21
|
+
{/* Centered loading spinner */}
|
|
22
|
+
<div className="flex justify-center">
|
|
23
|
+
<Card className="w-full max-w-md p-8 text-center">
|
|
24
|
+
<div className="flex flex-col items-center">
|
|
25
|
+
<Loader2 className="h-8 w-8 animate-spin text-blue-600 dark:text-blue-400 mb-4" />
|
|
26
|
+
<h2 className="text-lg font-medium text-gray-900 dark:text-white mb-2">
|
|
27
|
+
Loading
|
|
28
|
+
</h2>
|
|
29
|
+
<p className="text-sm text-gray-600 dark:text-gray-300">
|
|
30
|
+
Please wait while we load your content...
|
|
31
|
+
</p>
|
|
32
|
+
</div>
|
|
33
|
+
</Card>
|
|
34
|
+
</div>
|
|
35
|
+
</div>
|
|
18
36
|
</div>
|
|
19
37
|
)
|
|
20
38
|
}
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import React from 'react'
|
|
4
4
|
import { ThemeProvider } from 'next-themes'
|
|
5
5
|
import { AuthProvider } from '@digilogiclabs/saas-factory-auth'
|
|
6
|
+
import { Toaster } from '@digilogiclabs/saas-factory-ui'
|
|
6
7
|
import { AppThemeProvider } from './theme-provider'
|
|
7
8
|
|
|
8
9
|
interface AppProvidersProps {
|
|
@@ -21,6 +22,7 @@ export function AppProviders({ children }: AppProvidersProps) {
|
|
|
21
22
|
<AuthProvider>
|
|
22
23
|
<AppThemeProvider themeColor="{{themeColor}}">
|
|
23
24
|
{children}
|
|
25
|
+
<Toaster />
|
|
24
26
|
</AppThemeProvider>
|
|
25
27
|
</AuthProvider>
|
|
26
28
|
</ThemeProvider>
|
|
@@ -1,17 +1,27 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import React from 'react';
|
|
3
|
+
import React, { useState } from 'react';
|
|
4
4
|
import Link from 'next/link';
|
|
5
|
-
import { LogOut } from 'lucide-react';
|
|
5
|
+
import { LogOut, Search, Command } from 'lucide-react';
|
|
6
|
+
import { SearchBar, CommandPalette, useToast } from '@digilogiclabs/saas-factory-ui';
|
|
6
7
|
import { ThemeToggle } from '../ui/theme-toggle';
|
|
7
8
|
|
|
8
9
|
export function Header() {
|
|
9
10
|
const user = null; // Placeholder for auth state
|
|
11
|
+
const [showSearch, setShowSearch] = useState(false);
|
|
12
|
+
const { toast } = useToast();
|
|
10
13
|
|
|
11
14
|
const handleSignOut = () => {
|
|
12
15
|
alert('Sign out functionality requires @digilogiclabs/saas-factory-auth package');
|
|
13
16
|
};
|
|
14
17
|
|
|
18
|
+
const handleSearch = (query: string) => {
|
|
19
|
+
toast({
|
|
20
|
+
title: "Search",
|
|
21
|
+
description: `Searching for: ${query}`,
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
|
|
15
25
|
return (
|
|
16
26
|
<header className="bg-white dark:bg-gray-800 shadow-md">
|
|
17
27
|
<div className="container mx-auto px-4 py-4 flex justify-between items-center">
|
|
@@ -19,6 +29,25 @@ export function Header() {
|
|
|
19
29
|
{{titleCaseName}}
|
|
20
30
|
</Link>
|
|
21
31
|
<nav className="flex items-center gap-4">
|
|
32
|
+
{/* Search Bar */}
|
|
33
|
+
<div className="hidden md:block">
|
|
34
|
+
<SearchBar
|
|
35
|
+
placeholder="Search..."
|
|
36
|
+
onSearch={handleSearch}
|
|
37
|
+
debounceMs={300}
|
|
38
|
+
className="w-64"
|
|
39
|
+
/>
|
|
40
|
+
</div>
|
|
41
|
+
|
|
42
|
+
{/* Mobile search toggle */}
|
|
43
|
+
<button
|
|
44
|
+
onClick={() => setShowSearch(!showSearch)}
|
|
45
|
+
className="md:hidden p-2 text-gray-600 dark:text-gray-300 hover:text-gray-900 dark:hover:text-white"
|
|
46
|
+
>
|
|
47
|
+
<Search className="h-5 w-5" />
|
|
48
|
+
</button>
|
|
49
|
+
|
|
50
|
+
<CommandPalette />
|
|
22
51
|
<ThemeToggle />
|
|
23
52
|
{user ? (
|
|
24
53
|
<>
|
|
@@ -46,6 +75,18 @@ export function Header() {
|
|
|
46
75
|
</>
|
|
47
76
|
)}
|
|
48
77
|
</nav>
|
|
78
|
+
|
|
79
|
+
{/* Mobile search bar */}
|
|
80
|
+
{showSearch && (
|
|
81
|
+
<div className="md:hidden absolute top-full left-0 right-0 p-4 bg-white dark:bg-gray-800 border-t">
|
|
82
|
+
<SearchBar
|
|
83
|
+
placeholder="Search..."
|
|
84
|
+
onSearch={handleSearch}
|
|
85
|
+
debounceMs={300}
|
|
86
|
+
autoFocus
|
|
87
|
+
/>
|
|
88
|
+
</div>
|
|
89
|
+
)}
|
|
49
90
|
</div>
|
|
50
91
|
</header>
|
|
51
92
|
);
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"clsx": "^2.0.0",
|
|
20
20
|
"tailwindcss": "^3.3.0",
|
|
21
21
|
"autoprefixer": "^10.4.16",
|
|
22
|
-
"postcss": "^8.4.31"{{#ai.enabled}}
|
|
22
|
+
"postcss": "^8.4.31",{{#ai.enabled}}
|
|
23
23
|
"@digilogiclabs/saas-factory-ai": "^3.0.0",
|
|
24
24
|
"@digilogiclabs/saas-factory-ai-types": "^3.0.0"{{/ai.enabled}}
|
|
25
25
|
},
|
package/dist/templates/web/ui-auth-payments/template/src/components/providers/app-providers.tsx
CHANGED
|
@@ -4,6 +4,7 @@ import React from 'react'
|
|
|
4
4
|
import { ThemeProvider } from 'next-themes'
|
|
5
5
|
import { AuthProvider } from '@digilogiclabs/saas-factory-auth'
|
|
6
6
|
import { PaymentsProvider } from '@digilogiclabs/saas-factory-payments'
|
|
7
|
+
import { Toaster } from '@digilogiclabs/saas-factory-ui'
|
|
7
8
|
import { AppThemeProvider } from './theme-provider'
|
|
8
9
|
|
|
9
10
|
interface AppProvidersProps {
|
|
@@ -23,6 +24,7 @@ export function AppProviders({ children }: AppProvidersProps) {
|
|
|
23
24
|
<PaymentsProvider>
|
|
24
25
|
<AppThemeProvider themeColor="{{themeColor}}">
|
|
25
26
|
{children}
|
|
27
|
+
<Toaster />
|
|
26
28
|
</AppThemeProvider>
|
|
27
29
|
</PaymentsProvider>
|
|
28
30
|
</AuthProvider>
|
package/dist/templates/web/ui-auth-payments-ai/template/src/components/providers/app-providers.tsx
CHANGED
|
@@ -4,6 +4,7 @@ import React from 'react'
|
|
|
4
4
|
import { ThemeProvider } from 'next-themes'
|
|
5
5
|
import { AuthProvider } from '@digilogiclabs/saas-factory-auth'
|
|
6
6
|
import { PaymentsProvider } from '@digilogiclabs/saas-factory-payments'
|
|
7
|
+
import { Toaster } from '@digilogiclabs/saas-factory-ui'
|
|
7
8
|
import { AppThemeProvider } from './theme-provider'
|
|
8
9
|
|
|
9
10
|
interface AppProvidersProps {
|
|
@@ -27,6 +28,7 @@ export function AppProviders({ children }: AppProvidersProps) {
|
|
|
27
28
|
<PaymentsProvider>
|
|
28
29
|
<AppThemeProvider themeColor={themeColor}>
|
|
29
30
|
{children}
|
|
31
|
+
<Toaster />
|
|
30
32
|
</AppThemeProvider>
|
|
31
33
|
</PaymentsProvider>
|
|
32
34
|
</AuthProvider>
|
|
@@ -0,0 +1,434 @@
|
|
|
1
|
+
# AI Knowledge Platform with RAG v4.0.0
|
|
2
|
+
|
|
3
|
+
A comprehensive Next.js application with AI-powered knowledge base using Retrieval-Augmented Generation (RAG), complete with authentication, payments, and advanced analytics.
|
|
4
|
+
|
|
5
|
+
## ๐ Features
|
|
6
|
+
|
|
7
|
+
### AI & Knowledge Base
|
|
8
|
+
- **RAG-Powered Chat**: Intelligent conversations with your knowledge base
|
|
9
|
+
- **Semantic Search**: Vector-based document discovery
|
|
10
|
+
- **Knowledge Management**: Full CRUD operations for documents
|
|
11
|
+
- **Real-time Analytics**: Usage insights and performance metrics
|
|
12
|
+
- **Streaming Responses**: Real-time AI response generation
|
|
13
|
+
- **Source Citations**: Always know where information comes from
|
|
14
|
+
|
|
15
|
+
### Built-in Infrastructure
|
|
16
|
+
- **Authentication**: Secure user management with Supabase
|
|
17
|
+
- **Payments**: Stripe integration for subscriptions
|
|
18
|
+
- **Database**: PostgreSQL with vector embeddings
|
|
19
|
+
- **UI Components**: Modern glassmorphic design system
|
|
20
|
+
- **TypeScript**: Full type safety throughout
|
|
21
|
+
|
|
22
|
+
### Advanced Capabilities
|
|
23
|
+
- **Multi-domain Support**: Configure for different domains (plants, e-commerce, education)
|
|
24
|
+
- **Offline Caching**: Cached responses for better performance
|
|
25
|
+
- **Bulk Operations**: Import/export knowledge in batch
|
|
26
|
+
- **Confidence Scoring**: AI response quality indicators
|
|
27
|
+
- **Feedback System**: User satisfaction tracking
|
|
28
|
+
|
|
29
|
+
## ๐๏ธ Architecture
|
|
30
|
+
|
|
31
|
+
```
|
|
32
|
+
src/
|
|
33
|
+
โโโ app/ # Next.js 15 App Router
|
|
34
|
+
โ โโโ ai/ # AI dashboard and chat interface
|
|
35
|
+
โ โโโ api/ # API routes for RAG operations
|
|
36
|
+
โ โโโ auth/ # Authentication pages
|
|
37
|
+
โโโ components/
|
|
38
|
+
โ โโโ rag/ # RAG-specific components
|
|
39
|
+
โ โโโ RAGChatInterface.tsx
|
|
40
|
+
โ โโโ KnowledgeManager.tsx
|
|
41
|
+
โ โโโ RAGAnalytics.tsx
|
|
42
|
+
โโโ hooks/
|
|
43
|
+
โ โโโ useRAGSystem.ts # Main RAG hook
|
|
44
|
+
โโโ lib/
|
|
45
|
+
โ โโโ rag/
|
|
46
|
+
โ โโโ config.ts # RAG configuration
|
|
47
|
+
โโโ types/
|
|
48
|
+
โโโ supabase.ts # Generated database types
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## ๐ ๏ธ Quick Start
|
|
52
|
+
|
|
53
|
+
### 1. Installation
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
# Create new project
|
|
57
|
+
npm create saas-app my-ai-app --template=web-ai-rag
|
|
58
|
+
|
|
59
|
+
# Navigate to project
|
|
60
|
+
cd my-ai-app
|
|
61
|
+
|
|
62
|
+
# Install dependencies
|
|
63
|
+
npm install
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### 2. Environment Setup
|
|
67
|
+
|
|
68
|
+
Create `.env.local`:
|
|
69
|
+
|
|
70
|
+
```env
|
|
71
|
+
# Supabase Configuration
|
|
72
|
+
NEXT_PUBLIC_SUPABASE_URL=your_supabase_url
|
|
73
|
+
NEXT_PUBLIC_SUPABASE_ANON_KEY=your_supabase_anon_key
|
|
74
|
+
SUPABASE_SERVICE_ROLE_KEY=your_service_role_key
|
|
75
|
+
|
|
76
|
+
# OpenAI Configuration
|
|
77
|
+
OPENAI_API_KEY=your_openai_api_key
|
|
78
|
+
|
|
79
|
+
# App Configuration
|
|
80
|
+
NEXT_PUBLIC_APP_NAME=my-ai-app
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### 3. Database Setup
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
# Setup RAG system (creates tables, functions, sample data)
|
|
87
|
+
npm run setup:rag
|
|
88
|
+
|
|
89
|
+
# Generate TypeScript types
|
|
90
|
+
npm run db:types
|
|
91
|
+
|
|
92
|
+
# Seed with sample knowledge
|
|
93
|
+
npm run seed:knowledge
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### 4. Development
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
# Start development server
|
|
100
|
+
npm run dev
|
|
101
|
+
|
|
102
|
+
# Visit your AI dashboard
|
|
103
|
+
open http://localhost:3000/ai
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
## ๐ฏ Domain Configuration
|
|
107
|
+
|
|
108
|
+
The RAG system supports multiple pre-configured domains:
|
|
109
|
+
|
|
110
|
+
### Generic AI Assistant (Default)
|
|
111
|
+
```typescript
|
|
112
|
+
const ragSystem = useRAGSystem({
|
|
113
|
+
domain: 'generic',
|
|
114
|
+
enableStreaming: true,
|
|
115
|
+
enableCache: true
|
|
116
|
+
})
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
### Plant Care Assistant
|
|
120
|
+
```typescript
|
|
121
|
+
const ragSystem = useRAGSystem({
|
|
122
|
+
domain: 'plants',
|
|
123
|
+
// Optimized for botanical queries
|
|
124
|
+
})
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
### E-commerce Assistant
|
|
128
|
+
```typescript
|
|
129
|
+
const ragSystem = useRAGSystem({
|
|
130
|
+
domain: 'ecommerce',
|
|
131
|
+
// Optimized for product queries
|
|
132
|
+
})
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
### Education Platform
|
|
136
|
+
```typescript
|
|
137
|
+
const ragSystem = useRAGSystem({
|
|
138
|
+
domain: 'education',
|
|
139
|
+
// Optimized for learning content
|
|
140
|
+
})
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
## ๐ RAG System Usage
|
|
144
|
+
|
|
145
|
+
### Basic Chat Interface
|
|
146
|
+
|
|
147
|
+
```typescript
|
|
148
|
+
import { RAGChatInterface } from '@/components/rag/RAGChatInterface'
|
|
149
|
+
|
|
150
|
+
export default function ChatPage() {
|
|
151
|
+
const ragSystem = useRAGSystem({ domain: 'generic' })
|
|
152
|
+
|
|
153
|
+
return (
|
|
154
|
+
<RAGChatInterface
|
|
155
|
+
ragSystem={ragSystem}
|
|
156
|
+
enableStreaming={true}
|
|
157
|
+
showSources={true}
|
|
158
|
+
showConfidence={true}
|
|
159
|
+
/>
|
|
160
|
+
)
|
|
161
|
+
}
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
### Knowledge Management
|
|
165
|
+
|
|
166
|
+
```typescript
|
|
167
|
+
import { KnowledgeManager } from '@/components/rag/KnowledgeManager'
|
|
168
|
+
|
|
169
|
+
export default function KnowledgePage() {
|
|
170
|
+
const ragSystem = useRAGSystem()
|
|
171
|
+
|
|
172
|
+
return (
|
|
173
|
+
<KnowledgeManager
|
|
174
|
+
ragSystem={ragSystem}
|
|
175
|
+
enableBulkOperations={true}
|
|
176
|
+
enableExport={true}
|
|
177
|
+
/>
|
|
178
|
+
)
|
|
179
|
+
}
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
### Analytics Dashboard
|
|
183
|
+
|
|
184
|
+
```typescript
|
|
185
|
+
import { RAGAnalytics } from '@/components/rag/RAGAnalytics'
|
|
186
|
+
|
|
187
|
+
export default function AnalyticsPage() {
|
|
188
|
+
const ragSystem = useRAGSystem()
|
|
189
|
+
|
|
190
|
+
return (
|
|
191
|
+
<RAGAnalytics
|
|
192
|
+
ragSystem={ragSystem}
|
|
193
|
+
timeRange="7d"
|
|
194
|
+
showDetailedMetrics={true}
|
|
195
|
+
/>
|
|
196
|
+
)
|
|
197
|
+
}
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
## ๐ง API Routes
|
|
201
|
+
|
|
202
|
+
The template includes ready-to-use API endpoints:
|
|
203
|
+
|
|
204
|
+
### Chat with RAG
|
|
205
|
+
```bash
|
|
206
|
+
POST /api/rag/chat
|
|
207
|
+
{
|
|
208
|
+
"query": "How do I get started?",
|
|
209
|
+
"category": "faq",
|
|
210
|
+
"stream": true
|
|
211
|
+
}
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
### Search Knowledge Base
|
|
215
|
+
```bash
|
|
216
|
+
GET /api/rag/search?q=getting+started&category=faq&limit=10
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
### Manage Knowledge
|
|
220
|
+
```bash
|
|
221
|
+
# Add document
|
|
222
|
+
POST /api/knowledge
|
|
223
|
+
{
|
|
224
|
+
"content": "Document content...",
|
|
225
|
+
"category": "faq",
|
|
226
|
+
"fields": { "title": "Getting Started" }
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
# Update document
|
|
230
|
+
PUT /api/knowledge/[id]
|
|
231
|
+
{
|
|
232
|
+
"content": "Updated content..."
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
# Delete document
|
|
236
|
+
DELETE /api/knowledge/[id]
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
## ๐จ UI Components
|
|
240
|
+
|
|
241
|
+
### RAG Chat Interface
|
|
242
|
+
- Streaming responses with typing indicators
|
|
243
|
+
- Source citations with confidence scores
|
|
244
|
+
- Voice input support
|
|
245
|
+
- Message history and feedback
|
|
246
|
+
- Copy/share functionality
|
|
247
|
+
|
|
248
|
+
### Knowledge Manager
|
|
249
|
+
- Document CRUD operations
|
|
250
|
+
- Bulk import/export
|
|
251
|
+
- Category filtering
|
|
252
|
+
- Full-text search
|
|
253
|
+
- Metadata management
|
|
254
|
+
|
|
255
|
+
### Analytics Dashboard
|
|
256
|
+
- Query volume trends
|
|
257
|
+
- Response time metrics
|
|
258
|
+
- Popular queries analysis
|
|
259
|
+
- User satisfaction tracking
|
|
260
|
+
- System health monitoring
|
|
261
|
+
|
|
262
|
+
## ๐ Performance Features
|
|
263
|
+
|
|
264
|
+
### Caching Strategy
|
|
265
|
+
- **Response Caching**: Frequently asked queries cached locally
|
|
266
|
+
- **Vector Caching**: Embedding reuse for similar queries
|
|
267
|
+
- **Incremental Updates**: Only sync changed documents
|
|
268
|
+
|
|
269
|
+
### Optimization
|
|
270
|
+
- **Streaming**: Real-time response generation
|
|
271
|
+
- **Debouncing**: Reduced API calls for search
|
|
272
|
+
- **Lazy Loading**: Components loaded on demand
|
|
273
|
+
- **Background Sync**: Non-blocking knowledge updates
|
|
274
|
+
|
|
275
|
+
## ๐ Security & Privacy
|
|
276
|
+
|
|
277
|
+
### Data Protection
|
|
278
|
+
- **RLS Policies**: Row-level security on all tables
|
|
279
|
+
- **Input Sanitization**: XSS protection on user inputs
|
|
280
|
+
- **Rate Limiting**: API abuse prevention
|
|
281
|
+
- **Audit Logging**: Track all knowledge operations
|
|
282
|
+
|
|
283
|
+
### API Security
|
|
284
|
+
- **Authentication Required**: Protected endpoints
|
|
285
|
+
- **CORS Configuration**: Controlled access
|
|
286
|
+
- **Environment Separation**: Dev/staging/production configs
|
|
287
|
+
|
|
288
|
+
## ๐ Deployment
|
|
289
|
+
|
|
290
|
+
### Vercel (Recommended)
|
|
291
|
+
```bash
|
|
292
|
+
# Build and deploy
|
|
293
|
+
npm run build
|
|
294
|
+
vercel --prod
|
|
295
|
+
|
|
296
|
+
# Environment variables
|
|
297
|
+
vercel env add OPENAI_API_KEY
|
|
298
|
+
vercel env add SUPABASE_SERVICE_ROLE_KEY
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
### Docker
|
|
302
|
+
```dockerfile
|
|
303
|
+
FROM node:18-alpine
|
|
304
|
+
WORKDIR /app
|
|
305
|
+
COPY package*.json ./
|
|
306
|
+
RUN npm install
|
|
307
|
+
COPY . .
|
|
308
|
+
RUN npm run build
|
|
309
|
+
CMD ["npm", "start"]
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
### Environment-specific Configs
|
|
313
|
+
```typescript
|
|
314
|
+
// lib/rag/config.ts
|
|
315
|
+
export const getEnvironmentConfig = () => ({
|
|
316
|
+
development: {
|
|
317
|
+
logging: 'debug',
|
|
318
|
+
rateLimitRpm: 300
|
|
319
|
+
},
|
|
320
|
+
production: {
|
|
321
|
+
logging: 'info',
|
|
322
|
+
rateLimitRpm: 60
|
|
323
|
+
}
|
|
324
|
+
})
|
|
325
|
+
```
|
|
326
|
+
|
|
327
|
+
## ๐ Monitoring & Analytics
|
|
328
|
+
|
|
329
|
+
### Built-in Metrics
|
|
330
|
+
- Query response times
|
|
331
|
+
- Confidence score distributions
|
|
332
|
+
- User satisfaction ratings
|
|
333
|
+
- Knowledge base growth
|
|
334
|
+
- System health indicators
|
|
335
|
+
|
|
336
|
+
### Custom Analytics
|
|
337
|
+
```typescript
|
|
338
|
+
const analytics = await ragSystem.getAnalytics('30d')
|
|
339
|
+
console.log({
|
|
340
|
+
totalQueries: analytics.usage.totalQueries,
|
|
341
|
+
averageConfidence: analytics.performance.averageConfidence,
|
|
342
|
+
popularQueries: analytics.performance.popularQueries
|
|
343
|
+
})
|
|
344
|
+
```
|
|
345
|
+
|
|
346
|
+
## ๐ฏ Customization
|
|
347
|
+
|
|
348
|
+
### Custom Domain Logic
|
|
349
|
+
```typescript
|
|
350
|
+
// lib/rag/customConfig.ts
|
|
351
|
+
export const createCustomRAGConfig = (namespace: string) => {
|
|
352
|
+
return createGenericRAGConfig(namespace, supabaseConfig, openAIKey, {
|
|
353
|
+
retrieval: {
|
|
354
|
+
topK: 8,
|
|
355
|
+
confidenceThreshold: 0.8,
|
|
356
|
+
// Custom retrieval logic
|
|
357
|
+
},
|
|
358
|
+
generation: {
|
|
359
|
+
systemPrompt: "You are a specialized assistant for...",
|
|
360
|
+
temperature: 0.2,
|
|
361
|
+
// Custom generation parameters
|
|
362
|
+
}
|
|
363
|
+
})
|
|
364
|
+
}
|
|
365
|
+
```
|
|
366
|
+
|
|
367
|
+
### UI Customization
|
|
368
|
+
```typescript
|
|
369
|
+
// Custom styling
|
|
370
|
+
<RAGChatInterface
|
|
371
|
+
className="custom-chat-styles"
|
|
372
|
+
theme={{
|
|
373
|
+
primary: '#your-brand-color',
|
|
374
|
+
background: 'custom-gradient'
|
|
375
|
+
}}
|
|
376
|
+
/>
|
|
377
|
+
```
|
|
378
|
+
|
|
379
|
+
## ๐งช Testing
|
|
380
|
+
|
|
381
|
+
### Unit Tests
|
|
382
|
+
```bash
|
|
383
|
+
npm run test
|
|
384
|
+
```
|
|
385
|
+
|
|
386
|
+
### Integration Tests
|
|
387
|
+
```bash
|
|
388
|
+
npm run test:integration
|
|
389
|
+
```
|
|
390
|
+
|
|
391
|
+
### E2E Tests
|
|
392
|
+
```bash
|
|
393
|
+
npm run test:e2e
|
|
394
|
+
```
|
|
395
|
+
|
|
396
|
+
## ๐ Advanced Topics
|
|
397
|
+
|
|
398
|
+
### Vector Embeddings
|
|
399
|
+
The system uses OpenAI's text-embedding-ada-002 model (1536 dimensions) for semantic search. Embeddings are generated server-side and stored in PostgreSQL with the pgvector extension.
|
|
400
|
+
|
|
401
|
+
### Hybrid Search
|
|
402
|
+
Combines vector similarity search with traditional full-text search for optimal results:
|
|
403
|
+
- Vector search: Semantic understanding
|
|
404
|
+
- Text search: Keyword matching
|
|
405
|
+
- Combined scoring: Weighted relevance
|
|
406
|
+
|
|
407
|
+
### Knowledge Synchronization
|
|
408
|
+
Supports incremental sync strategies:
|
|
409
|
+
- **Immediate**: Real-time updates
|
|
410
|
+
- **Batch**: Scheduled bulk updates
|
|
411
|
+
- **Manual**: User-triggered sync
|
|
412
|
+
|
|
413
|
+
## ๐ค Contributing
|
|
414
|
+
|
|
415
|
+
1. Fork the repository
|
|
416
|
+
2. Create a feature branch
|
|
417
|
+
3. Make your changes
|
|
418
|
+
4. Add tests
|
|
419
|
+
5. Submit a pull request
|
|
420
|
+
|
|
421
|
+
## ๐ License
|
|
422
|
+
|
|
423
|
+
MIT License - see LICENSE file for details
|
|
424
|
+
|
|
425
|
+
## ๐ Support
|
|
426
|
+
|
|
427
|
+
- ๐ [Documentation](https://docs.example.com/rag)
|
|
428
|
+
- ๐ฌ [Discord Community](https://discord.gg/example)
|
|
429
|
+
- ๐ [Issue Tracker](https://github.com/example/issues)
|
|
430
|
+
- โ๏ธ [Email Support](mailto:support@example.com)
|
|
431
|
+
|
|
432
|
+
---
|
|
433
|
+
|
|
434
|
+
Built with โค๏ธ using Next.js 15, Supabase, OpenAI, and RAG v4.0.0
|