furkanyllmz/feattie

TypeScript

0

8 commits

updated Jan 5, 2026

See the code

README

๐Ÿค– Feattie - AI-Powered Multi-Tenant E-Commerce Chat Platform

Embeddable AI chat widgets for e-commerce businesses. Each tenant gets their own customized AI assistant with product knowledge, semantic search, RAG (Retrieval-Augmented Generation), and fully branded chat interface.


๐Ÿ“‹ Quick Info

ComponentTechnologyPortStatus
Admin DashboardReact + Vite + TypeScript + Tailwind + shadcn/ui3000โœ…
Backend APIASP.NET Core 9.0 + Entity Framework Core5078โœ…
RAG ServicePython 3.11 + FastAPI + Sentence Transformers8000โœ…
DatabasePostgreSQL 15+5432โœ…

๐Ÿ”‘ Default Admin Credentials

  • Email: admin@example.com
  • Password: Admin123!

๐Ÿš€ Quick Start (5 Minutes)

Prerequisites

  • Node.js 18+ and npm
  • Python 3.11+
  • .NET 9.0 SDK
  • PostgreSQL 15+
  • OpenAI API Key (for embeddings & chat)

1๏ธโƒฃ Clone & Setup Database

# Clone repository
git clone <your-repo-url>
cd feattie

# Start PostgreSQL with Docker (or use existing instance)
docker run --name feattie-postgres \
  -e POSTGRES_USER=postgres \
  -e POSTGRES_PASSWORD=postgres \
  -e POSTGRES_DB=feattie \
  -p 5432:5432 \
  -d postgres:15

2๏ธโƒฃ Start Backend API (.NET)

cd authentication/SecureAuth.Api

# Restore dependencies
dotnet restore

# Update appsettings.json with your OpenAI API key
# Edit: authentication/SecureAuth.Api/appsettings.json
# Set: "OpenAI": { "ApiKey": "sk-your-key-here" }

# Run migrations
dotnet ef database update

# Start API server
dotnet run

โœ… Backend running at: http://localhost:5078

3๏ธโƒฃ Start RAG Service (Python)

# From project root
python3 -m venv .venv
source .venv/bin/activate  # On Windows: .venv\Scripts\activate

# Install dependencies
pip install -r requirements.txt

# Start RAG server
export PYTHONPATH=$PWD  # On Windows: set PYTHONPATH=%CD%
python -m uvicorn src.api.tenant_server:app --host 0.0.0.0 --port 8000 --reload

โœ… RAG Service running at: http://localhost:8000

4๏ธโƒฃ Start Admin Dashboard (React)

cd admin-dashboard

# Install dependencies
npm install

# Create .env file (if not exists)
echo "VITE_API_URL=http://localhost:5078" > .env

# Start development server
npm run dev

โœ… Admin Dashboard running at: http://localhost:3000

5๏ธโƒฃ Login & Create Your First Tenant

  1. Open browser: http://localhost:3000/auth/login
  2. Login with admin credentials (see above)
  3. Navigate to "Tenant Management"
  4. Click "Create New Tenant" button
  5. Fill in tenant details:
    • Name: Your Store Name (e.g., "My Fashion Store")
    • Slug: Auto-generated URL slug (e.g., "my-fashion-store")
    • Shopify Store URL: https://your-store.myshopify.com
    • Shopify Access Token: (Optional - leave empty for now)
    • Max Products: 10000 (default)
  6. Click "Create Tenant"
  7. Click "Sync Products" to import products from Shopify
  8. Click "Generate Embeddings" to enable AI semantic search
  9. Customize widget appearance in "Widget Settings"
  10. Get embed code and test in "Chat Test"

๐ŸŽ‰ Done! Your AI chat widget is ready to embed on your e-commerce site.


โœจ Features

๐Ÿข Multi-Tenant Architecture

  • Isolated data per business (tenant)
  • Each tenant has separate:
    • Product catalog
    • RAG configuration
    • Embeddings database
    • Chat sessions & history
    • Widget customization
    • User access control

๐ŸŽจ Fully Customizable Widget

  • Brand Colors: Primary & secondary colors with gradient support
  • Position: 4 corner positions (bottom-right, bottom-left, top-right, top-left)
  • Chat Title & Welcome Message: Custom greetings
  • Auto-open Settings: Delay timer for automatic widget opening
  • Typing Indicator: Show "AI is thinking..." animation
  • Live Preview: See changes in real-time before saving
  • Embed Code Generator: One-click copy embed code

๐Ÿ” Role-Based Access Control (RBAC)

Admin Role (Full Access)

  • โœ… Create, update, delete tenants
  • โœ… Sync products from Shopify
  • โœ… Generate embeddings for semantic search
  • โœ… View all tenants and users
  • โœ… Assign users to tenants
  • โœ… Customize widget appearance
  • โœ… Access embed code
  • โœ… View system statistics

User Role (Limited Access)

  • โœ… View assigned tenant(s) only
  • โœ… Customize widget appearance for assigned tenant
  • โœ… Test chat functionality
  • โœ… View tenant statistics
  • โŒ Cannot sync products or generate embeddings
  • โŒ Cannot access embed code
  • โŒ Cannot manage other tenants or users

๐Ÿค– AI-Powered Chat (RAG)

  • Semantic Product Search: Find products by meaning, not just keywords
  • Context-Aware Responses: AI understands conversation history
  • Product Recommendations: Smart suggestions with images and links
  • Multi-language Support: Turkish, English, and more
  • Session Management: Persistent conversations
  • Embeddings: Sentence Transformers (multilingual-e5-large)
  • LLM: OpenAI GPT-4o-mini

๐Ÿ“ฆ Shopify Integration

  • Automatic Product Sync: Import products from Shopify store
  • Public & Private API Support: Works with or without access token
  • Product Data: Title, description, price, images, variants, handle, vendor
  • Incremental Sync: Only updates changed products

๐Ÿ“Š Admin Dashboard

  • System Statistics: Total users, active users, tenants
  • Tenant Management: CRUD operations for tenants
  • User Management: Assign users to tenants with roles
  • Widget Settings: Live preview and customization
  • Chat Test: Test AI chat with real products
  • Responsive Design: Works on desktop, tablet, and mobile

๐Ÿ“– Detailed Usage Guide

Creating a Tenant

  1. Navigate to Tenant Management

    • Click "Tenant Management" in sidebar
  2. Click "Create New Tenant"

    • Fill in the form:
      • Tenant Name: Display name (e.g., "Fashion Boutique")
      • Slug: URL-safe identifier (auto-generated, e.g., "fashion-boutique")
      • Shopify Store URL: Full URL (e.g., "https://my-store.myshopify.com")
      • Shopify Access Token: (Optional) For private API access
      • Max Products: Maximum products allowed (default: 10000)
  3. Click "Create Tenant"

    • Tenant is created with default RAG configuration
    • Default settings are applied

Syncing Products

  1. Find your tenant in the list
  2. Click the three dots menu (โ‹ฎ)
  3. Select "Sync Products"
  4. Wait for sync to complete (toast notification)
  5. Product count updates in the table

Note: First sync may take a few minutes depending on product count.

Generating Embeddings

Prerequisites: Products must be synced first

  1. Click the three dots menu (โ‹ฎ) on your tenant
  2. Select "Generate Embeddings"
  3. Wait for embedding generation (may take several minutes)
  4. Embeddings count updates in tenant stats

Note: Embeddings enable semantic search. Without them, chat won't work properly.

Customizing Widget Appearance

  1. Click "Edit Settings" on your tenant

  2. Appearance Tab:

    • Primary Color: Main brand color (buttons, header)
    • Secondary Color: Secondary color (user messages)
    • Widget Position: Choose from 4 corners
    • Chat Title: e.g., "Shop Assistant"
    • Welcome Message: First message shown to users
  3. Behavior Tab:

    • Auto-open: Enable/disable automatic widget opening
    • Auto-open Delay: Seconds before auto-open (5-60s)
    • Typing Indicator: Show "AI is thinking..." animation
  4. Live Preview:

    • See changes in real-time on the right side
    • Preview shows actual widget appearance
  5. Click "Save Settings"

