Skip to content

MAhmedcodes/ShieldAuth---Authentication-app-with-ShieldBot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

29 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

ShieldAuth - Modern Secure Authentication System with Advanced AI Assistant

A comprehensive, production-ready authentication application built with cutting-edge web technologies. ShieldAuth provides secure user authentication, role-based access control, a beautiful modern interface with advanced admin capabilities, and an integrated AI chatbot assistant with RAG (Retrieval Augmented Generation) capabilities for enhanced cybersecurity guidance.

๐Ÿš€ Technology Stack

  • Frontend: SvelteKit with Svelte 5
  • Authentication: Auth.js with PostgreSQL Database Sessions (No JWT)
  • Styling: TailwindCSS with custom dark theme
  • Database: PostgreSQL with pgvector extension for vector embeddings
  • AI Integration: Google Gemini AI with streaming responses and RAG
  • Vector Database: pgvector for semantic search and embeddings
  • Embedding Service: Python FastAPI microservice with Gemini Embeddings API
  • Security: CSRF protection, bcrypt hashing, secure sessions
  • Deployment: Docker-ready with comprehensive configuration

โœจ Core Features

๐Ÿค– ShieldBot AI Assistant with RAG

Intelligent Chat Interface

  • Real-time AI Chat - Interactive conversation with ShieldBot AI assistant
  • Word-by-Word Streaming - Natural typing effect with streaming responses
  • Context-Aware Responses - AI responses enhanced with retrieved document context
  • Citation Display - Shows which documents informed the AI's answer
  • File Upload Support - Upload documents (.txt, .doc, .docx, .pdf) for AI analysis
  • Multiple AI Models - Support for Gemini 2.5 Pro, 2.5 Flash, 1.5 Pro, and 1.5 Flash
  • Chat Management - Create, rename, delete, and organize chat conversations
  • Auto-Rename - Automatic chat naming based on first message topic
  • Responsive Design - Full-screen chat interface with collapsible sidebar

RAG (Retrieval Augmented Generation) Features

  • Document Ingestion - Upload and process documents for AI context
  • Semantic Search - Vector-based similarity search for relevant content
  • Context Retrieval - Automatic retrieval of relevant document snippets
  • Citation System - Track and display source documents with relevance scores
  • Chunking Strategy - Intelligent document chunking for optimal context
  • Embedding Generation - Automatic vector embeddings using Gemini API
  • Vector Storage - pgvector database for efficient similarity search
  • Relevance Gating - Only use document context when similarity is strong enough; otherwise answer from general knowledge

AI Features

  • Streaming Responses - Real-time word-by-word AI response streaming
  • Model Selection - Choose between different Gemini AI models
  • Chat History - Persistent chat conversations with timestamps
  • Security Guidance - Expert advice on password security, phishing protection, 2FA, and network security
  • Interactive Prompts - Pre-built conversation starters for common security topics
  • Markdown Rendering - Rich text formatting with syntax highlighting
  • Code Highlighting - Syntax highlighting for code blocks using Shiki
  • Citations in UI - Assistant messages show sources when document context is used

Advanced Message Management

  • Message Versioning - Complete forking system for message editing and branching
  • Edit Messages - Edit any user message to create conversation branches
  • Regenerate Responses - Generate new AI responses with streaming updates
  • Version Control - Track message versions with isActive flags and versionGroupId
  • Smart Context - AI maintains proper conversation context for versioned messages
  • First Message Protection - Prevents forking of initial messages with user-friendly popup
  • Editing UX - While saving an edit or regenerating, the chat disables send/regenerate and shows โ€œGenerating responseโ€ฆโ€

๐Ÿ” Authentication System

Multi-Method Authentication

  • Email/Password Registration - Secure account creation with email verification
  • Google OAuth Integration - One-click sign-in with Google accounts
  • GitHub OAuth Integration - Seamless GitHub authentication
  • Email Verification - 6-digit verification codes with spam folder alerts
  • Password Reset - Secure password recovery with email codes

