nothingworry commited on
Commit
90160c5
Β·
1 Parent(s): aa63765

update the code

Browse files
Files changed (2) hide show
  1. README.md +89 -35
  2. frontend/README.md +38 -5
README.md CHANGED
@@ -77,6 +77,8 @@ Agents can intelligently:
77
  - **Strict multi-tenant isolation** with tenant_id filtering
78
  - **Intelligent text chunking** (~300 words per chunk)
79
  - **Vector similarity search** using cosine distance
 
 
80
 
81
  ### 3. 🌐 Live Web Search Tool
82
 
@@ -121,6 +123,8 @@ Comprehensive insights for:
121
  - 🚨 Red-flag violation tracking
122
  - 🧠 Agent reasoning traces
123
  - πŸ‘₯ Tenant activity monitoring
 
 
124
 
125
  ### 7. 🏒 Multi-Tenant Isolation
126
 
@@ -149,16 +153,20 @@ Isolation is guaranteed via **Supabase Row-Level Security (RLS)**.
149
  | **Ollama / Groq** | LLM inference engine (configurable) |
150
  | **DuckDuckGo Search** | Web search provider |
151
  | **Slack / Email** | Alerting system |
 
 
152
 
153
  ### Frontend
154
 
155
  | Technology | Purpose |
156
  |------------|---------|
157
- | **React 18** | Modern UI framework |
 
158
  | **TailwindCSS** | Utility-first styling |
159
- | **Zustand** | State management |
160
  | **WebSocket** | Real-time streaming |
161
  | **Admin Dashboard** | Analytics & governance UI |
 
162
 
163
  ---
164
 
@@ -245,10 +253,14 @@ IntegraChat/
245
  β”‚ β”‚ └── embeddings.py # Sentence transformers embeddings
246
  β”‚ β”‚
247
  β”‚ β”œβ”€β”€ workers/
248
- β”‚ β”‚ β”œβ”€β”€ ingestion_worker.py
249
- β”‚ β”‚ β”œβ”€β”€ analytics_worker.py
250
- β”‚ β”‚ β”œβ”€β”€ scheduler.py
251
- β”‚ β”‚ └── celeryconfig.py
 
 
 
 
252
  β”‚ β”‚
253
  β”‚ β”œβ”€β”€ tests/
254
  β”‚ β”‚ β”œβ”€β”€ test_agent.py
@@ -260,33 +272,20 @@ IntegraChat/
260
  β”‚ └── Dockerfile
261
  β”‚
262
  β”œβ”€β”€ frontend/
263
- β”‚ β”œβ”€β”€ src/
264
- β”‚ β”‚ β”œβ”€β”€ components/
265
- β”‚ β”‚ β”‚ β”œβ”€β”€ chat/
266
- β”‚ β”‚ β”‚ β”‚ β”œβ”€β”€ ChatWindow.jsx
267
- β”‚ β”‚ β”‚ β”‚ β”œβ”€β”€ MessageBubble.jsx
268
- β”‚ β”‚ β”‚ β”‚ └── ToolTraces.jsx
269
- β”‚ β”‚ β”‚ β”œβ”€β”€ admin/
270
- β”‚ β”‚ β”‚ β”‚ β”œβ”€β”€ RedFlagEditor.jsx
271
- β”‚ β”‚ β”‚ β”‚ └── TenantManager.jsx
272
- β”‚ β”‚ β”‚ └── analytics/
273
- β”‚ β”‚ β”‚ β”œβ”€β”€ QueryStats.jsx
274
- β”‚ β”‚ β”‚ β”œβ”€β”€ ToolUsageChart.jsx
275
- β”‚ β”‚ β”‚ └── RagEffectiveness.jsx
276
- β”‚ β”‚ β”œβ”€β”€ pages/
277
- β”‚ β”‚ β”‚ β”œβ”€β”€ ChatPage.jsx
278
- β”‚ β”‚ β”‚ β”œβ”€β”€ AdminPage.jsx
279
- β”‚ β”‚ β”‚ └── AnalyticsPage.jsx
280
- β”‚ β”‚ β”œβ”€β”€ store/
281
- β”‚ β”‚ β”‚ β”œβ”€β”€ chatStore.js
282
- β”‚ β”‚ β”‚ β”œβ”€β”€ adminStore.js
283
- β”‚ β”‚ β”‚ └── analyticsStore.js
284
- β”‚ β”‚ β”œβ”€β”€ utils/
285
- β”‚ β”‚ β”‚ β”œβ”€β”€ websocket.js
286
- β”‚ β”‚ β”‚ β”œβ”€β”€ api.js
287
- β”‚ β”‚ β”‚ └── formatters.js
288
- β”‚ β”‚ β”œβ”€β”€ App.jsx
289
- β”‚ β”‚ └── main.jsx
290
  β”‚ β”œβ”€β”€ public/