Getting Embed Code (Admin Only)

  1. Go to tenant settings
  2. Click "Embed Code" tab
  3. Copy the JavaScript code
  4. Paste before </body> tag in your website:
<!-- Feattie Chat Widget -->
<script>
  window.FeattieChat = {
    tenantId: 1,
    tenantSlug: 'your-store',
    apiUrl: 'http://localhost:5078',
    customization: {
      primaryColor: '#6366f1',
      secondaryColor: '#8b5cf6',
      position: 'bottom-right',
      chatTitle: 'Chat with us',
      welcomeMessage: 'Hello! How can I help you today?',
      autoOpen: false,
      autoOpenDelay: 5,
      showTypingIndicator: true
    }
  };
</script>
<script src="http://localhost:5078/widget/widget.js"></script>

Managing Users (Admin Only)

  1. Navigate to "Users Management"
  2. Find user in the list
  3. Click three dots menu (โ‹ฎ)
  4. Select "Manage Tenants"
  5. Check/uncheck tenants to assign/remove
  6. User can now access assigned tenants

Testing Chat

  1. Navigate to "Chat Test"
  2. Select tenant from dropdown
  3. Type a message: e.g., "Show me blue dresses under $100"
  4. AI responds with relevant products
  5. Test different queries to verify RAG is working

โš™๏ธ Configuration

Backend API Configuration

File: authentication/SecureAuth.Api/appsettings.json

{
  "ConnectionStrings": {
    "Default": "Host=localhost;Port=5432;Database=feattie;Username=postgres;Password=postgres"
  },
  "Jwt": {
    "Secret": "your-super-secret-jwt-key-minimum-32-characters-required-for-production",
    "Issuer": "SecureAuth.Api",
    "Audience": "SecureAuth.Client",
    "ExpiryMinutes": 60
  },
  "Cors": {
    "AllowedOrigins": ["http://localhost:5173", "http://localhost:3000"]
  },
  "PythonRAG": {
    "BaseUrl": "http://localhost:8000"
  },
  "OpenAI": {
    "ApiKey": "sk-your-openai-api-key-here"
  }
}

Frontend Configuration

File: admin-dashboard/.env

VITE_API_URL=http://localhost:5078

Python RAG Configuration

File: .env (project root)

OPENAI_API_KEY=sk-your-openai-api-key-here

๐Ÿ—๏ธ System Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                    Customer Website                          โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”‚
โ”‚  โ”‚  Embedded Chat Widget (JavaScript)                 โ”‚    โ”‚
โ”‚  โ”‚  - Loads tenant config via API                     โ”‚    โ”‚
โ”‚  โ”‚  - Renders chat interface                          โ”‚    โ”‚
โ”‚  โ”‚  - Sends messages to chat endpoint                 โ”‚    โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                      โ”‚ HTTP/HTTPS
                      โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚            .NET Core API (Port 5078)                         โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”‚
โ”‚  โ”‚  Public Endpoints (No Authentication):               โ”‚  โ”‚
โ”‚  โ”‚  - GET  /api/widget/config/{slug}                    โ”‚  โ”‚
โ”‚  โ”‚  - POST /api/chat/{tenantId}                         โ”‚  โ”‚
โ”‚  โ”‚  - GET  /api/chat/{tenantId}/history/{sessionId}    โ”‚  โ”‚
โ”‚  โ”‚  - GET  /widget/widget.js                            โ”‚  โ”‚
โ”‚  โ”‚                                                       โ”‚  โ”‚
โ”‚  โ”‚  Authenticated Endpoints:                            โ”‚  โ”‚
โ”‚  โ”‚  - POST /api/auth/login                              โ”‚  โ”‚
โ”‚  โ”‚  - GET  /api/tenant                                  โ”‚  โ”‚
โ”‚  โ”‚  - POST /api/tenant                                  โ”‚  โ”‚
โ”‚  โ”‚  - GET  /api/tenants/{id}/settings                  โ”‚  โ”‚
โ”‚  โ”‚  - PUT  /api/tenants/{id}/settings                  โ”‚  โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
             โ”‚                        โ”‚
             โ”‚                        โ”‚ HTTP
             โ–ผ                        โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚   PostgreSQL DB      โ”‚  โ”‚   Python RAG Service (Port 8000) โ”‚
โ”‚   (Port 5432)        โ”‚  โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚
โ”‚                      โ”‚  โ”‚  โ”‚ - Sentence Transformers     โ”‚ โ”‚
โ”‚  - Users             โ”‚  โ”‚  โ”‚ - OpenAI GPT-4o-mini        โ”‚ โ”‚
โ”‚  - Tenants           โ”‚  โ”‚  โ”‚ - Embedding generation      โ”‚ โ”‚
โ”‚  - TenantSettings    โ”‚  โ”‚  โ”‚ - Semantic search           โ”‚ โ”‚
โ”‚  - Products          โ”‚  โ”‚  โ”‚ - RAG pipeline              โ”‚ โ”‚
โ”‚  - ChatSessions      โ”‚  โ”‚  โ”‚ - Context injection         โ”‚ โ”‚
โ”‚  - ChatMessages      โ”‚  โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚
โ”‚  - Contexts          โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
โ”‚  - RAGConfigurations โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚         Admin Dashboard (React + Vite - Port 3000)          โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”‚
โ”‚  โ”‚  Pages:                                              โ”‚  โ”‚
โ”‚  โ”‚  - Dashboard (system stats)                          โ”‚  โ”‚
โ”‚  โ”‚  - Tenant Management (CRUD)                          โ”‚  โ”‚
โ”‚  โ”‚  - User Management (assign to tenants)               โ”‚  โ”‚
โ”‚  โ”‚  - Widget Settings (customization + live preview)    โ”‚  โ”‚
โ”‚  โ”‚  - Chat Test (test AI chat)                          โ”‚  โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

๐Ÿ“ก API Endpoints

Public Endpoints (No Authentication Required)

MethodEndpointDescriptionBody
GET/api/widget/config/{tenantSlug}Get widget configuration-
POST/api/chat/{tenantId}Send chat message{ query, sessionId?, topK? }
GET/api/chat/{tenantId}/history/{sessionId}Get chat history-
GET/widget/widget.jsWidget JavaScript file-

Authentication Endpoints

MethodEndpointDescriptionBody
POST/api/auth/loginLogin{ email, password }
POST/api/auth/registerRegister new user{ email, password, firstName?, lastName? }
POST/api/auth/logoutLogout-
GET/api/auth/meGet current user info-
GET/api/auth/me/tenantsGet user's assigned tenants-

Tenant Management (Admin Only)

MethodEndpointDescriptionBody
GET/api/tenantList all tenantsQuery: isActive?, page?, pageSize?
GET/api/tenant/{id}Get tenant by ID-
GET/api/tenant/by-slug/{slug}Get tenant by slug-
POST/api/tenantCreate new tenant{ Name, Slug, ShopifyStoreUrl, ShopifyAccessToken?, MaxProducts? }
PUT/api/tenant/{id}Update tenant{ Name?, ShopifyStoreUrl?, IsActive?, MaxProducts? }
DELETE/api/tenant/{id}Delete tenant (soft delete)Query: permanent?
GET/api/tenant/{id}/statsGet tenant statistics-

User-Tenant Management (Admin Only)

MethodEndpointDescriptionBody
GET/api/auth/admin/usersList all usersQuery: search?, page?, pageSize?
GET/api/auth/admin/users/{userId}/tenantsGet user's tenants-
POST/api/auth/admin/users/{userId}/tenants/{tenantId}Assign user to tenant{ role? }
DELETE/api/auth/admin/users/{userId}/tenants/{tenantId}Remove user from tenant-

Tenant Settings (User & Admin)