Security Features

  • Database Sessions Only - No JWT tokens, secure server-side sessions
  • Bcrypt Password Hashing - Industry-standard password encryption
  • CSRF Protection - Built-in cross-site request forgery protection
  • Input Validation - Comprehensive server-side validation
  • Secure Headers - Security-focused HTTP headers
  • Profile Image Persistence - OAuth profile image/name synced on link/sign-in; DB image preferred to prevent flicker; avatars use referrerpolicy="no-referrer"

๐Ÿ‘‘ Role-Based Access Control (RBAC)

Admin Dashboard

  • User Analytics - Real-time user statistics and metrics
  • System Overview - Complete system health and activity monitoring
  • Quick Actions - Fast access to common admin tasks
  • Modern UI - Beautiful gradient-based interface with dark theme

Advanced User Management

  • Search & Filter - Real-time search by name/email with role filtering
  • User Statistics - Dynamic user counts by role (Admin/Regular users)
  • Role Management - Promote/demote users between user and admin roles
  • Account Control - Delete user accounts with comprehensive data removal
  • Self-Protection - Admins cannot modify their own accounts
  • Activity Tracking - User registration and update timestamps

๐ŸŽจ Modern User Interface

Dark Theme Design

  • Consistent Dark Mode - Beautiful black theme with blue accents throughout
  • Gradient Backgrounds - Modern gradient overlays and textures
  • Responsive Design - Perfect display on all devices and screen sizes
  • Professional Navigation - Role-based navigation with smooth transitions

Enhanced UX Features

  • Slide-up Animations - Smooth text animations on About and Contact pages
  • Interactive Elements - Hover effects, scale transforms, and smooth transitions
  • Form Validation - Real-time validation with user-friendly error messages
  • Loading States - Visual feedback during form submissions and API calls
  • Accessibility - ARIA labels, keyboard navigation, and screen reader support

๐Ÿ“ฑ Page-Specific Features

Homepage

  • Hero Section - Engaging landing page with feature showcase
  • Feature Cards - Interactive cards highlighting system capabilities
  • ShieldBot Integration - AI chatbot card with purple theme and functional buttons
  • Call-to-Action - Beautiful gradient buttons for user engagement
  • Professional Footer - Complete site navigation and social links

ShieldBot Chat Interface

  • Full-Screen Chat - Immersive chat experience without navbar distractions
  • Collapsible Sidebar - Chat history and management with toggle functionality
  • Model Selection - Dropdown to choose AI model with real-time switching
  • Streaming Responses - Word-by-word AI response streaming for natural conversation
  • Chat Prompts - Pre-built conversation starters for security topics
  • Auto-Rename - Intelligent chat naming based on conversation topics
  • File Upload - Drag-and-drop file upload with validation
  • Citation Display - Show source documents with relevance scores
  • Doc-first Title - If the first message includes a file, the chat auto-renames to that documentโ€™s name

Enhanced Chat Management

  • Professional Rename Modal - Beautiful modal form for chat renaming with keyboard shortcuts
  • Smart Auto-Scroll - Automatic scrolling to bottom on new messages and page reload
  • Empty State UI - Beautiful interface when no conversations exist
  • Chat Deletion - Complete cleanup of messages and conversations with confirmation
  • Page Refresh Continuity - Resume last active chat after page reload
  • Hidden Scrollbars - Clean UI with custom scrollbar hiding throughout the interface
  • Keyboard Navigation - Enter/Escape key support for all modals and forms

Authentication Pages

  • Modern Login/Register - Purple-blue gradient themes with pattern backgrounds
  • Email Verification - 6-digit code input with individual digit fields
  • Password Management - Secure password change and reset workflows
  • Forgot Password - Email-based password recovery system
  • Alert Messages - "Check Spam Section" alerts for email verification

