autoverse-fyp 1.0.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/README.md ADDED
@@ -0,0 +1,398 @@
1
+ <p align="center">
2
+ <img src="https://img.shields.io/npm/v/autoverse-fyp?color=667eea&style=for-the-badge&labelColor=0a0a1a" alt="npm version" />
3
+ <img src="https://img.shields.io/npm/dm/autoverse-fyp?color=764ba2&style=for-the-badge&labelColor=0a0a1a" alt="downloads" />
4
+ <img src="https://img.shields.io/badge/license-MIT-34d399?style=for-the-badge&labelColor=0a0a1a" alt="license" />
5
+ </p>
6
+
7
+ <h1 align="center">🤖 Autoverse Agent</h1>
8
+
9
+ <p align="center">
10
+ <strong>Zero-config AI customer service chatbot for any website.</strong><br/>
11
+ Auto-scrapes your site, learns your products, handles orders, and talks like a real human.<br/>
12
+ Powered by Groq LLMs.
13
+ </p>
14
+
15
+ ---
16
+
17
+ ## ✨ Features
18
+
19
+ - 🚀 **One-line install** — `import "autoverse-fyp"` and the widget appears
20
+ - 🧠 **Auto-learns your site** — Scrapes products, pages, and APIs automatically
21
+ - 🛒 **Order automation** — Collects customer details and places orders step-by-step
22
+ - 🎨 **Fully customizable** — Colors, theme, position, tone via admin dashboard
23
+ - 🌍 **Bilingual** — English + Urdu with auto-detection
24
+ - 🔑 **Multi-tenant** — One server, unlimited chatbots with unique Bot IDs
25
+ - 📡 **Network interception** — Auto-indexes API responses for richer context
26
+ - 💬 **Human-like tone** — Sounds like a luxury store concierge, not a robot
27
+
28
+ ---
29
+
30
+ ## 🚀 Quick Start
31
+
32
+ - ### 1. Install the package
33
+
34
+ ```bash
35
+ npm install autoverse-fyp
36
+ ```
37
+
38
+ - ### 2. Add one line to your app
39
+
40
+ ```typescript
41
+ import "autoverse-fyp";
42
+ ```
43
+
44
+ That's it. A chat bubble appears on your website. Click it, enter your **Bot ID**, and your AI assistant is live.
45
+
46
+ ---
47
+
48
+ ## 📋 How It Works
49
+
50
+ This project is built using a highly decoupled, production-ready microservices architecture. It separates client-side embeds, administrative controls, and core RAG operations to achieve extreme performance, security, and scalability:
51
+
52
+ ```
53
+ Customer Website (Host Environment)
54
+
55
+
56
+ autoverse-agent widget (Injected client bundle)
57
+
58
+
59
+ api.autoverse.com (High-speed API gateway / autoverse-server)
60
+
61
+ ├─ AI responses (Groq Llama-3.1 + local vector RAG)
62
+ ├─ chat history
63
+ ├─ bot configs
64
+ └─ sessions
65
+
66
+
67
+ Database (Persistence Layer)
68
+
69
+
70
+ Vercel Dashboard (Decoupled Admin Panel)
71
+ ```
72
+
73
+ 1. **Deploy the backend API server (`autoverse-server`)** to **Railway** (mapping to `api.autoverse.com`)
74
+ 2. **Deploy the Admin Dashboard (`dashboard`)** to **Vercel**
75
+ 3. **Configure your Database** for storing bot configurations, chat logs, and sessions
76
+ 4. **Create a bot** in the Vercel dashboard to receive a unique Bot ID
77
+ 5. **Install the npm package (`autoverse-fyp`)** or inject the script tag on any customer website
78
+ 6. **Connect the widget** with your Bot ID, and your custom AI concierge goes live!
79
+
80
+ ---
81
+
82
+ ## 🔧 Integration Methods
83
+
84
+ ### Method 1: NPM Package (Recommended)
85
+
86
+ ```bash
87
+ npm install autoverse-fyp
88
+ ```
89
+
90
+ **Zero-config (setup via widget):**
91
+ ```typescript
92
+ import "autoverse-fyp";
93
+ ```
94
+
95
+ **Pre-configured (skip setup screen):**
96
+ ```typescript
97
+ import { initWidget } from "autoverse-fyp";
98
+
99
+ initWidget({ botId: "YOUR_BOT_ID" });
100
+ ```
101
+
102
+ ### Method 2: Script Tag (No npm needed)
103
+
104
+ ```html
105
+ <script src="https://YOUR-SERVER.com/autoverse/widget.js?botId=YOUR_BOT_ID"></script>
106
+ ```
107
+
108
+ ### Method 3: Meta Tag + Import
109
+
110
+ ```html
111
+ <meta name="autoverse-bot-id" content="YOUR_BOT_ID">
112
+ ```
113
+ ```typescript
114
+ import "autoverse-fyp";
115
+ ```
116
+
117
+ ### Method 4: Express Middleware
118
+
119
+ ```typescript
120
+ import express from "express";
121
+ import { autoverse } from "autoverse-fyp";
122
+
123
+ const app = express();
124
+ app.use(autoverse());
125
+ app.listen(3000);
126
+ ```
127
+
128
+ ---
129
+
130
+ ## 🎛️ Admin Dashboard
131
+
132
+ The Autoverse dashboard lets you manage multiple chatbots from one place.
133
+
134
+ ### Features
135
+
136
+ | Tab | What You Can Do |
137
+ |-----|----------------|
138
+ | 🎨 **Appearance** | Primary/accent colors, dark/light theme, position, bubble size, welcome message |
139
+ | 🗣️ **Tone** | Language preference, response length, custom system prompt |
140
+ | 🔗 **Integration** | Copy-paste embed codes, view Bot ID, creation date |
141
+
142
+ ### Live Preview
143
+
144
+ Changes are applied **instantly** — no redeployment needed. The widget fetches its configuration from the server on every load.
145
+
146
+ ---
147
+
148
+ ## 🛒 Order Automation
149
+
150
+ The chatbot handles the full order flow automatically:
151
+
152
+ ```
153
+ Customer: "I want to buy the Swiss Army Knife"
154
+
155
+ Bot: "Great choice! 🎉 The Swiss Army Knife is $49.99.
156
+ How many would you like?"
157
+
158
+ Customer: "2 please"
159
+
160
+ Bot: "Perfect! Could I get your full name for the order?"
161
+
162
+ Customer: "Ahmed Khan"
163
+
164
+ Bot: "Thanks Ahmed! And your phone/WhatsApp number?"
165
+
166
+ Customer: "0300-1234567"
167
+
168
+ Bot: "What's the delivery address?"
169
+
170
+ Customer: "House 12, Street 5, DHA Phase 2, Lahore"
171
+
172
+ Bot: "Would you like Cash on Delivery or online payment?"
173
+
174
+ Customer: "COD"
175
+
176
+ Bot: "Let me confirm your order:
177
+ 📦 Product: Swiss Army Knife x 2
178
+ 💸 Total: $99.98
179
+ 👤 Name: Ahmed Khan
180
+ 📱 Phone: 0300-1234567
181
+ 📍 Address: House 12, Street 5, DHA Phase 2, Lahore
182
+ 💳 Payment: Cash on Delivery
183
+
184
+ Shall I place this order for you?"
185
+
186
+ Customer: "Yes"
187
+
188
+ Bot: "✅ Order Placed Successfully!
189
+ 🎉 Order #AV-482916
190
+ Your order will be processed shortly.
191
+ By the way, you might also love these..."
192
+ ```
193
+
194
+ ---
195
+
196
+ ## 🖥️ Server Setup (autoverse-server)
197
+
198
+ ### Running Locally
199
+
200
+ ```bash
201
+ # Clone the repository
202
+ git clone https://github.com/your-repo/autoverse-agent.git
203
+ cd autoverse-agent-main
204
+
205
+ # Install dependencies for both projects
206
+ cd autoverse-server && npm install
207
+ cd ../dashboard && npm install
208
+
209
+ # Start the backend server in development mode
210
+ cd ../autoverse-server && npm run dev
211
+
212
+ # Start the admin dashboard in development mode
213
+ cd ../dashboard && npm run dev
214
+ ```
215
+
216
+ - Backend API runs at: **http://localhost:3000**
217
+ - Local Dashboard opens at: **http://localhost:5173**
218
+
219
+ ### Environment Variables
220
+
221
+ Create a `.env` file in the `autoverse-server` directory:
222
+
223
+ ```env
224
+ # Required
225
+ GROQ_API_KEY=gsk_your_api_key_here
226
+
227
+ # Optional
228
+ GROQ_MODEL=llama3-8b-8192 # AI model (default: llama3-8b-8192)
229
+ PORT=3000 # Server port (default: 3000)
230
+ PUBLIC_URL=http://localhost:3000 # Your server's public URL
231
+ ```
232
+
233
+ | Variable | Default | Description |
234
+ |----------|---------|-------------|
235
+ | `GROQ_API_KEY` | — | Your Groq API key ([get one free](https://console.groq.com)) |
236
+ | `GROQ_MODEL` | `llama3-8b-8192` | LLM model to use |
237
+ | `PORT` | `3000` | Server port |
238
+ | `PUBLIC_URL` | `http://localhost:3000` | Public URL (set this when deploying) |
239
+
240
+ ### Supported Models
241
+
242
+ | Model | Speed | Quality | Best For |
243
+ |-------|-------|---------|----------|
244
+ | `llama3-8b-8192` | ⚡ Fast | Good | Most use cases |
245
+ | `llama3-70b-8192` | Medium | Excellent | Complex queries |
246
+ | `mixtral-8x7b-32768` | Medium | Great | Long conversations |
247
+ | `gemma-7b-it` | ⚡ Fast | Good | Simple Q&A |
248
+
249
+ ---
250
+
251
+ ## 🚢 Deploy to Production
252
+
253
+ ### 1. Deploy Backend API to Railway
254
+
255
+ 1. Link your GitHub repository to [Railway](https://railway.app).
256
+ 2. Deploy the `autoverse-server` subdirectory.
257
+ 3. Configure the following environment variables:
258
+ ```env
259
+ GROQ_API_KEY=gsk_your_api_key
260
+ PUBLIC_URL=https://api.autoverse.com # Or your Railway app domain
261
+ PORT=3000
262
+ ```
263
+ 4. Set the build command:
264
+ ```bash
265
+ npm run build
266
+ ```
267
+ 5. Set the start command:
268
+ ```bash
269
+ npm start
270
+ ```
271
+
272
+ ### 2. Deploy Admin Dashboard to Vercel
273
+
274
+ 1. Import your workspace in [Vercel](https://vercel.com).
275
+ 2. Target the `dashboard` folder as the Root Directory.
276
+ 3. Configure the API build environment variable:
277
+ ```env
278
+ VITE_API_URL=https://api.autoverse.com # Point to your API gateway
279
+ ```
280
+ 4. Set the Build Command:
281
+ ```bash
282
+ npm run build
283
+ ```
284
+ 5. Set the Output Directory:
285
+ ```
286
+ dist
287
+ ```
288
+ 6. Click **Deploy**. Your dashboard is now live on Vercel's global Edge CDN!
289
+
290
+ ### 3. Deploy NPM Widget Package
291
+
292
+ 1. Sign in to your developer console on the [NPM Registry](https://npmjs.com).
293
+ 2. Inside the `autoverse-fyp` folder, verify the default `AUTOVERSE_CLOUD_URL` in `src/widget.ts` points to `https://api.autoverse.com`.
294
+ 3. Build the widget bundle:
295
+ ```bash
296
+ npm run build
297
+ ```
298
+ 4. Publish the optimized package:
299
+ ```bash
300
+ npm publish --access public
301
+ ```
302
+
303
+ ---
304
+
305
+ ## 📦 API Reference
306
+
307
+ ### `initWidget(options?)`
308
+
309
+ Initialize the chat widget manually.
310
+
311
+ ```typescript
312
+ import { initWidget } from "autoverse-fyp";
313
+
314
+ initWidget({
315
+ botId: "abc123", // Optional: skip setup screen
316
+ serverUrl: "https://my.server" // Optional: custom server URL
317
+ });
318
+ ```
319
+
320
+ | Option | Type | Default | Description |
321
+ |--------|------|---------|-------------|
322
+ | `botId` | `string` | `""` | Bot ID from dashboard. If empty, shows setup screen |
323
+ | `serverUrl` | `string` | Built-in cloud URL | Autoverse server URL |
324
+
325
+ ### `autoverse(config?)`
326
+
327
+ Express middleware for server-side integration.
328
+
329
+ ```typescript
330
+ import { autoverse } from "autoverse-fyp";
331
+
332
+ app.use(autoverse({
333
+ groqModel: "llama3-8b-8192",
334
+ groqBaseUrl: "https://api.groq.com/openai/v1",
335
+ verbose: true
336
+ }));
337
+ ```
338
+
339
+ ### `startServer(config?)`
340
+
341
+ Start a standalone Autoverse server with built-in dashboard.
342
+
343
+ ```typescript
344
+ import { startServer } from "autoverse-fyp";
345
+
346
+ startServer({
347
+ port: 3000,
348
+ publicUrl: "https://my-server.com",
349
+ groqModel: "llama3-70b-8192"
350
+ });
351
+ ```
352
+
353
+ ---
354
+
355
+ ## 🔌 REST API Endpoints
356
+
357
+ | Method | Endpoint | Description |
358
+ |--------|----------|-------------|
359
+ | `GET` | `/autoverse/widget.js` | Widget JavaScript (add `?botId=xxx`) |
360
+ | `GET` | `/autoverse/api/health` | Server health check |
361
+ | `POST` | `/autoverse/api/init` | Initialize agent for a website |
362
+ | `POST` | `/autoverse/api/chat` | Send a chat message |
363
+ | `GET` | `/autoverse/api/bots/:id/config` | Get bot appearance config |
364
+ | `POST` | `/autoverse/api/dashboard/bots` | Create a new bot |
365
+ | `GET` | `/autoverse/api/dashboard/bots` | List all bots |
366
+ | `GET` | `/autoverse/api/dashboard/bots/:id` | Get bot details |
367
+ | `PUT` | `/autoverse/api/dashboard/bots/:id` | Update bot settings |
368
+ | `DELETE` | `/autoverse/api/dashboard/bots/:id` | Delete a bot |
369
+
370
+ ---
371
+
372
+ ## 🤝 How the NPM Package Connects to the Dashboard
373
+
374
+ ```
375
+ Developer's Website Your Autoverse Server
376
+ ┌─────────────────┐ ┌─────────────────────┐
377
+ │ │ │ │
378
+ │ import │ Bot ID │ Admin Dashboard │
379
+ │ "autoverse- │ ◄──────────────── │ (create bots, │
380
+ │ fyp" │ │ customize look) │
381
+ │ │ │ │
382
+ │ 💬 Widget │ ──── API ────► │ AI Engine │
383
+ │ appears! │ ◄── Response ──── │ (Groq + RAG) │
384
+ │ │ │ │
385
+ └─────────────────┘ └─────────────────────┘
386
+ ```
387
+
388
+ 1. Admin creates a bot in the dashboard → gets a **Bot ID**
389
+ 2. Developer installs `autoverse-fyp` on their website
390
+ 3. Widget auto-appears → user enters the Bot ID
391
+ 4. Widget connects to the server → AI starts helping customers
392
+ 5. Admin can change appearance/tone anytime from the dashboard — changes apply instantly
393
+
394
+ ---
395
+
396
+ ## 📝 License
397
+
398
+ MIT © [Autoverse](https://github.com/your-repo/autoverse-fyp)
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Initialize the Autoverse chat widget.
3
+ *
4
+ * Usage:
5
+ * import "autoverse-fyp"; // auto-init
6
+ * import { initWidget } from "autoverse-fyp"; // manual
7
+ * initWidget({ botId: "abc123" });
8
+ *
9
+ * Safety:
10
+ * - Returns immediately in SSR/Node (no window)
11
+ * - Waits for DOM ready if called early
12
+ * - Prevents duplicate mounts
13
+ * - Never throws — fails silently
14
+ */
15
+ declare function initWidget(options?: {
16
+ serverUrl?: string;
17
+ botId?: string;
18
+ }): void;
19
+
20
+ export { initWidget };