MethodEndpointDescriptionBody
GET/api/tenants/{id}/settingsGet tenant settings-
PUT/api/tenants/{id}/settingsUpdate tenant settings{ brandColorPrimary?, brandColorSecondary?, widgetPosition?, chatTitle?, welcomeMessage?, autoOpen?, autoOpenDelaySeconds?, showTypingIndicator? }
GET/api/tenants/{id}/settings/embed-codeGet embed code (Admin)-

Product Management (Admin Only)

MethodEndpointDescriptionBody
GET/api/tenants/{id}/productsList productsQuery: hasEmbedding?, page?, pageSize?
POST/api/tenants/{id}/products/syncSync products from Shopify{ forceResync? }
POST/api/tenants/{id}/products/generate-embeddingsGenerate embeddings{ forceRegenerate? }
GET/api/tenants/{id}/products/statsGet product statistics-

RAG Configuration (Admin Only)

MethodEndpointDescriptionBody
GET/api/tenants/{id}/rag-configGet RAG configuration-
PUT/api/tenants/{id}/rag-configUpdate RAG configuration{ embeddingModel?, llmModel?, systemPrompt?, temperature?, ... }

๐Ÿ—‚๏ธ Project Structure

feattie/
โ”œโ”€โ”€ authentication/SecureAuth.Api/        # .NET Core Backend API
โ”‚   โ”œโ”€โ”€ Controllers/
โ”‚   โ”‚   โ”œโ”€โ”€ AuthController.cs            # Authentication & user management
โ”‚   โ”‚   โ”œโ”€โ”€ TenantController.cs          # Tenant CRUD operations
โ”‚   โ”‚   โ”œโ”€โ”€ TenantSettingsController.cs  # Widget settings
โ”‚   โ”‚   โ”œโ”€โ”€ ChatController.cs            # Chat API
โ”‚   โ”‚   โ”œโ”€โ”€ ProductController.cs         # Product sync & embeddings
โ”‚   โ”‚   โ””โ”€โ”€ RAGConfigurationController.cs # RAG settings
โ”‚   โ”œโ”€โ”€ Models/
โ”‚   โ”‚   โ”œโ”€โ”€ User.cs                      # User model
โ”‚   โ”‚   โ”œโ”€โ”€ Tenant.cs                    # Tenant model
โ”‚   โ”‚   โ”œโ”€โ”€ TenantUser.cs                # User-Tenant junction
โ”‚   โ”‚   โ”œโ”€โ”€ TenantSettings.cs            # Widget settings
โ”‚   โ”‚   โ”œโ”€โ”€ Product.cs                   # Product model
โ”‚   โ”‚   โ”œโ”€โ”€ ChatSession.cs               # Chat session
โ”‚   โ”‚   โ”œโ”€โ”€ ChatMessage.cs               # Chat message
โ”‚   โ”‚   โ”œโ”€โ”€ RAGConfiguration.cs          # RAG config
โ”‚   โ”‚   โ””โ”€โ”€ Context.cs                   # Custom context
โ”‚   โ”œโ”€โ”€ Services/
โ”‚   โ”‚   โ”œโ”€โ”€ ShopifyService.cs            # Shopify integration
โ”‚   โ”‚   โ”œโ”€โ”€ PythonRAGService.cs          # Python RAG client
โ”‚   โ”‚   โ””โ”€โ”€ ProductService.cs            # Product operations
โ”‚   โ”œโ”€โ”€ Data/
โ”‚   โ”‚   โ””โ”€โ”€ AppDbContext.cs              # Entity Framework DbContext
โ”‚   โ”œโ”€โ”€ DTOs/                             # Data Transfer Objects
โ”‚   โ”œโ”€โ”€ Migrations/                       # EF Core migrations
โ”‚   โ”œโ”€โ”€ wwwroot/widget/
โ”‚   โ”‚   โ””โ”€โ”€ widget.js                    # Embeddable widget script
โ”‚   โ”œโ”€โ”€ Program.cs                        # Application entry point
โ”‚   โ”œโ”€โ”€ appsettings.json                 # Configuration
โ”‚   โ””โ”€โ”€ appsettings.Development.json     # Dev configuration
โ”‚
โ”œโ”€โ”€ admin-dashboard/                      # React Admin Dashboard
โ”‚   โ”œโ”€โ”€ app/                              # Next.js App Router
โ”‚   โ”‚   โ”œโ”€โ”€ page.tsx                     # Dashboard home
โ”‚   โ”‚   โ”œโ”€โ”€ tenants/
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ page.tsx                 # Tenant management
โ”‚   โ”‚   โ”œโ”€โ”€ users/
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ page.tsx                 # User management
โ”‚   โ”‚   โ”œโ”€โ”€ tenant-settings/
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ page.tsx                 # Widget settings
โ”‚   โ”‚   โ”œโ”€โ”€ chat/
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ page.tsx                 # Chat test
โ”‚   โ”‚   โ””โ”€โ”€ auth/
โ”‚   โ”‚       โ””โ”€โ”€ login/
โ”‚   โ”‚           โ””โ”€โ”€ page.tsx             # Login page
โ”‚   โ”œโ”€โ”€ components/
โ”‚   โ”‚   โ”œโ”€โ”€ ui/                          # shadcn/ui components
โ”‚   โ”‚   โ””โ”€โ”€ AdminLayout.tsx              # Layout with sidebar
โ”‚   โ”œโ”€โ”€ contexts/
โ”‚   โ”‚   โ””โ”€โ”€ AuthContext.tsx              # Authentication context
โ”‚   โ”œโ”€โ”€ lib/
โ”‚   โ”‚   โ”œโ”€โ”€ api.ts                       # API client (axios)
โ”‚   โ”‚   โ””โ”€โ”€ utils.ts                     # Utility functions
โ”‚   โ”œโ”€โ”€ hooks/
โ”‚   โ”‚   โ””โ”€โ”€ use-toast.tsx                # Toast notifications
โ”‚   โ”œโ”€โ”€ package.json
โ”‚   โ”œโ”€โ”€ vite.config.ts
โ”‚   โ”œโ”€โ”€ tailwind.config.js
โ”‚   โ””โ”€โ”€ .env                              # Environment variables
โ”‚
โ”œโ”€โ”€ src/                                  # Python RAG Service
โ”‚   โ”œโ”€โ”€ api/
โ”‚   โ”‚   โ””โ”€โ”€ tenant_server.py             # FastAPI server
โ”‚   โ”œโ”€โ”€ embeddings/
โ”‚   โ”‚   โ”œโ”€โ”€ local_embeddings.py          # Sentence Transformers
โ”‚   โ”‚   โ””โ”€โ”€ openai_embeddings.py         # OpenAI embeddings
โ”‚   โ”œโ”€โ”€ models/
โ”‚   โ”‚   โ””โ”€โ”€ tenant_models.py             # Pydantic models
โ”‚   โ””โ”€โ”€ services/
โ”‚       โ”œโ”€โ”€ llm_service.py               # OpenAI LLM integration
โ”‚       โ””โ”€โ”€ rag_service.py               # RAG pipeline
โ”‚
โ”œโ”€โ”€ scripts/
โ”‚   โ”œโ”€โ”€ shop_pull.py                     # Shopify product scraper
โ”‚   โ””โ”€โ”€ add-admin.sh                     # Add admin user script
โ”‚
โ”œโ”€โ”€ requirements.txt                      # Python dependencies
โ”œโ”€โ”€ package.json                          # Project metadata
โ”œโ”€โ”€ .env                                  # Environment variables
โ”œโ”€โ”€ .env.example                          # Example env file
โ”œโ”€โ”€ README.md                             # This file
โ”œโ”€โ”€ QUICK_START.md                        # Quick start guide
โ””โ”€โ”€ OPENAI_SETUP.md                       # OpenAI setup guide

๐Ÿ› Troubleshooting

Port Already in Use