User Dashboard

  • Profile Management - Complete user profile with picture upload
  • Settings Panel - User preferences and account settings
  • Activity Overview - User activity and account information
  • Change Password - Secure password update with modern lock icon

Admin Interface

  • Dashboard Analytics - User statistics and system metrics
  • User Management - Advanced search, filtering, and user control
  • Role Administration - User role management and permissions
  • System Monitoring - Real-time system health and activity

๐Ÿ”ง Environment Configuration

Create a .env file in the root directory:

# Database Configuration (Required)
DATABASE_URL="postgresql://postgres:password@localhost:5433/authapp"

# Authentication Secret (Required)
AUTH_SECRET="your-super-secret-auth-key-here"

# AI Configuration (Required for ShieldBot)
GOOGLE_AI_API_KEY="your-google-ai-api-key"

# Embedding Service Configuration (Required for RAG)
EMBEDDING_API_URL="http://localhost:8000"
# Embedding target dimension (must match DB vector column; defaults to 3072)
EMBEDDING_TARGET_DIM="3072"

# OAuth Configuration (Optional)
GOOGLE_CLIENT_ID="your-google-client-id"
GOOGLE_CLIENT_SECRET="your-google-client-secret"
GITHUB_CLIENT_ID="your-github-client-id"
GITHUB_CLIENT_SECRET="your-github-client-secret"

# Environment
NODE_ENV="development"

Important Notes:

  • Uses PostgreSQL with pgvector - no SQLite fallback
  • Custom port 5433 to avoid conflicts
  • Generate secure AUTH_SECRET: openssl rand -base64 32
  • Google AI API Key required for ShieldBot functionality
  • Embedding API URL required for RAG functionality
  • OAuth credentials are optional

๐Ÿ—๏ธ Project Structure

src/
โ”œโ”€โ”€ lib/
โ”‚   โ”œโ”€โ”€ components/          # Reusable UI components
โ”‚   โ”‚   โ”œโ”€โ”€ Button.svelte
โ”‚   โ”‚   โ”œโ”€โ”€ Card.svelte
โ”‚   โ”‚   โ”œโ”€โ”€ Input.svelte
โ”‚   โ”‚   โ”œโ”€โ”€ Notification.svelte
โ”‚   โ”‚   โ”œโ”€โ”€ EnhancedMessageRenderer.svelte
โ”‚   โ”‚   โ””โ”€โ”€ MarkdownRenderer.svelte    # Markdown with syntax highlighting
โ”‚   โ”œโ”€โ”€ server/              # Server-side utilities
โ”‚   โ”‚   โ”œโ”€โ”€ auth.ts          # Auth.js configuration
โ”‚   โ”‚   โ”œโ”€โ”€ ai.ts            # AI service integration
โ”‚   โ”‚   โ”œโ”€โ”€ db/              # Database schema and connection
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ schema.ts    # Main database schema
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ rag.schema.ts # RAG-specific tables
โ”‚   โ”‚   โ”œโ”€โ”€ email.ts         # Email service
โ”‚   โ”‚   โ””โ”€โ”€ security.ts      # Security utilities
โ”‚   โ”œโ”€โ”€ services/            # Client-side services
โ”‚   โ”‚   โ”œโ”€โ”€ clientChatService.ts  # AI chat service
โ”‚   โ”‚   โ””โ”€โ”€ databaseChatService.ts # Database chat operations
โ”‚   โ””โ”€โ”€ stores/              # Svelte stores
โ”‚       โ””โ”€โ”€ chatStore.ts     # Chat state management
โ”œโ”€โ”€ routes/                  # Application routes
โ”‚   โ”œโ”€โ”€ api/                 # API endpoints
โ”‚   โ”‚   โ”œโ”€โ”€ auth/            # Authentication endpoints
โ”‚   โ”‚   โ”œโ”€โ”€ chat/            # AI chat streaming endpoints
โ”‚   โ”‚   โ””โ”€โ”€ rag/             # RAG endpoints
โ”‚   โ”‚       โ”œโ”€โ”€ ingest/      # Document ingestion
โ”‚   โ”‚       โ””โ”€โ”€ retrieve/    # Context retrieval
โ”‚   โ”œโ”€โ”€ admin/               # Admin-only pages
โ”‚   โ”œโ”€โ”€ auth/                # Authentication pages
โ”‚   โ”œโ”€โ”€ chatbot/             # ShieldBot AI chat interface
โ”‚   โ””โ”€โ”€ (pages)/             # Public and protected pages
โ””โ”€โ”€ static/                  # Static assets