291
  β”‚ └── package.json
292
  β”‚
@@ -372,6 +371,10 @@ Before you begin, ensure you have the following installed:
372
  OLLAMA_MODEL=llama3
373
  # Or use Groq instead:
374
  # GROQ_API_KEY=your_groq_api_key
 
 
 
 
375
  ```
376
 
377
  4. **Start the RAG MCP Server**
@@ -383,7 +386,16 @@ Before you begin, ensure you have the following installed:
383
  - Server runs on `http://localhost:8001`
384
  - API docs available at `http://localhost:8001/docs`
385
 
386
- 5. **Run the main API server**
 
 
 
 
 
 
 
 
 
387
  ```bash
388
  cd backend
389
  uvicorn api.main:app --reload
@@ -413,6 +425,34 @@ curl -X POST http://localhost:8001/search \
413
  }'
414
  ```
415
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
416
  ### Frontend Setup
417
 
418
  1. **Navigate to frontend directory**
@@ -425,10 +465,22 @@ curl -X POST http://localhost:8001/search \
425
  npm install
426
  ```
427
 
428
- 3. **Start the development server**
 
 
 
 
 
 
 
429
  ```bash
430
  npm run dev
431
  ```
 
 
 
 
 
432
 
433
  ### Quick Start with Docker
434
 
@@ -449,6 +501,8 @@ docker-compose up -d
449
  | 🌐 **English Web Search** | Forces English language results for better accuracy |
450
  | 🏒 **Production-Grade** | Multi-tenant design with strict Supabase RLS |
451
  | πŸ“Š **Full Observability** | Logs, analytics, tool events, violations |
 
 
452
  | 🎯 **Demo-Ready** | Perfect for enterprise presentations |
453
 
454
  ---
 
77
  - **Strict multi-tenant isolation** with tenant_id filtering
78
  - **Intelligent text chunking** (~300 words per chunk)
79
  - **Vector similarity search** using cosine distance
80
+ - **Async document ingestion** via Celery workers (PDF, DOCX, TXT support)
81
+ - **Knowledge base management UI** for document upload and search
82
 
83
  ### 3. 🌐 Live Web Search Tool
84
 
 
123
  - 🚨 Red-flag violation tracking
124
  - 🧠 Agent reasoning traces
125
  - πŸ‘₯ Tenant activity monitoring
126
+ - **Real-time analytics panel** in the frontend UI
127
+ - **Async analytics processing** via Celery workers
128
 
129
  ### 7. 🏒 Multi-Tenant Isolation
130
 
 
153
  | **Ollama / Groq** | LLM inference engine (configurable) |
154
  | **DuckDuckGo Search** | Web search provider |
155
  | **Slack / Email** | Alerting system |
156
+ | **Celery** | Async task queue for document ingestion and analytics |
157
+ | **Redis / RabbitMQ** | Message broker for Celery workers |
158
 
159
  ### Frontend
160
 
161
  | Technology | Purpose |
162
  |------------|---------|
163
+ | **Next.js 16** | React framework with App Router |
164
+ | **React 19** | Modern UI framework |
165
  | **TailwindCSS** | Utility-first styling |
166
+ | **TypeScript** | Type-safe development |
167
  | **WebSocket** | Real-time streaming |
168
  | **Admin Dashboard** | Analytics & governance UI |
169
+ | **Knowledge Base UI** | Document management interface |
170
 
171
  ---
172
 
 
253
  β”‚ β”‚ └── embeddings.py # Sentence transformers embeddings
254
  β”‚ β”‚
255
  β”‚ β”œβ”€β”€ workers/
256
+ β”‚ β”‚ β”œβ”€β”€ ingestion_worker.py # Celery tasks for document ingestion
257
+ β”‚ β”‚ β”œβ”€β”€ analytics_worker.py # Celery tasks for analytics processing
258
+ β”‚ β”‚ β”œβ”€β”€ scheduler.py # Scheduled task definitions
259
+ β”‚ β”‚ └── celeryconfig.py # Celery app configuration
260
+ β”‚ β”‚
261
+ β”‚ β”œβ”€β”€ api/
262
+ β”‚ β”‚ β”œβ”€β”€ ingestion/
263
+ β”‚ β”‚ β”‚ └── pdf.py # PDF processing utilities
264
  β”‚ β”‚
265
  β”‚ β”œβ”€β”€ tests/
266
  β”‚ β”‚ β”œβ”€β”€ test_agent.py
 
272
  β”‚ └── Dockerfile
273
  β”‚
274
  β”œβ”€β”€ frontend/
275
+ β”‚ β”œβ”€β”€ app/
276
+ β”‚ β”‚ β”œβ”€β”€ page.tsx # Main landing page
277
+ β”‚ β”‚ β”œβ”€β”€ layout.tsx # Root layout
278
+ β”‚ β”‚ β”œβ”€β”€ globals.css # Global styles
279
+ β”‚ β”‚ └── knowledge-base/
280
+ β”‚ β”‚ └── page.tsx # Knowledge base management page
281
+ β”‚ β”œβ”€β”€ components/
282
+ β”‚ β”‚ β”œβ”€β”€ chat-panel.tsx # Chat interface component
283
+ β”‚ β”‚ β”œβ”€β”€ analytics-panel.tsx # Analytics dashboard component
284
+ β”‚ β”‚ β”œβ”€β”€ knowledge-base-panel.tsx # Knowledge base search/ingest UI
285
+ β”‚ β”‚ β”œβ”€β”€ ingestion-card.tsx # Document ingestion card
286
+ β”‚ β”‚ β”œβ”€β”€ hero.tsx # Hero section
287
+ β”‚ β”‚ β”œβ”€β”€ feature-grid.tsx # Feature showcase grid
288
+ β”‚ β”‚ └── footer.tsx # Footer component
 
 
 
 
 
 
 
 
 
 
 
 
 
289
  β”‚ β”œβ”€β”€ public/
290
  β”‚ └── package.json
291
  β”‚
 
371
  OLLAMA_MODEL=llama3
372
  # Or use Groq instead:
373
  # GROQ_API_KEY=your_groq_api_key
374
+
375
+ # Celery Configuration (for async workers)
376
+ CELERY_BROKER_URL=redis://localhost:6379/0
377
+ CELERY_RESULT_BACKEND=redis://localhost:6379/0
378
  ```