# Kill processes on specific ports
lsof -ti:5078 | xargs kill -9  # .NET API
lsof -ti:8000 | xargs kill -9  # Python RAG
lsof -ti:5173 | xargs kill -9  # Admin Dashboard
lsof -ti:5432 | xargs kill -9  # PostgreSQL

# Or kill all at once
lsof -ti:5078,8000,5173 | xargs kill -9

Database Connection Failed

  1. Check PostgreSQL is running:

    pg_isready -h localhost -p 5432
    
  2. Check connection string in appsettings.json:

    "ConnectionStrings": {
      "Default": "Host=localhost;Port=5432;Database=feattie;Username=postgres;Password=postgres"
    }
    
  3. Ensure database exists:

    psql -U postgres
    CREATE DATABASE feattie;
    \q
    
  4. Run migrations:

    cd authentication/SecureAuth.Api
    dotnet ef database update
    

Python Module Not Found

# Activate virtual environment
source .venv/bin/activate  # macOS/Linux
.venv\Scripts\activate     # Windows

# Set PYTHONPATH
export PYTHONPATH=$PWD     # macOS/Linux
set PYTHONPATH=%CD%        # Windows

# Reinstall dependencies
pip install -r requirements.txt --upgrade

Migrations Error

cd authentication/SecureAuth.Api

# Drop and recreate database (WARNING: deletes all data)
dotnet ef database drop --force
dotnet ef database update

# Or create new migration
dotnet ef migrations add YourMigrationName
dotnet ef database update

Chat Not Working

Checklist:

  1. โœ… All 3 services running (API, RAG, Frontend)
  2. โœ… Tenant has products synced
  3. โœ… Embeddings are generated for products
  4. โœ… OpenAI API key is set in appsettings.json
  5. โœ… RAG service URL is correct in appsettings.json
  6. โœ… Check browser console for errors
  7. โœ… Check API logs for errors
  8. โœ… Check RAG service logs for errors

CORS Errors

Update appsettings.json:

"Cors": {
  "AllowedOrigins": [
    "http://localhost:5173",
    "http://localhost:3000",
    "https://your-production-domain.com"
  ]
}

Widget Not Loading

  1. Check widget URL is correct
  2. Check CORS is configured for customer domain
  3. Check tenant slug is correct
  4. Open browser console and check for errors
  5. Verify tenant is active: IsActive = true

๐Ÿ”’ Security & Production Deployment

Pre-Production Checklist

  • Change default admin password
  • Use strong JWT secret (32+ characters, random)
  • Enable HTTPS/SSL
  • Store API keys in environment variables (not in code)
  • Set AllowedOrigins in CORS to actual domain
  • Enable rate limiting
  • Set up regular database backups
  • Update all dependencies
  • Remove default test users
  • Set ASPNETCORE_ENVIRONMENT=Production
  • Use production-grade PostgreSQL (e.g., RDS, Azure DB)
  • Set up logging (Serilog, Application Insights)
  • Set up monitoring (health checks, uptime)

Environment Variables (Production)

# .NET API
ASPNETCORE_ENVIRONMENT=Production
ConnectionStrings__Default="Host=prod-db.example.com;Port=5432;Database=feattie;Username=app_user;Password=secure_password"
Jwt__Secret="production-secret-key-at-least-32-characters-long-and-random"
Jwt__ExpiryMinutes=60
OpenAI__ApiKey="sk-prod-openai-api-key"
Cors__AllowedOrigins__0="https://admin.yourdomain.com"
PythonRAG__BaseUrl="https://rag.yourdomain.com"

# Python RAG
OPENAI_API_KEY="sk-prod-openai-api-key"
PYTHONPATH=/app

# Admin Dashboard (build time)
VITE_API_URL=https://api.yourdomain.com

Required API Keys

  1. OpenAI API Key

    • Get from: https://platform.openai.com/api-keys
    • Used for: Embeddings (text-embedding-3-small) & Chat (gpt-4o-mini)
    • Pricing: ~$0.02 per 1M tokens (embeddings), ~$0.15 per 1M tokens (chat)
  2. Shopify Access Token (per tenant, optional)

    • For private apps: Create in Shopify Admin โ†’ Apps โ†’ Develop apps
    • Required permissions: read_products
    • Not required if using public Shopify API

Production Deployment (Docker)

# Dockerfile for .NET API
FROM mcr.microsoft.com/dotnet/aspnet:9.0 AS base
WORKDIR /app
EXPOSE 5078

FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build
WORKDIR /src
COPY ["authentication/SecureAuth.Api/SecureAuth.Api.csproj", "authentication/SecureAuth.Api/"]
RUN dotnet restore "authentication/SecureAuth.Api/SecureAuth.Api.csproj"
COPY . .
WORKDIR "/src/authentication/SecureAuth.Api"
RUN dotnet build "SecureAuth.Api.csproj" -c Release -o /app/build
RUN dotnet publish "SecureAuth.Api.csproj" -c Release -o /app/publish

FROM base AS final
WORKDIR /app
COPY --from=build /app/publish .
ENTRYPOINT ["dotnet", "SecureAuth.Api.dll"]
# docker-compose.yml
version: '3.8'

services:
  postgres:
    image: postgres:15
    environment:
      POSTGRES_USER: postgres
      POSTGRES_PASSWORD: ${DB_PASSWORD}
      POSTGRES_DB: feattie
    ports:
      - "5432:5432"
    volumes:
      - postgres_data:/var/lib/postgresql/data

  api:
    build:
      context: .
      dockerfile: Dockerfile.api
    ports:
      - "5078:5078"
    environment:
      - ConnectionStrings__Default=Host=postgres;Database=feattie;Username=postgres;Password=${DB_PASSWORD}
      - Jwt__Secret=${JWT_SECRET}
      - OpenAI__ApiKey=${OPENAI_API_KEY}
    depends_on:
      - postgres

  rag:
    build:
      context: .
      dockerfile: Dockerfile.rag
    ports:
      - "8000:8000"
    environment:
      - OPENAI_API_KEY=${OPENAI_API_KEY}
      - PYTHONPATH=/app
    depends_on:
      - postgres

  admin:
    build:
      context: ./admin-dashboard
      dockerfile: Dockerfile
    ports:
      - "5173:80"
    environment:
      - VITE_API_URL=http://api:5078

volumes:
  postgres_data:

๐Ÿ“Š Database Schema

Key Tables

  • Users: User accounts (admin & regular users)
  • Tenants: Business accounts (e-commerce stores)
  • TenantUsers: Many-to-many relationship (users can access multiple tenants)
  • TenantSettings: Widget customization per tenant
  • Products: Product catalog per tenant
  • RAGConfigurations: AI/LLM settings per tenant
  • Contexts: Custom context snippets per tenant
  • ChatSessions: Chat sessions
  • ChatMessages: Chat message history

๐Ÿ“ Default Test Users

EmailPasswordRoleTenants Assigned
admin@example.comAdmin123!AdminAll
admin@test.comTest123!AdminAll
john@test.comTest123!UserNone (assign manually)
jane@test.comTest123!UserNone (assign manually)

๐Ÿค Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

๐Ÿ“„ License

MIT License - see LICENSE file for details


๐Ÿ™ Support & Contact

For questions, issues, or feature requests:

  • GitHub Issues: [Your Repo Issues]
  • Email: [Your Email]
  • Documentation: See QUICK_START.md and OPENAI_SETUP.md

๐ŸŽฏ Roadmap

v1.1 (Coming Soon)

  • Widget analytics (views, messages, conversions)
  • Multiple language support for dashboard
  • Email notifications for admins
  • Webhook support for Shopify product updates
  • Custom CSS editor with syntax highlighting

v1.2 (Future)

  • WooCommerce integration
  • WhatsApp integration
  • Voice chat support
  • A/B testing for widget variants
  • Mobile app for admin dashboard

Built with โค๏ธ for modern e-commerce businesses

Powered by: .NET 9.0 | React 18 | OpenAI | PostgreSQL | Python 3.11