embedding-service/           # Python microservice
โ”œโ”€โ”€ app.py                   # FastAPI embedding service
โ”œโ”€โ”€ Dockerfile              # Container configuration
โ””โ”€โ”€ requirements.txt        # Python dependencies

๐Ÿš€ Quick Start

1. Clone and Install

git clone https://github.com/Vanar-AI-Excellence-Program/Assignment-3-Ahmed-Asghar-and-Aatiqa-Hussain
cd Assignment-3-Ahmed-Asghar-and-Aatiqa-Hussain
npm install

2. Database Setup

# Start PostgreSQL with pgvector (custom port 5433)
docker-compose up -d

# Push database schema
npm run db:push

3. Environment Configuration

Create a .env file in the root directory with the following variables:

# Database Configuration
DATABASE_URL="postgresql://postgres:password@localhost:5433/Authapp"

# Authentication Configuration
AUTH_SECRET="your-auth-secret-here-generate-a-long-random-string"
AUTH_TRUST_HOST=true

# OAuth Configuration (Optional)
GOOGLE_CLIENT_ID="your-google-client-id"
GOOGLE_CLIENT_SECRET="your-google-client-secret"
GITHUB_CLIENT_ID="your-github-client-id"
GITHUB_CLIENT_SECRET="your-github-client-secret"

# AI Configuration (Required for ShieldBot)
GOOGLE_AI_API_KEY="your-google-ai-api-key"

# Embedding Service Configuration (Required for RAG)
EMBEDDING_API_URL="http://localhost:8000"
# Optional: override embedding dimension exposed by the Python service
EMBEDDING_TARGET_DIM="3072"

# Email Configuration (Optional - for email verification and password reset)
SENDGRID_API_KEY="your-sendgrid-api-key"
FROM_EMAIL="noreply@yourdomain.com"

# Application Configuration
NODE_ENV="development"

Important: Both GOOGLE_AI_API_KEY and EMBEDDING_API_URL are required for full ShieldBot functionality.

4. Start Development

# Start the embedding service
docker-compose up embedding-service -d

# Verify embedding service
curl http://localhost:8000/health

# Start the main application
npm run dev

Visit http://localhost:5173 to see your application!

๐Ÿค– ShieldBot AI Features

Getting Started with ShieldBot

  1. Navigate to Chatbot - Click "Start Chat" on the homepage or visit /chatbot
  2. Choose AI Model - Select from Gemini 2.5 Pro, 2.5 Flash, 1.5 Pro, or 1.5 Flash
  3. Start Conversation - Use pre-built prompts or ask your own security questions
  4. Upload Documents - Upload files for AI to analyze and reference
  5. Streaming Responses - Watch AI responses appear word-by-word in real-time
  6. View Citations - See which documents informed the AI's answer
  7. Out-of-Doc Questions - If retrieval is not relevant enough, ShieldBot answers from its general knowledge

RAG Capabilities

  • Document Analysis - Upload and analyze security documents, policies, and guides
  • Context-Aware Responses - AI responses enhanced with relevant document content
  • Citation Tracking - See exactly which documents and sections informed each answer
  • Semantic Search - Find relevant content using vector similarity
  • Multi-Format Support - Support for .txt, .doc, .docx, and .pdf files
  • Configurable Relevance - Document context is only attached when similarity passes an internal threshold (default ~0.62 cosine-like). You can raise/lower this threshold in src/lib/server/ai.ts if needed.