379
 
380
  4. **Start the RAG MCP Server**
 
386
  - Server runs on `http://localhost:8001`
387
  - API docs available at `http://localhost:8001/docs`
388
 
389
+ 5. **Start Celery workers** (for async document ingestion and analytics)
390
+ ```bash
391
+ # Start Celery worker
392
+ celery -A backend.workers.celeryconfig worker --loglevel=info
393
+
394
+ # In another terminal, start Celery beat (for scheduled tasks)
395
+ celery -A backend.workers.celeryconfig beat --loglevel=info
396
+ ```
397
+
398
+ 6. **Run the main API server**
399
  ```bash
400
  cd backend
401
  uvicorn api.main:app --reload
 
425
  }'
426
  ```
427
 
428
+ ### Document Ingestion via Celery Workers
429
+
430
+ Documents can be ingested asynchronously using Celery workers:
431
+
432
+ **Via API endpoint (triggers Celery task):**
433
+ ```bash
434
+ curl -X POST http://localhost:8000/rag/ingest \
435
+ -H "Content-Type: application/json" \
436
+ -H "x-tenant-id: tenant123" \
437
+ -d '{
438
+ "content": "Your document text here...",
439
+ "doc_id": "doc_001"
440
+ }'
441
+ ```
442
+
443
+ **Supported formats:**
444
+ - Raw text content
445
+ - PDF files (via file upload)
446
+ - DOCX files (via file upload)
447
+ - TXT files (via file upload)
448
+ - URLs (web page content)
449
+
450
+ The ingestion worker automatically:
451
+ - Extracts text from files
452
+ - Chunks text with configurable overlap
453
+ - Generates embeddings using Sentence-Transformers
454
+ - Stores chunks and embeddings in Supabase/pgvector
455
+
456
  ### Frontend Setup
457
 
458
  1. **Navigate to frontend directory**
 
465
  npm install
466
  ```
467
 
468
+ 3. **Configure environment variables** (optional)
469
+
470
+ Create a `.env.local` file in the frontend directory:
471
+ ```env
472
+ NEXT_PUBLIC_API_URL=http://localhost:8000
473
+ ```
474
+
475
+ 4. **Start the development server**
476
  ```bash
477
  npm run dev