furkanyllmz/feattie

TypeScript

0

8 commits

updated Jan 5, 2026

See the code

README

๐Ÿค– Feattie - AI-Powered Multi-Tenant E-Commerce Chat Platform

Embeddable AI chat widgets for e-commerce businesses. Each tenant gets their own customized AI assistant with product knowledge, semantic search, RAG (Retrieval-Augmented Generation), and fully branded chat interface.


๐Ÿ“‹ Quick Info

ComponentTechnologyPortStatus
Admin DashboardReact + Vite + TypeScript + Tailwind + shadcn/ui3000โœ…
Backend APIASP.NET Core 9.0 + Entity Framework Core5078โœ…
RAG ServicePython 3.11 + FastAPI + Sentence Transformers8000โœ…
DatabasePostgreSQL 15+5432โœ…

๐Ÿ”‘ Default Admin Credentials

  • Email: admin@example.com
  • Password: Admin123!

๐Ÿš€ Quick Start (5 Minutes)

Prerequisites

  • Node.js 18+ and npm
  • Python 3.11+
  • .NET 9.0 SDK
  • PostgreSQL 15+
  • OpenAI API Key (for embeddings & chat)

1๏ธโƒฃ Clone & Setup Database

# Clone repository
git clone <your-repo-url>
cd feattie

# Start PostgreSQL with Docker (or use existing instance)
docker run --name feattie-postgres \
  -e POSTGRES_USER=postgres \
  -e POSTGRES_PASSWORD=postgres \
  -e POSTGRES_DB=feattie \
  -p 5432:5432 \
  -d postgres:15

2๏ธโƒฃ Start Backend API (.NET)

cd authentication/SecureAuth.Api

# Restore dependencies
dotnet restore

# Update appsettings.json with your OpenAI API key
# Edit: authentication/SecureAuth.Api/appsettings.json
# Set: "OpenAI": { "ApiKey": "sk-your-key-here" }

# Run migrations
dotnet ef database update

# Start API server
dotnet run

โœ… Backend running at: http://localhost:5078

3๏ธโƒฃ Start RAG Service (Python)

# From project root
python3 -m venv .venv
source .venv/bin/activate  # On Windows: .venv\Scripts\activate

# Install dependencies
pip install -r requirements.txt

# Start RAG server
export PYTHONPATH=$PWD  # On Windows: set PYTHONPATH=%CD%
python -m uvicorn src.api.tenant_server:app --host 0.0.0.0 --port 8000 --reload

โœ… RAG Service running at: http://localhost:8000

4๏ธโƒฃ Start Admin Dashboard (React)

cd admin-dashboard

# Install dependencies
npm install

# Create .env file (if not exists)
echo "VITE_API_URL=http://localhost:5078" > .env

# Start development server
npm run dev

โœ… Admin Dashboard running at: http://localhost:3000

5๏ธโƒฃ Login & Create Your First Tenant

  1. Open browser: http://localhost:3000/auth/login
  2. Login with admin credentials (see above)
  3. Navigate to "Tenant Management"
  4. Click "Create New Tenant" button
  5. Fill in tenant details:
    • Name: Your Store Name (e.g., "My Fashion Store")
    • Slug: Auto-generated URL slug (e.g., "my-fashion-store")
    • Shopify Store URL: https://your-store.myshopify.com
    • Shopify Access Token: (Optional - leave empty for now)
    • Max Products: 10000 (default)
  6. Click "Create Tenant"
  7. Click "Sync Products" to import products from Shopify
  8. Click "Generate Embeddings" to enable AI semantic search
  9. Customize widget appearance in "Widget Settings"
  10. Get embed code and test in "Chat Test"

๐ŸŽ‰ Done! Your AI chat widget is ready to embed on your e-commerce site.


โœจ Features

๐Ÿข Multi-Tenant Architecture

  • Isolated data per business (tenant)
  • Each tenant has separate:
    • Product catalog
    • RAG configuration
    • Embeddings database
    • Chat sessions & history
    • Widget customization
    • User access control

๐ŸŽจ Fully Customizable Widget

  • Brand Colors: Primary & secondary colors with gradient support
  • Position: 4 corner positions (bottom-right, bottom-left, top-right, top-left)
  • Chat Title & Welcome Message: Custom greetings
  • Auto-open Settings: Delay timer for automatic widget opening
  • Typing Indicator: Show "AI is thinking..." animation
  • Live Preview: See changes in real-time before saving
  • Embed Code Generator: One-click copy embed code

๐Ÿ” Role-Based Access Control (RBAC)

Admin Role (Full Access)

  • โœ… Create, update, delete tenants
  • โœ… Sync products from Shopify
  • โœ… Generate embeddings for semantic search
  • โœ… View all tenants and users
  • โœ… Assign users to tenants
  • โœ… Customize widget appearance
  • โœ… Access embed code
  • โœ… View system statistics

User Role (Limited Access)

  • โœ… View assigned tenant(s) only
  • โœ… Customize widget appearance for assigned tenant
  • โœ… Test chat functionality
  • โœ… View tenant statistics
  • โŒ Cannot sync products or generate embeddings
  • โŒ Cannot access embed code
  • โŒ Cannot manage other tenants or users

๐Ÿค– AI-Powered Chat (RAG)

  • Semantic Product Search: Find products by meaning, not just keywords
  • Context-Aware Responses: AI understands conversation history
  • Product Recommendations: Smart suggestions with images and links
  • Multi-language Support: Turkish, English, and more
  • Session Management: Persistent conversations
  • Embeddings: Sentence Transformers (multilingual-e5-large)
  • LLM: OpenAI GPT-4o-mini

๐Ÿ“ฆ Shopify Integration

  • Automatic Product Sync: Import products from Shopify store
  • Public & Private API Support: Works with or without access token
  • Product Data: Title, description, price, images, variants, handle, vendor
  • Incremental Sync: Only updates changed products

๐Ÿ“Š Admin Dashboard

  • System Statistics: Total users, active users, tenants
  • Tenant Management: CRUD operations for tenants
  • User Management: Assign users to tenants with roles
  • Widget Settings: Live preview and customization
  • Chat Test: Test AI chat with real products
  • Responsive Design: Works on desktop, tablet, and mobile

๐Ÿ“– Detailed Usage Guide

Creating a Tenant

  1. Navigate to Tenant Management

    • Click "Tenant Management" in sidebar
  2. Click "Create New Tenant"

    • Fill in the form:
      • Tenant Name: Display name (e.g., "Fashion Boutique")
      • Slug: URL-safe identifier (auto-generated, e.g., "fashion-boutique")
      • Shopify Store URL: Full URL (e.g., "https://my-store.myshopify.com")
      • Shopify Access Token: (Optional) For private API access
      • Max Products: Maximum products allowed (default: 10000)
  3. Click "Create Tenant"

    • Tenant is created with default RAG configuration
    • Default settings are applied

Syncing Products

  1. Find your tenant in the list
  2. Click the three dots menu (โ‹ฎ)
  3. Select "Sync Products"
  4. Wait for sync to complete (toast notification)
  5. Product count updates in the table

Note: First sync may take a few minutes depending on product count.

Generating Embeddings

Prerequisites: Products must be synced first

  1. Click the three dots menu (โ‹ฎ) on your tenant
  2. Select "Generate Embeddings"
  3. Wait for embedding generation (may take several minutes)
  4. Embeddings count updates in tenant stats

Note: Embeddings enable semantic search. Without them, chat won't work properly.

Customizing Widget Appearance

  1. Click "Edit Settings" on your tenant

  2. Appearance Tab:

    • Primary Color: Main brand color (buttons, header)
    • Secondary Color: Secondary color (user messages)
    • Widget Position: Choose from 4 corners
    • Chat Title: e.g., "Shop Assistant"
    • Welcome Message: First message shown to users
  3. Behavior Tab:

    • Auto-open: Enable/disable automatic widget opening
    • Auto-open Delay: Seconds before auto-open (5-60s)
    • Typing Indicator: Show "AI is thinking..." animation
  4. Live Preview:

    • See changes in real-time on the right side
    • Preview shows actual widget appearance
  5. Click "Save Settings"

Getting Embed Code (Admin Only)

  1. Go to tenant settings
  2. Click "Embed Code" tab
  3. Copy the JavaScript code
  4. Paste before </body> tag in your website:
<!-- Feattie Chat Widget -->
<script>
  window.FeattieChat = {
    tenantId: 1,
    tenantSlug: 'your-store',
    apiUrl: 'http://localhost:5078',
    customization: {
      primaryColor: '#6366f1',
      secondaryColor: '#8b5cf6',
      position: 'bottom-right',
      chatTitle: 'Chat with us',
      welcomeMessage: 'Hello! How can I help you today?',
      autoOpen: false,
      autoOpenDelay: 5,
      showTypingIndicator: true
    }
  };
</script>
<script src="http://localhost:5078/widget/widget.js"></script>

Managing Users (Admin Only)

  1. Navigate to "Users Management"
  2. Find user in the list
  3. Click three dots menu (โ‹ฎ)
  4. Select "Manage Tenants"
  5. Check/uncheck tenants to assign/remove
  6. User can now access assigned tenants

Testing Chat

  1. Navigate to "Chat Test"
  2. Select tenant from dropdown
  3. Type a message: e.g., "Show me blue dresses under $100"
  4. AI responds with relevant products
  5. Test different queries to verify RAG is working

โš™๏ธ Configuration

Backend API Configuration

File: authentication/SecureAuth.Api/appsettings.json

{
  "ConnectionStrings": {
    "Default": "Host=localhost;Port=5432;Database=feattie;Username=postgres;Password=postgres"
  },
  "Jwt": {
    "Secret": "your-super-secret-jwt-key-minimum-32-characters-required-for-production",
    "Issuer": "SecureAuth.Api",
    "Audience": "SecureAuth.Client",
    "ExpiryMinutes": 60
  },
  "Cors": {
    "AllowedOrigins": ["http://localhost:5173", "http://localhost:3000"]
  },
  "PythonRAG": {
    "BaseUrl": "http://localhost:8000"
  },
  "OpenAI": {
    "ApiKey": "sk-your-openai-api-key-here"
  }
}

Frontend Configuration

File: admin-dashboard/.env

VITE_API_URL=http://localhost:5078

Python RAG Configuration

File: .env (project root)

OPENAI_API_KEY=sk-your-openai-api-key-here

๐Ÿ—๏ธ System Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                    Customer Website                          โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”‚
โ”‚  โ”‚  Embedded Chat Widget (JavaScript)                 โ”‚    โ”‚
โ”‚  โ”‚  - Loads tenant config via API                     โ”‚    โ”‚
โ”‚  โ”‚  - Renders chat interface                          โ”‚    โ”‚
โ”‚  โ”‚  - Sends messages to chat endpoint                 โ”‚    โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                      โ”‚ HTTP/HTTPS
                      โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚            .NET Core API (Port 5078)                         โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”‚
โ”‚  โ”‚  Public Endpoints (No Authentication):               โ”‚  โ”‚
โ”‚  โ”‚  - GET  /api/widget/config/{slug}                    โ”‚  โ”‚
โ”‚  โ”‚  - POST /api/chat/{tenantId}                         โ”‚  โ”‚
โ”‚  โ”‚  - GET  /api/chat/{tenantId}/history/{sessionId}    โ”‚  โ”‚
โ”‚  โ”‚  - GET  /widget/widget.js                            โ”‚  โ”‚
โ”‚  โ”‚                                                       โ”‚  โ”‚
โ”‚  โ”‚  Authenticated Endpoints:                            โ”‚  โ”‚
โ”‚  โ”‚  - POST /api/auth/login                              โ”‚  โ”‚
โ”‚  โ”‚  - GET  /api/tenant                                  โ”‚  โ”‚
โ”‚  โ”‚  - POST /api/tenant                                  โ”‚  โ”‚
โ”‚  โ”‚  - GET  /api/tenants/{id}/settings                  โ”‚  โ”‚
โ”‚  โ”‚  - PUT  /api/tenants/{id}/settings                  โ”‚  โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
             โ”‚                        โ”‚
             โ”‚                        โ”‚ HTTP
             โ–ผ                        โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚   PostgreSQL DB      โ”‚  โ”‚   Python RAG Service (Port 8000) โ”‚
โ”‚   (Port 5432)        โ”‚  โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚
โ”‚                      โ”‚  โ”‚  โ”‚ - Sentence Transformers     โ”‚ โ”‚
โ”‚  - Users             โ”‚  โ”‚  โ”‚ - OpenAI GPT-4o-mini        โ”‚ โ”‚
โ”‚  - Tenants           โ”‚  โ”‚  โ”‚ - Embedding generation      โ”‚ โ”‚
โ”‚  - TenantSettings    โ”‚  โ”‚  โ”‚ - Semantic search           โ”‚ โ”‚
โ”‚  - Products          โ”‚  โ”‚  โ”‚ - RAG pipeline              โ”‚ โ”‚
โ”‚  - ChatSessions      โ”‚  โ”‚  โ”‚ - Context injection         โ”‚ โ”‚
โ”‚  - ChatMessages      โ”‚  โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚
โ”‚  - Contexts          โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
โ”‚  - RAGConfigurations โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚         Admin Dashboard (React + Vite - Port 3000)          โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”‚
โ”‚  โ”‚  Pages:                                              โ”‚  โ”‚
โ”‚  โ”‚  - Dashboard (system stats)                          โ”‚  โ”‚
โ”‚  โ”‚  - Tenant Management (CRUD)                          โ”‚  โ”‚
โ”‚  โ”‚  - User Management (assign to tenants)               โ”‚  โ”‚
โ”‚  โ”‚  - Widget Settings (customization + live preview)    โ”‚  โ”‚
โ”‚  โ”‚  - Chat Test (test AI chat)                          โ”‚  โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

๐Ÿ“ก API Endpoints

Public Endpoints (No Authentication Required)

MethodEndpointDescriptionBody
GET/api/widget/config/{tenantSlug}Get widget configuration-
POST/api/chat/{tenantId}Send chat message{ query, sessionId?, topK? }
GET/api/chat/{tenantId}/history/{sessionId}Get chat history-
GET/widget/widget.jsWidget JavaScript file-

Authentication Endpoints

MethodEndpointDescriptionBody
POST/api/auth/loginLogin{ email, password }
POST/api/auth/registerRegister new user{ email, password, firstName?, lastName? }
POST/api/auth/logoutLogout-
GET/api/auth/meGet current user info-
GET/api/auth/me/tenantsGet user's assigned tenants-

Tenant Management (Admin Only)

MethodEndpointDescriptionBody
GET/api/tenantList all tenantsQuery: isActive?, page?, pageSize?
GET/api/tenant/{id}Get tenant by ID-
GET/api/tenant/by-slug/{slug}Get tenant by slug-
POST/api/tenantCreate new tenant{ Name, Slug, ShopifyStoreUrl, ShopifyAccessToken?, MaxProducts? }
PUT/api/tenant/{id}Update tenant{ Name?, ShopifyStoreUrl?, IsActive?, MaxProducts? }
DELETE/api/tenant/{id}Delete tenant (soft delete)Query: permanent?
GET/api/tenant/{id}/statsGet tenant statistics-

User-Tenant Management (Admin Only)

MethodEndpointDescriptionBody
GET/api/auth/admin/usersList all usersQuery: search?, page?, pageSize?
GET/api/auth/admin/users/{userId}/tenantsGet user's tenants-
POST/api/auth/admin/users/{userId}/tenants/{tenantId}Assign user to tenant{ role? }
DELETE/api/auth/admin/users/{userId}/tenants/{tenantId}Remove user from tenant-

Tenant Settings (User & Admin)

MethodEndpointDescriptionBody
GET/api/tenants/{id}/settingsGet tenant settings-
PUT/api/tenants/{id}/settingsUpdate tenant settings{ brandColorPrimary?, brandColorSecondary?, widgetPosition?, chatTitle?, welcomeMessage?, autoOpen?, autoOpenDelaySeconds?, showTypingIndicator? }
GET/api/tenants/{id}/settings/embed-codeGet embed code (Admin)-

Product Management (Admin Only)

MethodEndpointDescriptionBody
GET/api/tenants/{id}/productsList productsQuery: hasEmbedding?, page?, pageSize?
POST/api/tenants/{id}/products/syncSync products from Shopify{ forceResync? }
POST/api/tenants/{id}/products/generate-embeddingsGenerate embeddings{ forceRegenerate? }
GET/api/tenants/{id}/products/statsGet product statistics-

RAG Configuration (Admin Only)

MethodEndpointDescriptionBody
GET/api/tenants/{id}/rag-configGet RAG configuration-
PUT/api/tenants/{id}/rag-configUpdate RAG configuration{ embeddingModel?, llmModel?, systemPrompt?, temperature?, ... }

๐Ÿ—‚๏ธ Project Structure

feattie/
โ”œโ”€โ”€ authentication/SecureAuth.Api/        # .NET Core Backend API
โ”‚   โ”œโ”€โ”€ Controllers/
โ”‚   โ”‚   โ”œโ”€โ”€ AuthController.cs            # Authentication & user management
โ”‚   โ”‚   โ”œโ”€โ”€ TenantController.cs          # Tenant CRUD operations
โ”‚   โ”‚   โ”œโ”€โ”€ TenantSettingsController.cs  # Widget settings
โ”‚   โ”‚   โ”œโ”€โ”€ ChatController.cs            # Chat API
โ”‚   โ”‚   โ”œโ”€โ”€ ProductController.cs         # Product sync & embeddings
โ”‚   โ”‚   โ””โ”€โ”€ RAGConfigurationController.cs # RAG settings
โ”‚   โ”œโ”€โ”€ Models/
โ”‚   โ”‚   โ”œโ”€โ”€ User.cs                      # User model
โ”‚   โ”‚   โ”œโ”€โ”€ Tenant.cs                    # Tenant model
โ”‚   โ”‚   โ”œโ”€โ”€ TenantUser.cs                # User-Tenant junction
โ”‚   โ”‚   โ”œโ”€โ”€ TenantSettings.cs            # Widget settings
โ”‚   โ”‚   โ”œโ”€โ”€ Product.cs                   # Product model
โ”‚   โ”‚   โ”œโ”€โ”€ ChatSession.cs               # Chat session
โ”‚   โ”‚   โ”œโ”€โ”€ ChatMessage.cs               # Chat message
โ”‚   โ”‚   โ”œโ”€โ”€ RAGConfiguration.cs          # RAG config
โ”‚   โ”‚   โ””โ”€โ”€ Context.cs                   # Custom context
โ”‚   โ”œโ”€โ”€ Services/
โ”‚   โ”‚   โ”œโ”€โ”€ ShopifyService.cs            # Shopify integration
โ”‚   โ”‚   โ”œโ”€โ”€ PythonRAGService.cs          # Python RAG client
โ”‚   โ”‚   โ””โ”€โ”€ ProductService.cs            # Product operations
โ”‚   โ”œโ”€โ”€ Data/
โ”‚   โ”‚   โ””โ”€โ”€ AppDbContext.cs              # Entity Framework DbContext
โ”‚   โ”œโ”€โ”€ DTOs/                             # Data Transfer Objects
โ”‚   โ”œโ”€โ”€ Migrations/                       # EF Core migrations
โ”‚   โ”œโ”€โ”€ wwwroot/widget/
โ”‚   โ”‚   โ””โ”€โ”€ widget.js                    # Embeddable widget script
โ”‚   โ”œโ”€โ”€ Program.cs                        # Application entry point
โ”‚   โ”œโ”€โ”€ appsettings.json                 # Configuration
โ”‚   โ””โ”€โ”€ appsettings.Development.json     # Dev configuration
โ”‚
โ”œโ”€โ”€ admin-dashboard/                      # React Admin Dashboard
โ”‚   โ”œโ”€โ”€ app/                              # Next.js App Router
โ”‚   โ”‚   โ”œโ”€โ”€ page.tsx                     # Dashboard home
โ”‚   โ”‚   โ”œโ”€โ”€ tenants/
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ page.tsx                 # Tenant management
โ”‚   โ”‚   โ”œโ”€โ”€ users/
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ page.tsx                 # User management
โ”‚   โ”‚   โ”œโ”€โ”€ tenant-settings/
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ page.tsx                 # Widget settings
โ”‚   โ”‚   โ”œโ”€โ”€ chat/
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ page.tsx                 # Chat test
โ”‚   โ”‚   โ””โ”€โ”€ auth/
โ”‚   โ”‚       โ””โ”€โ”€ login/
โ”‚   โ”‚           โ””โ”€โ”€ page.tsx             # Login page
โ”‚   โ”œโ”€โ”€ components/
โ”‚   โ”‚   โ”œโ”€โ”€ ui/                          # shadcn/ui components
โ”‚   โ”‚   โ””โ”€โ”€ AdminLayout.tsx              # Layout with sidebar
โ”‚   โ”œโ”€โ”€ contexts/
โ”‚   โ”‚   โ””โ”€โ”€ AuthContext.tsx              # Authentication context
โ”‚   โ”œโ”€โ”€ lib/
โ”‚   โ”‚   โ”œโ”€โ”€ api.ts                       # API client (axios)
โ”‚   โ”‚   โ””โ”€โ”€ utils.ts                     # Utility functions
โ”‚   โ”œโ”€โ”€ hooks/
โ”‚   โ”‚   โ””โ”€โ”€ use-toast.tsx                # Toast notifications
โ”‚   โ”œโ”€โ”€ package.json
โ”‚   โ”œโ”€โ”€ vite.config.ts
โ”‚   โ”œโ”€โ”€ tailwind.config.js
โ”‚   โ””โ”€โ”€ .env                              # Environment variables
โ”‚
โ”œโ”€โ”€ src/                                  # Python RAG Service
โ”‚   โ”œโ”€โ”€ api/
โ”‚   โ”‚   โ””โ”€โ”€ tenant_server.py             # FastAPI server
โ”‚   โ”œโ”€โ”€ embeddings/
โ”‚   โ”‚   โ”œโ”€โ”€ local_embeddings.py          # Sentence Transformers
โ”‚   โ”‚   โ””โ”€โ”€ openai_embeddings.py         # OpenAI embeddings
โ”‚   โ”œโ”€โ”€ models/
โ”‚   โ”‚   โ””โ”€โ”€ tenant_models.py             # Pydantic models
โ”‚   โ””โ”€โ”€ services/
โ”‚       โ”œโ”€โ”€ llm_service.py               # OpenAI LLM integration
โ”‚       โ””โ”€โ”€ rag_service.py               # RAG pipeline
โ”‚
โ”œโ”€โ”€ scripts/
โ”‚   โ”œโ”€โ”€ shop_pull.py                     # Shopify product scraper
โ”‚   โ””โ”€โ”€ add-admin.sh                     # Add admin user script
โ”‚
โ”œโ”€โ”€ requirements.txt                      # Python dependencies
โ”œโ”€โ”€ package.json                          # Project metadata
โ”œโ”€โ”€ .env                                  # Environment variables
โ”œโ”€โ”€ .env.example                          # Example env file
โ”œโ”€โ”€ README.md                             # This file
โ”œโ”€โ”€ QUICK_START.md                        # Quick start guide
โ””โ”€โ”€ OPENAI_SETUP.md                       # OpenAI setup guide

๐Ÿ› Troubleshooting

Port Already in Use