AI Capabilities

  • Password Security - Best practices for strong passwords
  • Phishing Protection - How to identify and avoid phishing scams
  • Two-Factor Authentication - Benefits and setup guidance
  • Network Security - Securing home Wi-Fi and devices
  • General Cybersecurity - Comprehensive security advice
  • Document-Specific Guidance - AI responses based on uploaded documents

Chat Management

  • Auto-Rename - Chats automatically named based on first message
  • Manual Rename - Custom chat titles for organization
  • Chat History - Persistent conversation storage
  • Delete Chats - Remove unwanted conversations
  • New Chat - Start fresh conversations anytime
  • File Attachments - Upload and reference documents in conversations

๐Ÿ‘‘ Admin Features

Getting Admin Access

npm run promote-admin your-email@example.com

Admin Capabilities

  • Dashboard: /admin - System analytics and overview
  • User Management: /admin/users - Advanced user administration
  • Search & Filter: Real-time user search by name/email
  • Role Management: Promote/demote users between roles
  • Account Control: Delete user accounts with full data removal
  • Statistics: Dynamic user counts and activity metrics

๐Ÿ”— OAuth Integration

Supported Providers

  • Google OAuth - Sign in with Google account
  • GitHub OAuth - Sign in with GitHub account
  • Email/Password - Traditional authentication

OAuth Features

  • Seamless Integration - One-click social authentication
  • Account Linking - OAuth accounts linked to email accounts
  • Profile Sync - Automatic name and picture sync from providers
  • Flexible Authentication - Multiple authentication methods per user

๐Ÿ“ฑ Application Routes

Public Routes

  • / - Homepage with feature showcase and ShieldBot card
  • /about - About page with slide-up animations
  • /contact - Contact page with modern UI
  • /register - User registration with email verification
  • /login - User login with OAuth options

AI Chat Routes

  • /chatbot - ShieldBot AI chat interface with streaming responses and RAG

Authentication Routes

  • /verify-code - Email verification with 6-digit codes
  • /forgot-password - Password recovery request
  • /reset-password-code - Password reset code entry
  • /reset-password - New password creation
  • /change-password-code - Password change verification
  • /change-password - Password update

Protected Routes

  • /dashboard - User dashboard with profile overview
  • /profile - Profile management with picture upload
  • /change-password - Secure password change

Admin Routes

  • /admin - Admin dashboard with analytics
  • /admin/users - User management with search/filter