478
  ```
479
+
480
+ The app will be available at `http://localhost:3000` with:
481
+ - **Main landing page** with hero, features, and chat panel
482
+ - **Knowledge base page** (`/knowledge-base`) for document management
483
+ - **Analytics panel** showing query metrics and tool usage
484
 
485
  ### Quick Start with Docker
486
 
 
501
  | 🌐 **English Web Search** | Forces English language results for better accuracy |
502
  | 🏒 **Production-Grade** | Multi-tenant design with strict Supabase RLS |
503
  | πŸ“Š **Full Observability** | Logs, analytics, tool events, violations |
504
+ | πŸ“š **Knowledge Base UI** | Complete document management interface with search and ingestion |
505
+ | ⚑ **Async Processing** | Celery workers for scalable document ingestion and analytics |
506
  | 🎯 **Demo-Ready** | Perfect for enterprise presentations |
507
 
508
  ---
frontend/README.md CHANGED
@@ -3,10 +3,12 @@
3
  Next.js 16 / React 19 app that showcases everything wired up in `backend/`.
4
  It provides a polished operator console with:
5
 
6
- - Hero + feature overview describing the FastAPI + MCP stack
7
- - Live chat panel that POSTs to `POST /agent/message`
8
- - Analytics snapshot pulling from `GET /analytics/overview`
9
- - Knowledge ingestion pipeline summary tied to Celery workers
 
 
10
 
11
  ## Running Locally
12
 
@@ -16,7 +18,7 @@ npm install
16
  npm run dev
17
  ```
18
 
19
- Visit `http://localhost:3000`.
20
 
21
  ### API configuration
22
 
@@ -27,6 +29,37 @@ Update `.env.local` if your backend runs elsewhere:
27
  NEXT_PUBLIC_API_URL=http://localhost:8000
28
  ```
29
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
30
  ## Deploy
31
 
32
  Deploy like any Next.js app (Vercel, Docker, etc.). Ensure the backend endpoints are reachable from the browser and CORS is enabled (already configured in `backend/api/main.py`).
 
 
 
3
  Next.js 16 / React 19 app that showcases everything wired up in `backend/`.
4
  It provides a polished operator console with:
5
 
6
+ - **Hero section** + feature overview describing the FastAPI + MCP stack
7
+ - **Live chat panel** that POSTs to `POST /agent/message` for AI conversations
8
+ - **Analytics dashboard** pulling from `GET /analytics/overview` with real-time metrics
9
+ - **Knowledge base management** page (`/knowledge-base`) for document search and ingestion
10
+ - **Document ingestion UI** for uploading PDF, DOCX, TXT files or raw text
11
+ - **Feature grid** showcasing platform capabilities
12
 
13
  ## Running Locally
14
 
 
18
  npm run dev
19
  ```
20
 
21
+ Visit `http://localhost:3000` for the main landing page, or `http://localhost:3000/knowledge-base` for document management.
22
 
23
  ### API configuration
24
 
 
29
  NEXT_PUBLIC_API_URL=http://localhost:8000
30
  ```
31
 
32
+ ## Features
33
+
34
+ ### Main Landing Page (`/`)
35
+ - **Hero section** with platform introduction
36
+ - **Feature grid** showcasing key capabilities
37
+ - **Chat panel** for real-time AI conversations
38
+ - **Analytics panel** with query metrics and tool usage statistics
39
+ - **Ingestion card** for quick document uploads
40
+
41
+ ### Knowledge Base Page (`/knowledge-base`)
42
+ - **Document listing** with pagination and filtering
43
+ - **Search interface** for semantic search across documents
44
+ - **Document ingestion** with support for:
45
+ - Raw text input
46
+ - PDF file uploads
47
+ - DOCX file uploads
48
+ - TXT file uploads
49
+ - **Document management** with tenant isolation
50
+
51
+ ### Components
52
+
53
+ - `chat-panel.tsx` - Real-time chat interface with streaming responses
54
+ - `analytics-panel.tsx` - Analytics dashboard with metrics visualization
55
+ - `knowledge-base-panel.tsx` - Document search and ingestion component
56
+ - `ingestion-card.tsx` - Quick document upload card
57
+ - `hero.tsx` - Landing page hero section
58
+ - `feature-grid.tsx` - Feature showcase grid
59
+ - `footer.tsx` - Footer component
60
+
61
  ## Deploy
62
 
63
  Deploy like any Next.js app (Vercel, Docker, etc.). Ensure the backend endpoints are reachable from the browser and CORS is enabled (already configured in `backend/api/main.py`).
64
+
65
+ **Note:** Make sure Celery workers are running in production for document ingestion and analytics processing to work properly.