# Kill processes on specific ports
lsof -ti:5078 | xargs kill -9  # .NET API
lsof -ti:8000 | xargs kill -9  # Python RAG
lsof -ti:5173 | xargs kill -9  # Admin Dashboard
lsof -ti:5432 | xargs kill -9  # PostgreSQL

# Or kill all at once
lsof -ti:5078,8000,5173 | xargs kill -9

Database Connection Failed

  1. Check PostgreSQL is running:

    pg_isready -h localhost -p 5432
    
  2. Check connection string in appsettings.json:

    "ConnectionStrings": {
      "Default": "Host=localhost;Port=5432;Database=feattie;Username=postgres;Password=postgres"
    }
    
  3. Ensure database exists:

    psql -U postgres
    CREATE DATABASE feattie;
    \q
    
  4. Run migrations:

    cd authentication/SecureAuth.Api
    dotnet ef database update
    

Python Module Not Found

# Activate virtual environment
source .venv/bin/activate  # macOS/Linux
.venv\Scripts\activate     # Windows

# Set PYTHONPATH
export PYTHONPATH=$PWD     # macOS/Linux
set PYTHONPATH=%CD%        # Windows

# Reinstall dependencies
pip install -r requirements.txt --upgrade

Migrations Error

cd authentication/SecureAuth.Api

# Drop and recreate database (WARNING: deletes all data)
dotnet ef database drop --force
dotnet ef database update

# Or create new migration
dotnet ef migrations add YourMigrationName
dotnet ef database update

Chat Not Working

Checklist:

  1. โœ… All 3 services running (API, RAG, Frontend)
  2. โœ… Tenant has products synced
  3. โœ… Embeddings are generated for products
  4. โœ… OpenAI API key is set in appsettings.json
  5. โœ… RAG service URL is correct in appsettings.json
  6. โœ… Check browser console for errors
  7. โœ… Check API logs for errors
  8. โœ… Check RAG service logs for errors

CORS Errors

Update appsettings.json:

"Cors": {
  "AllowedOrigins": [
    "http://localhost:5173",
    "http://localhost:3000",
    "https://your-production-domain.com"
  ]
}

Widget Not Loading

  1. Check widget URL is correct
  2. Check CORS is configured for customer domain
  3. Check tenant slug is correct
  4. Open browser console and check for errors
  5. Verify tenant is active: IsActive = true

๐Ÿ”’ Security & Production Deployment

Pre-Production Checklist

  • Change default admin password
  • Use strong JWT secret (32+ characters, random)
  • Enable HTTPS/SSL
  • Store API keys in environment variables (not in code)
  • Set AllowedOrigins in CORS to actual domain
  • Enable rate limiting
  • Set up regular database backups
  • Update all dependencies
  • Remove default test users
  • Set ASPNETCORE_ENVIRONMENT=Production
  • Use production-grade PostgreSQL (e.g., RDS, Azure DB)
  • Set up logging (Serilog, Application Insights)
  • Set up monitoring (health checks, uptime)

Environment Variables (Production)

# .NET API
ASPNETCORE_ENVIRONMENT=Production
ConnectionStrings__Default="Host=prod-db.example.com;Port=5432;Database=feattie;Username=app_user;Password=secure_password"
Jwt__Secret="production-secret-key-at-least-32-characters-long-and-random"
Jwt__ExpiryMinutes=60
OpenAI__ApiKey="sk-prod-openai-api-key"
Cors__AllowedOrigins__0="https://admin.yourdomain.com"
PythonRAG__BaseUrl="https://rag.yourdomain.com"

# Python RAG
OPENAI_API_KEY="sk-prod-openai-api-key"
PYTHONPATH=/app

# Admin Dashboard (build time)
VITE_API_URL=https://api.yourdomain.com

Required API Keys

  1. OpenAI API Key

    • Get from: https://platform.openai.com/api-keys
    • Used for: Embeddings (text-embedding-3-small) & Chat (gpt-4o-mini)
    • Pricing: ~$0.02 per 1M tokens (embeddings), ~$0.15 per 1M tokens (chat)
  2. Shopify Access Token (per tenant, optional)

    • For private apps: Create in Shopify Admin โ†’ Apps โ†’ Develop apps
    • Required permissions: read_products
    • Not required if using public Shopify API

Production Deployment (Docker)

# Dockerfile for .NET API
FROM mcr.microsoft.com/dotnet/aspnet:9.0 AS base
WORKDIR /app
EXPOSE 5078

FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build
WORKDIR /src
COPY ["authentication/SecureAuth.Api/SecureAuth.Api.csproj", "authentication/SecureAuth.Api/"]
RUN dotnet restore "authentication/SecureAuth.Api/SecureAuth.Api.csproj"
COPY . .
WORKDIR "/src/authentication/SecureAuth.Api"
RUN dotnet build "SecureAuth.Api.csproj" -c Release -o /app/build
RUN dotnet publish "SecureAuth.Api.csproj" -c Release -o /app/publish

FROM base AS final
WORKDIR /app
COPY --from=build /app/publish .
ENTRYPOINT ["dotnet", "SecureAuth.Api.dll"]
# docker-compose.yml
version: '3.8'

services:
  postgres:
    image: postgres:15
    environment:
      POSTGRES_USER: postgres
      POSTGRES_PASSWORD: ${DB_PASSWORD}
      POSTGRES_DB: feattie
    ports:
      - "5432:5432"
    volumes:
      - postgres_data:/var/lib/postgresql/data

  api:
    build:
      context: .
      dockerfile: Dockerfile.api
    ports:
      - "5078:5078"
    environment:
      - ConnectionStrings__Default=Host=postgres;Database=feattie;Username=postgres;Password=${DB_PASSWORD}
      - Jwt__Secret=${JWT_SECRET}
      - OpenAI__ApiKey=${OPENAI_API_KEY}
    depends_on:
      - postgres

  rag:
    build:
      context: .
      dockerfile: Dockerfile.rag
    ports:
      - "8000:8000"
    environment:
      - OPENAI_API_KEY=${OPENAI_API_KEY}
      - PYTHONPATH=/app
    depends_on:
      - postgres

  admin:
    build:
      context: ./admin-dashboard
      dockerfile: Dockerfile
    ports:
      - "5173:80"
    environment:
      - VITE_API_URL=http://api:5078

volumes:
  postgres_data:

๐Ÿ“Š Database Schema

Key Tables

  • Users: User accounts (admin & regular users)
  • Tenants: Business accounts (e-commerce stores)
  • TenantUsers: Many-to-many relationship (users can access multiple tenants)
  • TenantSettings: Widget customization per tenant
  • Products: Product catalog per tenant
  • RAGConfigurations: AI/LLM settings per tenant
  • Contexts: Custom context snippets per tenant
  • ChatSessions: Chat sessions
  • ChatMessages: Chat message history

๐Ÿ“ Default Test Users

EmailPasswordRoleTenants Assigned
admin@example.comAdmin123!AdminAll
admin@test.comTest123!AdminAll
john@test.comTest123!UserNone (assign manually)
jane@test.comTest123!UserNone (assign manually)

๐Ÿค Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

๐Ÿ“„ License

MIT License - see LICENSE file for details


๐Ÿ™ Support & Contact

For questions, issues, or feature requests:

  • GitHub Issues: [Your Repo Issues]
  • Email: [Your Email]
  • Documentation: See QUICK_START.md and OPENAI_SETUP.md

๐ŸŽฏ Roadmap

v1.1 (Coming Soon)

  • Widget analytics (views, messages, conversions)
  • Multiple language support for dashboard
  • Email notifications for admins
  • Webhook support for Shopify product updates
  • Custom CSS editor with syntax highlighting

v1.2 (Future)

  • WooCommerce integration
  • WhatsApp integration
  • Voice chat support
  • A/B testing for widget variants
  • Mobile app for admin dashboard

Built with โค๏ธ for modern e-commerce businesses

Powered by: .NET 9.0 | React 18 | OpenAI | PostgreSQL | Python 3.11