API Endpoints

  • /api/auth/* - Authentication endpoints
  • /api/profile/* - Profile management
  • /api/admin/users/* - Admin user management
  • /api/chat/stream - AI chat streaming endpoint
  • /api/rag/ingest - Document ingestion endpoint
  • /api/rag/retrieve - Context retrieval endpoint

Chat Management API

  • /api/chat/conversations - Create and list conversations
  • /api/chat/conversations/[id]/delete - Delete conversation with message cleanup
  • /api/chat/conversations/[id]/rename - Rename conversation
  • /api/chat/messages/[id]/edit - Edit message with versioning
  • /api/chat/messages/[id]/regenerate - Regenerate AI response with streaming
  • /api/chat/messages/[id]/versions - Get message versions

๐Ÿ› ๏ธ Development Scripts

Development

npm run dev          # Start development server
npm run build        # Build for production
npm run preview      # Preview production build
npm run check        # Type checking and linting

Database Management

npm run db:up        # Start PostgreSQL database
npm run db:down      # Stop PostgreSQL database
npm run db:push      # Push database schema changes
npm run db:studio    # Open Drizzle Studio
npm run seed         # Seed database with sample data

Admin Tools

npm run promote-admin <email>  # Promote user to admin role

Docker Services

docker-compose up -d                    # Start all services
docker-compose up embedding-service -d  # Start only embedding service
docker-compose down                     # Stop all services

๐ŸŽฏ Key Features Breakdown

RAG System Flow

  1. Document Upload โ†’ File validation โ†’ Text extraction โ†’ Chunking
  2. Embedding Generation โ†’ Python service โ†’ Gemini API โ†’ Vector storage
  3. Context Retrieval โ†’ User query โ†’ Vector similarity โ†’ Relevant chunks
  4. AI Enhancement โ†’ Context + query โ†’ Enhanced AI response โ†’ Citations

AI Chat Flow

  1. Model Selection โ†’ Choose AI model โ†’ Start conversation
  2. Streaming Response โ†’ Word-by-word streaming โ†’ Real-time display
  3. Context Integration โ†’ RAG context โ†’ Enhanced responses โ†’ Citations
  4. Chat Management โ†’ Auto-rename โ†’ Manual organization
  5. Security Guidance โ†’ Expert advice โ†’ Interactive learning

Message Versioning Flow

  1. Edit Message โ†’ Click edit button โ†’ Modify content โ†’ Save changes
  2. Version Creation โ†’ New message version created โ†’ Previous version deactivated
  3. AI Regeneration โ†’ Regenerate AI response โ†’ Streaming update โ†’ Context preserved
  4. Version Navigation โ†’ View message history โ†’ Switch between versions
  5. Context Maintenance โ†’ AI maintains conversation context across versions

Authentication Flow

  1. Registration โ†’ Email verification โ†’ Account activation
  2. Login โ†’ Database session creation โ†’ Protected access
  3. Password Reset โ†’ Email code โ†’ New password creation
  4. OAuth Login โ†’ Provider authentication โ†’ Account linking

Admin Workflow

  1. User Search โ†’ Real-time filtering โ†’ Role management
  2. Account Control โ†’ User deletion โ†’ Complete data removal
  3. Analytics โ†’ User statistics โ†’ System monitoring
  4. Security โ†’ Self-protection โ†’ Audit trail

UI/UX Features

  1. Dark Theme โ†’ Consistent black theme with blue accents
  2. Animations โ†’ Slide-up text animations and smooth transitions
  3. Responsive โ†’ Perfect display on all devices
  4. Accessibility โ†’ ARIA labels and keyboard navigation
  5. Streaming โ†’ Real-time AI response streaming
  6. Markdown โ†’ Rich text formatting with syntax highlighting

Enhanced Chat Experience

  1. Auto-Scroll โ†’ Automatic scrolling to bottom on new messages
  2. Hidden Scrollbars โ†’ Clean UI with custom scrollbar hiding
  3. Keyboard Shortcuts โ†’ Enter/Escape key support for all modals
  4. Professional Modals โ†’ Beautiful modal forms instead of browser prompts
  5. Empty States โ†’ Beautiful UI when no conversations exist
  6. Page Continuity โ†’ Resume last active chat after page reload
  7. File Upload โ†’ Drag-and-drop file upload with validation
  8. Citation Display โ†’ Source documents with relevance scores

๐Ÿ”’ Security Implementation

Session Management

  • Database Sessions - Server-side session storage
  • 30-day Expiration - Automatic session cleanup
  • Secure Cookies - HttpOnly, Secure, SameSite attributes
  • CSRF Protection - Built-in cross-site request forgery protection

Message Versioning Security

  • Version Control - Secure message versioning with versionGroupId and isActive flags
  • Context Integrity - AI maintains proper conversation context for versioned messages
  • Data Consistency - Proper cleanup of related messages when conversations are deleted
  • First Message Protection - Prevents forking of initial messages to maintain conversation integrity

Password Security

  • Bcrypt Hashing - Industry-standard password encryption
  • Salt Rounds - Configurable encryption strength
  • Password Validation - Strong password requirements
  • Secure Reset - Email-based password recovery

Input Validation

  • Server-side Validation - All inputs validated on server
  • Type Safety - TypeScript implementation throughout
  • SQL Injection Protection - Drizzle ORM parameterized queries
  • XSS Protection - Input sanitization and output encoding

AI Security

  • API Key Protection - Secure server-side AI API key handling
  • Input Sanitization - All user inputs sanitized before AI processing
  • Rate Limiting - Protection against AI API abuse
  • Error Handling - Graceful AI service error management

RAG Security

  • File Validation - Strict file type and size validation
  • Content Sanitization - All uploaded content sanitized before processing
  • Vector Security - Secure embedding generation and storage
  • Access Control - User-specific document access and retrieval
  • Thresholding - Irrelevant context is ignored to avoid data leakage from unrelated documents

๐Ÿงช Troubleshooting

  • Embeddings not saved:
    • Ensure the embedding service is running: curl http://localhost:8000/health should return status ok and target_dim: 3072.
    • Confirm your DB has pgvector and the embeddings column dimensions match 3072.
    • Check server logs for Saved embedding for chunk messages.
  • Always citing docs for out-of-scope questions:
    • The system now gates context by similarity. If it still feels too eager, increase the threshold in src/lib/server/ai.ts.
  • OAuth avatar missing or late:
    • We persist the provider image on link/sign-in and prefer the DB image in session. Clear cache and refresh.
  • Edit/regenerate buttons clickable during generation:
    • The UI disables these while generating and shows a status label. If you donโ€™t see this, rebuild the app.

๐Ÿš€ Deployment

Production Checklist

  • โœ… Set NODE_ENV=production
  • โœ… Configure production database URL
  • โœ… Set secure AUTH_SECRET
  • โœ… Configure GOOGLE_AI_API_KEY for ShieldBot
  • โœ… Configure EMBEDDING_API_URL for RAG
  • โœ… Enable SSL for database connections
  • โœ… Configure reverse proxy
  • โœ… Set up monitoring and logging

Docker Deployment

# Build and run with Docker Compose
docker-compose up -d

# Check service status
docker-compose ps

# View logs
docker-compose logs -f

๐Ÿ“Š Performance Optimizations

Frontend

  • Code Splitting - Automatic bundle optimization
  • Component Library - Reusable, optimized components
  • TailwindCSS Purging - Optimized CSS for production
  • Image Optimization - Compressed and optimized assets
  • Streaming Optimization - Efficient AI response streaming
  • Markdown Rendering - Optimized syntax highlighting

Backend

  • Connection Pooling - Efficient database connections
  • Query Optimization - Optimized database queries
  • Caching - Strategic caching implementation
  • Error Handling - Graceful error management
  • AI Response Caching - Optimized AI service calls
  • Vector Indexing - Optimized vector similarity search

RAG System

  • Chunking Strategy - Optimal document chunking for context
  • Vector Indexing - Efficient similarity search with pgvector
  • Embedding Caching - Cached embeddings for performance
  • Context Filtering - Smart context selection and ranking

Message Versioning System

  • Tree Structure - Messages organized in tree structure with parentId relationships
  • Version Groups - Messages grouped by versionGroupId for easy version tracking
  • Active Flags - isActive flag to identify current version of each message
  • Version Numbers - Sequential versionNumber for version ordering
  • Context Preservation - AI maintains conversation context across message versions
  • Data Integrity - Proper cleanup of related messages when conversations are deleted

๐Ÿค 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

This project is licensed under the MIT License - see the LICENSE file for details.

๐Ÿ™ Acknowledgments


ShieldAuth - Built with โค๏ธ using modern web technologies for secure, scalable authentication with intelligent AI assistance and advanced RAG capabilities.

๐Ÿ”ฎ Recent Updates

v4.0 - Complete RAG Integration ๐ŸŽ‰

๐Ÿง  Advanced RAG System

  • โœ… Document Ingestion - Upload and process documents for AI context
  • โœ… Vector Embeddings - Automatic embedding generation using Gemini API
  • โœ… Semantic Search - Vector-based similarity search with pgvector
  • โœ… Context Retrieval - Automatic retrieval of relevant document snippets
  • โœ… Citation System - Track and display source documents with relevance scores
  • โœ… Python Microservice - Containerized embedding service with FastAPI

๐Ÿ’ฌ Enhanced AI Chat Experience

  • โœ… Context-Aware Responses - AI responses enhanced with retrieved document context
  • โœ… File Upload Support - Upload .txt, .doc, .docx, .pdf files for analysis
  • โœ… Citation Display - Show which documents informed the AI's answer
  • โœ… Markdown Rendering - Rich text formatting with syntax highlighting
  • โœ… Code Highlighting - Syntax highlighting for code blocks using Shiki
  • โœ… Streaming Integration - Real-time streaming with context integration

๐Ÿ”ง Technical Improvements

  • โœ… pgvector Integration - PostgreSQL with vector similarity search
  • โœ… Embedding Service - Python FastAPI microservice for embeddings
  • โœ… Database Schema - RAG tables for documents, chunks, and embeddings
  • โœ… API Endpoints - Document ingestion and context retrieval endpoints
  • โœ… Error Handling - Comprehensive error handling for RAG operations
  • โœ… Performance - Optimized vector search and context retrieval

v3.0 - Complete Forking Implementation ๐ŸŽ‰

๐Ÿค– Enhanced AI Chat Experience

  • โœ… Message Versioning - Complete message forking and versioning system
  • โœ… Edit & Regenerate - Edit any message or regenerate AI responses
  • โœ… Smart Context Handling - AI maintains proper conversation context for versioned messages
  • โœ… Streaming Regeneration - Real-time streaming for regenerated responses
  • โœ… First Message Protection - Prevents forking of first messages with user-friendly popup

๐Ÿ’ฌ Advanced Chat Management

  • โœ… Professional Rename Modal - Beautiful modal form instead of browser prompts
  • โœ… Smart Auto-Rename - Automatic chat naming based on conversation topics
  • โœ… Chat Deletion - Complete cleanup of messages and conversations
  • โœ… Empty State Handling - Beautiful UI when no conversations exist
  • โœ… Page Refresh Continuity - Resume last active chat after page reload

๐ŸŽจ Enhanced User Interface

  • โœ… Auto-Scroll Functionality - Smooth scrolling to bottom on new messages
  • โœ… Hidden Scrollbars - Clean UI with custom scrollbar hiding
  • โœ… Keyboard Shortcuts - Enter/Escape key support for all modals
  • โœ… Responsive Design - Perfect display on all devices
  • โœ… Dark Theme Consistency - Unified dark theme throughout

๐Ÿ”ง Technical Improvements

  • โœ… Error Handling - Comprehensive error handling and user feedback
  • โœ… State Management - Enhanced chat store with proper state management
  • โœ… API Optimization - Improved API endpoints for better performance
  • โœ… Database Integrity - Proper message cleanup and data consistency
  • โœ… Real-time Updates - Immediate UI updates for all chat operations

v2.0 - ShieldBot AI Integration

  • โœ… AI Chat Interface - Full-screen chat with ShieldBot AI assistant
  • โœ… Streaming Responses - Word-by-word AI response streaming
  • โœ… Model Selection - Support for multiple Gemini AI models
  • โœ… Chat Management - Auto-rename, manual rename, and chat organization
  • โœ… Security Focus - Specialized cybersecurity guidance and advice
  • โœ… Responsive Design - Mobile-optimized chat interface
  • โœ… UI Improvements - Fixed ShieldBot card styling and dashboard icons
  • โœ… Performance - Optimized streaming and error handling

About

ShieldAuth is an authntication application that provides auth controls for admin and a friendly chatbot ShieldBot that is completly forkable, RAG implemented and context aware

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors