~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.
Python academiaanthropicarxivbravedeep-researchencryptionhome-automationhomeserverlocallocal-deep-researchlocal-llmmistralollamaopenaipubmedresearchresearch-toolretrieval-augmented-generationsearxngself-hosted
Fix Font Awesome icons by implementing proper static file serving for Vite dist assets
LearningCircuitedc98bc9cc06
diff --git a/docs/FRONTEND_BUILD_SYSTEM.md b/docs/FRONTEND_BUILD_SYSTEM.mdnew file mode 100644index 0000000000..317e0cc61c--- /dev/null+++ b/docs/FRONTEND_BUILD_SYSTEM.md@@ -0,0 +1,302 @@+# Frontend Build System Guide++## Overview++Local Deep Research uses a modern frontend build system with **npm** for package management and **Vite** for bundling. This ensures all JavaScript libraries and CSS frameworks are served locally without any external CDN dependencies.++## Quick Start++### Development Mode++1. **Install dependencies** (first time only):+ ```bash+ npm install+ ```++2. **Start the Flask server**:+ ```bash+ cd src+ python -m local_deep_research.web.app+ ```++3. **Start Vite dev server** (in a separate terminal):+ ```bash+ npm run dev+ ```++ Vite will start on http://localhost:5173 with Hot Module Replacement (HMR) for instant updates.++### Production Mode++1. **Build production assets**:+ ```bash+ npm run build+ ```++ This creates optimized bundles in `src/local_deep_research/web/static/dist/`++2. **Start Flask normally**:+ ```bash+ cd src+ python -m local_deep_research.web.app+ ```++ Flask will automatically serve the built assets from the `dist/` folder.++## Architecture++### Why No CDNs?++- **Security**: All code is audited and served from your server+- **Privacy**: No user data leaks to third-party CDNs+- **Reliability**: Works offline, no dependency on external services+- **Performance**: Assets are optimized and cached locally+- **Compliance**: Important for enterprise/government deployments++### Technology Stack++- **npm**: Package manager for JavaScript dependencies+- **Vite**: Fast build tool with instant HMR in development+- **Flask**: Python web framework serving the application++## Dependencies++All frontend dependencies are managed in `package.json`:++| Library | Purpose | License |+|---------|---------|---------|+| `@fortawesome/fontawesome-free` | Icons throughout the UI | Font Awesome Free |+| `bootstrap` | CSS framework for some pages | MIT |+| `bootstrap-icons` | Additional icons | MIT |+| `chart.js` | Analytics charts | MIT |+| `highlight.js` | Code syntax highlighting | BSD-3-Clause |+| `marked` | Markdown rendering | MIT |+| `socket.io-client` | Real-time updates | MIT |+| `jspdf` & `html2canvas` | PDF export | MIT |++## File Structure++```+.+├── package.json # npm dependencies and scripts+├── vite.config.js # Vite configuration+├── node_modules/ # Downloaded packages (git-ignored)+└── src/local_deep_research/web/+ ├── static/+ │ ├── dist/ # Production build output (git-ignored)+ │ │ ├── css/ # Bundled CSS+ │ │ ├── fonts/ # Font files (Font Awesome, Bootstrap Icons)+ │ │ └── js/ # Bundled JavaScript+ │ ├── js/+ │ │ ├── app.js # Main entry point importing all dependencies+ │ │ └── ... # Other application JavaScript+ │ └── css/+ │ └── styles.css # Application styles+ ├── templates/+ │ └── base.html # Uses Vite helper for asset loading+ └── utils/+ └── vite_helper.py # Flask-Vite integration++```++## Common Tasks++### Update Dependencies++```bash+# Update all packages to latest versions+npm update++# Check for security vulnerabilities+npm audit++# Auto-fix vulnerabilities (if possible)+npm audit fix++# Rebuild after updates+npm run build+```++### Add a New Library++1. Install the package:+ ```bash+ npm install library-name+ ```++2. Import in `src/local_deep_research/web/static/js/app.js`:+ ```javascript+ import 'library-name/dist/library.css'; // If it has CSS+ import Library from 'library-name'; // Import JS++ // Make available globally if needed+ window.Library = Library;+ ```++3. Rebuild:+ ```bash+ npm run build+ ```++### Debug Build Issues++```bash+# Clean install (removes node_modules and reinstalls)+rm -rf node_modules package-lock.json+npm install++# Verbose build output+npm run build -- --debug++# Check what's included in the bundle+npm run build -- --sourcemap+```++## Security++### Automated Checks++- **Pre-commit Hook**: `.pre-commit-hooks/check-external-resources.py` prevents CDN references+- **GitHub Dependabot**: Enable it to get automated PRs for security updates+- **npm audit**: Run in CI/CD pipeline to catch vulnerabilities++### Manual Security Audit++```bash+# Check for known vulnerabilities+npm audit++# See dependency tree+npm list++# Check outdated packages+npm outdated+```++## Troubleshooting++### Icons Not Showing++**Problem**: Font Awesome or Bootstrap icons appear as squares++**Solution**:+1. Ensure fonts were built: Check `src/local_deep_research/web/static/dist/fonts/`+2. Rebuild if missing: `npm run build`+3. Clear browser cache: Ctrl+F5 (or Cmd+Shift+R on Mac)++### JavaScript Not Loading++**Problem**: Libraries like marked or Chart.js not working++**Solution**:+1. Check browser console for errors+2. Verify npm packages installed: `npm install`+3. Rebuild assets: `npm run build`+4. Check Flask is serving from dist: Look for `.vite/manifest.json`++### Vite Dev Server Issues++**Problem**: HMR not working or connection refused++**Solution**:+1. Ensure Vite is running: `npm run dev`+2. Check port 5173 is free: `lsof -i :5173`+3. Verify Flask debug mode is on for development++### Build Errors++**Problem**: `npm run build` fails++**Solution**:+1. Check Node.js version: `node --version` (should be 16+ or 18+)+2. Clear cache and reinstall:+ ```bash+ rm -rf node_modules package-lock.json+ npm cache clean --force+ npm install+ ```+3. Check for conflicting global packages: `npm list -g --depth=0`++## Development Tips++### Using Vite Dev Server++When developing, Vite provides:+- **Instant updates**: Changes appear immediately without page refresh+- **Better errors**: Build errors shown in browser+- **Fast startup**: No bundling needed during development++### Production Optimization++Vite automatically:+- Minifies JavaScript and CSS+- Tree-shakes unused code+- Splits code into chunks+- Generates sourcemaps for debugging+- Optimizes images and fonts+- Creates cache-busting hashes++### Flask Integration++The `ViteHelper` class (`src/local_deep_research/web/utils/vite_helper.py`) handles:+- Loading from Vite dev server in development+- Loading built assets in production+- Fallback if build hasn't run yet++## CI/CD Integration++Add to your CI pipeline:++```yaml+# Example GitHub Actions+- name: Setup Node.js+ uses: actions/setup-node@v3+ with:+ node-version: '18'+ cache: 'npm'++- name: Install dependencies+ run: npm ci++- name: Security audit+ run: npm audit --audit-level=high++- name: Build assets+ run: npm run build++- name: Check for external resources+ run: python .pre-commit-hooks/check-external-resources.py+```++## Migration from CDNs++If you're updating from an older version that used CDNs:++1. **Pull latest changes**+2. **Install npm dependencies**: `npm install`+3. **Build assets**: `npm run build`+4. **Clear browser cache**: CDN resources may be cached+5. **Test thoroughly**: Ensure all features work offline++## Contributing++When adding frontend features:++1. **No external resources**: All assets must be in npm packages+2. **Update package.json**: Add new dependencies properly+3. **Import in app.js**: Ensure libraries are imported+4. **Test the build**: Run `npm run build` before committing+5. **Document changes**: Update this guide if needed++## Support++- **Build issues**: Check Node.js version and reinstall packages+- **Runtime issues**: Check browser console and Flask logs+- **Security concerns**: Run `npm audit` and update packages+- **Performance**: Vite automatically optimizes; check bundle size with `npm run build`++---++*Last updated: August 2024*+*Vite version: 5.x*+*npm version: 10.x*diff --git a/package.json b/package.jsonnew file mode 100644index 0000000000..55555eb548--- /dev/null+++ b/package.json@@ -0,0 +1,33 @@+{+ "name": "local-deep-research-web",+ "version": "1.0.0",+ "description": "Web frontend for Local Deep Research",+ "private": true,+ "type": "module",+ "scripts": {+ "dev": "vite",+ "build": "vite build",+ "preview": "vite preview",+ "update": "npm update",+ "audit": "npm audit",+ "audit-fix": "npm audit fix"+ },+ "dependencies": {+ "@fortawesome/fontawesome-free": "^6.5.0",+ "bootstrap": "^5.3.0",+ "bootstrap-icons": "^1.11.0",+ "chart.js": "^4.4.0",+ "chartjs-adapter-date-fns": "^3.0.0",+ "chartjs-plugin-annotation": "^3.0.0",+ "date-fns": "^2.30.0",+ "highlight.js": "^11.9.0",+ "html2canvas": "^1.4.1",+ "jspdf": "^2.5.1",+ "marked": "^11.0.0",+ "socket.io-client": "^4.6.0"+ },+ "devDependencies": {+ "axe-core": "^4.8.0",+ "vite": "^5.0.0"+ }+}diff --git a/src/local_deep_research/web/app_factory.py b/src/local_deep_research/web/app_factory.pyindex 74120cdc85..04307ab671 100644--- a/src/local_deep_research/web/app_factory.py+++ b/src/local_deep_research/web/app_factory.py@@ -40,19 +40,24 @@ def create_app():TEMPLATE_DIR = (package_dir / "templates").as_posix()# Initialize Flask app with package directories- app = Flask(- __name__, static_folder=STATIC_DIR, template_folder=TEMPLATE_DIR- )+ # Set static_folder to None to disable Flask's built-in static handling+ # We'll use our custom static route instead to handle dist folder+ app = Flask(__name__, static_folder=None, template_folder=TEMPLATE_DIR)+ # Store static dir for custom handling+ app.config["STATIC_DIR"] = STATIC_DIRlogger.debug(f"Using package static path: {STATIC_DIR}")logger.debug(f"Using package template path: {TEMPLATE_DIR}")except Exception:# Fallback for developmentlogger.exception("Package directories not found, using fallback paths")+ # Set static_folder to None to disable Flask's built-in static handlingapp = Flask(__name__,- static_folder=str(Path("static").resolve()),+ static_folder=None,template_folder=str(Path("templates").resolve()),)+ # Store static dir for custom handling+ app.config["STATIC_DIR"] = str(Path("static").resolve())# App configuration# Generate or load a unique SECRET_KEY per installation@@ -144,6 +149,11 @@ def create_app():)logger.info("=" * 60)+ # Initialize Vite helper for asset management+ from .utils.vite_helper import vite++ vite.init_app(app)+# Register socket servicesocket_service = SocketIOService(app=app)@@ -446,14 +456,30 @@ def register_blueprints(app):# Add favicon route@app.route("/favicon.ico")def favicon():+ static_dir = app.config.get("STATIC_DIR", "static")return send_from_directory(- app.static_folder, "favicon.ico", mimetype="image/x-icon"+ static_dir, "favicon.ico", mimetype="image/x-icon")# Add static route at the app level for compatibility@app.route("/static/<path:path>")def app_serve_static(path):- return send_from_directory(app.static_folder, path)+ static_dir = Path(app.config.get("STATIC_DIR", "static"))++ # First try to serve from dist directory (for built assets)+ dist_path = static_dir / "dist"+ file_path = dist_path / path++ if file_path.exists():+ return send_from_directory(str(dist_path), path)++ # Fall back to regular static folder+ regular_path = static_dir / path++ if regular_path.exists():+ return send_from_directory(str(static_dir), path)++ return make_response(jsonify({"error": "Not found"}), 404)def register_error_handlers(app):diff --git a/src/local_deep_research/web/routes/research_routes.py b/src/local_deep_research/web/routes/research_routes.pyindex cb46c7fe83..41e9776fe9 100644--- a/src/local_deep_research/web/routes/research_routes.py+++ b/src/local_deep_research/web/routes/research_routes.py@@ -6,6 +6,7 @@ from pathlib import Pathfrom flask import (Blueprint,+ abort,g,jsonify,redirect,@@ -44,8 +45,27 @@ research_bp = Blueprint("research", __name__)@research_bp.route("/static/<path:path>")def serve_static(path):"""Serve static files"""- static_dir = Path(__file__).parent.parent / "static"- return send_from_directory(str(static_dir), path)+ from flask import current_app++ # Get static dir from app config or fallback to default+ static_dir = Path(+ current_app.config.get(+ "STATIC_DIR", Path(__file__).parent.parent / "static"+ )+ )++ # First try to serve from dist directory (for built assets)+ dist_path = static_dir / "dist" / path+ if dist_path.exists():+ return send_from_directory(str(static_dir / "dist"), path)++ # Fall back to regular static folder+ regular_path = static_dir / path+ if regular_path.exists():+ return send_from_directory(str(static_dir), path)++ # File not found+ abort(404)# Add static route at the root leveldiff --git a/src/local_deep_research/web/static/js/app.js b/src/local_deep_research/web/static/js/app.jsnew file mode 100644index 0000000000..39e2fc1994--- /dev/null+++ b/src/local_deep_research/web/static/js/app.js@@ -0,0 +1,84 @@+/**+ * Main application entry point for Vite+ * Imports all vendor dependencies and makes them available globally+ */++// Import CSS first+import '@fortawesome/fontawesome-free/css/all.css';+import 'bootstrap/dist/css/bootstrap.min.css';+import 'bootstrap-icons/font/bootstrap-icons.css';+import 'highlight.js/styles/github-dark.css';+import '../css/styles.css';++// Import and setup core libraries+import { marked } from 'marked';+import io from 'socket.io-client';+import hljs from 'highlight.js';+import jsPDF from 'jspdf';+import html2canvas from 'html2canvas';++// Import Bootstrap JavaScript+import * as bootstrap from 'bootstrap';++// Chart.js and plugins (imported but not attached to window by default)+import Chart from 'chart.js/auto';+import 'chartjs-adapter-date-fns';+import annotationPlugin from 'chartjs-plugin-annotation';++// Register Chart.js plugin+Chart.register(annotationPlugin);++// Make libraries available globally for existing code compatibility+window.marked = marked;+window.io = io;+window.hljs = hljs;+window.jsPDF = jsPDF;+window.html2canvas = html2canvas;+window.bootstrap = bootstrap;+window.Chart = Chart;++// Configure marked+marked.setOptions({+ headerIds: false,+ mangle: false,+ smartypants: false,+ highlight: function(code, lang) {+ if (lang && hljs.getLanguage(lang)) {+ try {+ return hljs.highlight(code, { language: lang }).value;+ } catch (err) {+ console.error('Highlight error:', err);+ }+ }+ return code;+ }+});++// Initialize highlight.js when DOM is ready+document.addEventListener('DOMContentLoaded', () => {+ // Highlight all code blocks+ document.querySelectorAll('pre code').forEach((block) => {+ hljs.highlightElement(block);+ });++ // Initialize Bootstrap tooltips and popovers if present+ const tooltipTriggerList = document.querySelectorAll('[data-bs-toggle="tooltip"]');+ [...tooltipTriggerList].map(tooltipTriggerEl => new bootstrap.Tooltip(tooltipTriggerEl));++ const popoverTriggerList = document.querySelectorAll('[data-bs-toggle="popover"]');+ [...popoverTriggerList].map(popoverTriggerEl => new bootstrap.Popover(popoverTriggerEl));+});++// Log successful initialization+console.log('✨ LDR App initialized with Vite');++// Export for potential module usage+export {+ marked,+ io,+ hljs,+ jsPDF,+ html2canvas,+ bootstrap,+ Chart+};diff --git a/src/local_deep_research/web/templates/auth/change_password.html b/src/local_deep_research/web/templates/auth/change_password.htmlindex 26cb52a41b..fdaba6d973 100644--- a/src/local_deep_research/web/templates/auth/change_password.html+++ b/src/local_deep_research/web/templates/auth/change_password.html@@ -4,8 +4,12 @@<meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>Change Password - Local Deep Research</title>- <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">- <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css">++ <!-- Vite HMR for development -->+ {{ vite_hmr() }}++ <!-- Load all vendor dependencies and styles through Vite -->+ {{ vite_asset('js/app.js') }}<style>body {background-color: #f8f9fa;@@ -177,7 +181,6 @@</div></div>- <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script><script>function checkPasswordStrength(password) {const strengthBar = document.getElementById('password-strength');diff --git a/src/local_deep_research/web/templates/auth/login.html b/src/local_deep_research/web/templates/auth/login.htmlindex eba5a9ebf2..5c145edb55 100644--- a/src/local_deep_research/web/templates/auth/login.html+++ b/src/local_deep_research/web/templates/auth/login.html@@ -4,8 +4,15 @@<meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>Login - Local Deep Research</title>++ <!-- Vite HMR for development -->+ {{ vite_hmr() }}++ <!-- Load all vendor dependencies and styles through Vite -->+ {{ vite_asset('js/app.js') }}++ <!-- Keep local styles --><link rel="stylesheet" href="{{ url_for('research.serve_static', path='css/styles.css') }}">- <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css"><style>/* Override main layout for auth pages */body {diff --git a/src/local_deep_research/web/templates/auth/register.html b/src/local_deep_research/web/templates/auth/register.htmlindex e46652d090..63261e364d 100644--- a/src/local_deep_research/web/templates/auth/register.html+++ b/src/local_deep_research/web/templates/auth/register.html@@ -4,8 +4,15 @@<meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>Register - Local Deep Research</title>++ <!-- Vite HMR for development -->+ {{ vite_hmr() }}++ <!-- Load all vendor dependencies and styles through Vite -->+ {{ vite_asset('js/app.js') }}++ <!-- Keep local styles --><link rel="stylesheet" href="{{ url_for('research.serve_static', path='css/styles.css') }}">- <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css"><style>/* Override main layout for auth pages */body {diff --git a/src/local_deep_research/web/templates/base.html b/src/local_deep_research/web/templates/base.htmlindex cdd2ce14c1..186ed1b397 100644--- a/src/local_deep_research/web/templates/base.html+++ b/src/local_deep_research/web/templates/base.html@@ -5,9 +5,14 @@<meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="csrf-token" content="{{ csrf_token() }}"><title>{% block title %}Deep Research System{% endblock %}</title>+ <!-- Vite HMR for development -->+ {{ vite_hmr() }}++ <!-- Load all vendor dependencies and styles through Vite -->+ {{ vite_asset('js/app.js') }}++ <!-- Keep local styles that aren't in npm packages --><link rel="stylesheet" href="{{ url_for('research.serve_static', path='css/styles.css') }}">- <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css" integrity="sha512-Fo3rlrZj/k7ujTnHg4CGR2D7kSs0v4LLanw2qksYuRlEzO+tcaEPQogQ0KaoGN26/zrn20ImR1DfuLWnOo7aBA==" crossorigin="anonymous" referrerpolicy="no-referrer">- <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.7.0/styles/github-dark.min.css" integrity="sha512-rO+olRTkcf304DQBxSWxln8JXCzTHlKnIdnMUwYvQa9/Jd4cQaNkItIUj6Z4nvW1dqK0SKXLbn9h4KwZTNtAyw==" crossorigin="anonymous" referrerpolicy="no-referrer">{% block extra_head %}{% endblock %}</head><body>@@ -64,12 +69,7 @@});</script>- <!-- External Libraries -->- <script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/4.4.1/socket.io.min.js" integrity="sha512-iqRVtNB+t9O+epcgUTIPF+nklypcR23H1yR1NFM9kffn6/iBhZ9bTB6oKLaGMv8JE9UgjcwfBFg/eHC/VMws+g==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>- <script src="https://cdn.jsdelivr.net/npm/[email protected]/lib/marked.umd.min.js" integrity="sha512-P0TPTfSkSA7/I3P0xjPz+qIrXojG8vEAU2EfFkaYFX7tdN1yeMM4ryUfuHHMKOugMpb+0bgYAmDl+2aN7Bogpg==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>- <script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.7.0/highlight.min.js" integrity="sha512-bgHRAiTjGrzHzLyKOnpFvaEpGzJet3z4tZnXGjpsCcqOnAH6VGUx9frc5bcIhKTVLEiCO6vEhNAgx5jtLUYrfA==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>- <script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/2.5.1/jspdf.umd.min.js" integrity="sha512-qZvrmS2ekKPF2mSznTQsxqPgnpkI4DNTlrdUmTzrDgektczlKNRRhy5X5AAOnx5S09ydFYWWNSfcEqDTTHgtNA==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>- <script src="https://cdnjs.cloudflare.com/ajax/libs/html2canvas/1.4.1/html2canvas.min.js" integrity="sha512-BNaRQnYJYiPSqHHDb58B0yaPfCu+Wgds8Gp/gU33kqBtgNS4tSPHuGibyoeqMV/TJlSKda6FXzoEyYGjTe+vXA==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>+ <!-- All vendor libraries are now loaded through Vite in the <head> section --><!-- Core JS --><script src="{{ url_for('research.serve_static', path='js/services/formatting.js') }}"></script>diff --git a/src/local_deep_research/web/templates/pages/benchmark.html b/src/local_deep_research/web/templates/pages/benchmark.htmlindex 269ad295d9..1422a7fa9b 100644--- a/src/local_deep_research/web/templates/pages/benchmark.html+++ b/src/local_deep_research/web/templates/pages/benchmark.html@@ -8,7 +8,6 @@{% block extra_head %}<meta name="csrf-token" content="{{ csrf_token() }}"><link rel="stylesheet" href="{{ url_for('research.serve_static', path='css/custom_dropdown.css') }}">-<script src="https://cdn.jsdelivr.net/npm/chart.js"></script><style>.benchmark-card {width: 100%;@@ -494,7 +493,6 @@}}-/* Performance Charts Styles */.charts-section {margin-top: 20px;@@ -810,7 +808,6 @@</div></div>-<!-- Action Buttons --><div class="form-actions"><button type="button" id="validate-config-btn" class="btn btn-secondary">@@ -980,7 +977,6 @@ let evalModelData = null;let evalTempData = null;let evalEndpointData = null;-// Charts for performance trackinglet accuracyChart = null;let timingChart = null;@@ -1877,7 +1873,6 @@ function initializeCharts() {});}-function updateCharts(status) {if (!accuracyChart || !timingChart || !searchResultsChart || !status) return;@@ -2532,7 +2527,6 @@ function refreshEvaluationModels() {// This was causing the dropdown to open unexpectedly on page load}-function setupEvaluationEventHandlers() {// Provider change handlerif (evaluationProviderSelect) {@@ -2712,7 +2706,6 @@ function saveEvaluationSetting(key, value) {});}-</script>{% endblock %}diff --git a/src/local_deep_research/web/templates/pages/context_overflow.html b/src/local_deep_research/web/templates/pages/context_overflow.htmlindex ea593a4a2c..66374d988d 100644--- a/src/local_deep_research/web/templates/pages/context_overflow.html+++ b/src/local_deep_research/web/templates/pages/context_overflow.html@@ -5,9 +5,6 @@{% block title %}Context Overflow Analytics - Deep Research System{% endblock %}{% block extra_head %}-<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>-<script src="https://cdn.jsdelivr.net/npm/[email protected]/index.min.js"></script>-<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/chartjs-adapter-date-fns.bundle.min.js"></script><style>.overflow-grid {display: grid;diff --git a/src/local_deep_research/web/templates/pages/cost_analytics.html b/src/local_deep_research/web/templates/pages/cost_analytics.htmlindex 733990c9b2..64b19b4b58 100644--- a/src/local_deep_research/web/templates/pages/cost_analytics.html+++ b/src/local_deep_research/web/templates/pages/cost_analytics.html@@ -5,7 +5,6 @@{% block title %}Cost Analytics - Deep Research System{% endblock %}{% block extra_head %}-<script src="https://cdn.jsdelivr.net/npm/chart.js"></script><style>.cost-analytics-container {max-width: 1400px;@@ -255,7 +254,6 @@left: 0;}-.loading, .error, .no-data {text-align: center;padding: 3rem;diff --git a/src/local_deep_research/web/templates/pages/details.html b/src/local_deep_research/web/templates/pages/details.htmlindex 8909f7a548..79fd3d4acf 100644--- a/src/local_deep_research/web/templates/pages/details.html+++ b/src/local_deep_research/web/templates/pages/details.html@@ -3,8 +3,6 @@{% block title %}Research Details - Deep Research System{% endblock %}{% block extra_head %}-<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>-<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/chartjs-plugin-annotation.min.js"></script><style>.metrics-section {margin-top: 2rem;@@ -341,7 +339,6 @@</div></div>-<!-- Token Metrics Section --><div class="card metrics-section" id="token-metrics-section" style="display: none;"><div class="card-header">@@ -469,7 +466,6 @@</div></div>-<!-- Search Timeline --><div style="margin-top: 2rem;"><h3><i class="fas fa-clock"></i> Search Timeline</h3>diff --git a/src/local_deep_research/web/templates/pages/history.html b/src/local_deep_research/web/templates/pages/history.htmlindex af979d90ba..fd99f51751 100644--- a/src/local_deep_research/web/templates/pages/history.html+++ b/src/local_deep_research/web/templates/pages/history.html@@ -7,7 +7,6 @@{% block styles %}{{ super() }}<link rel="stylesheet" href="{{ url_for('research.serve_static', path='css/components/history.css') }}">-<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">{% endblock %}{% block content %}@@ -50,5 +49,4 @@<!-- Then load the component --><script src="{{ url_for('research.serve_static', path='js/components/history.js') }}"></script><!-- Add Bootstrap JavaScript -->-<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous"></script>{% endblock %}diff --git a/src/local_deep_research/web/templates/pages/link_analytics.html b/src/local_deep_research/web/templates/pages/link_analytics.htmlindex 1e463c2129..191e21153a 100644--- a/src/local_deep_research/web/templates/pages/link_analytics.html+++ b/src/local_deep_research/web/templates/pages/link_analytics.html@@ -3,7 +3,6 @@{% block title %}Link Analytics - Deep Research System{% endblock %}{% block extra_head %}-<script src="https://cdn.jsdelivr.net/npm/chart.js"></script><style>.link-analytics-container {max-width: 1200px;diff --git a/src/local_deep_research/web/templates/pages/metrics.html b/src/local_deep_research/web/templates/pages/metrics.htmlindex 2df6912728..9d28218f3b 100644--- a/src/local_deep_research/web/templates/pages/metrics.html+++ b/src/local_deep_research/web/templates/pages/metrics.html@@ -5,7 +5,6 @@{% block title %}Metrics Dashboard - Deep Research System{% endblock %}{% block extra_head %}-<script src="https://cdn.jsdelivr.net/npm/chart.js"></script><style>.metrics-grid {display: grid;@@ -979,7 +978,6 @@(metricsData.by_model && metricsData.by_model.length > 0) ||(metricsData.recent_researches && metricsData.recent_researches.length > 0);-if (hasData) {// We have data, display normallydisplayMetrics();@@ -1249,7 +1247,6 @@// Get strategy data from metricsData (added by our API)const strategyData = metricsData.strategy_analytics;-if (strategyData && strategyData.strategy_usage && strategyData.strategy_usage.length > 0) {strategyData.strategy_usage.forEach(strategy => {const item = document.createElement('div');diff --git a/src/local_deep_research/web/templates/pages/news-subscription-form.html b/src/local_deep_research/web/templates/pages/news-subscription-form.htmlindex a6422b2f7e..c22a13fab9 100644--- a/src/local_deep_research/web/templates/pages/news-subscription-form.html+++ b/src/local_deep_research/web/templates/pages/news-subscription-form.html@@ -4,8 +4,6 @@{% block title %}{{ 'Edit' if subscription else 'Create' }} News Subscription - LDR{% endblock %}{% block extra_head %}-<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">-<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/font/bootstrap-icons.css" integrity="sha384-EvBWSlnoFgZlXJvpzS+MAUEjvN7+gcCwH+qh7GRFOGgZO0PuwOFro7qPOJnLfe7l" crossorigin="anonymous"><link rel="stylesheet" href="{{ url_for('research.serve_static', path='css/custom_dropdown.css') }}"><link rel="stylesheet" href="{{ url_for('research.serve_static', path='css/news.css') }}"><style>@@ -241,7 +239,6 @@</form></div>-<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous"></script><script src="{{ url_for('research.serve_static', path='js/components/custom_dropdown.js') }}"></script><script>// Global variables@@ -848,7 +845,6 @@ async function handleTestRun(event) {}}-// Handle create and run button clickasync function handleCreateAndRun(event) {if (event) {diff --git a/src/local_deep_research/web/templates/pages/news.html b/src/local_deep_research/web/templates/pages/news.htmlindex ac46be2d28..e80e36819b 100644--- a/src/local_deep_research/web/templates/pages/news.html+++ b/src/local_deep_research/web/templates/pages/news.html@@ -5,8 +5,6 @@{% block extra_head %}<meta name="csrf-token" content="{{ csrf_token() }}">-<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">-<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/font/bootstrap-icons.css" integrity="sha384-EvBWSlnoFgZlXJvpzS+MAUEjvN7+gcCwH+qh7GRFOGgZO0PuwOFro7qPOJnLfe7l" crossorigin="anonymous"><link rel="stylesheet" href="{{ url_for('research.serve_static', path='css/custom_dropdown.css') }}"><link rel="stylesheet" href="{{ url_for('research.serve_static', path='css/news.css') }}"><link rel="stylesheet" href="{{ url_for('research.serve_static', path='css/news-enhanced.css') }}">@@ -153,8 +151,6 @@<!-- Will be populated with trending topics --></div>--<h3 class="mt-4 d-flex justify-content-between align-items-center"><span><i class="bi bi-clock-history"></i> Recent Searches</span><button class="btn btn-sm btn-outline-secondary" onclick="clearSearchHistory()" title="Clear search history">@@ -173,8 +169,6 @@</div></div>--<!-- Subscriptions Modal --><div class="modal fade" id="subscriptionsModal" tabindex="-1"><div class="modal-dialog modal-lg">@@ -338,8 +332,6 @@</div><!-- Add marked.js for markdown rendering -->-<script src="https://cdnjs.cloudflare.com/ajax/libs/marked/4.0.2/marked.min.js" integrity="sha384-pF+2qz7eFoUyrCTPr8gVboYJ7fNpmJKJzl0vPX6w3XDML+Of8bMSyd6fZIRJdwo7" crossorigin="anonymous"></script>-<!-- Add UI services for markdown rendering --><script src="{{ url_for('research.serve_static', path='js/services/ui.js') }}"></script>@@ -353,8 +345,6 @@<script src="{{ url_for('research.serve_static', path='js/components/subscription-manager.js') }}"></script><!-- Add Bootstrap JavaScript -->-<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous"></script>-<!-- Add design enhancements --><script src="{{ url_for('research.serve_static', path='js/news-enhancements.js') }}"></script>{% endblock %}diff --git a/src/local_deep_research/web/templates/pages/news_cleaned.html b/src/local_deep_research/web/templates/pages/news_cleaned.htmlindex 885bd35dc5..54500453b8 100644--- a/src/local_deep_research/web/templates/pages/news_cleaned.html+++ b/src/local_deep_research/web/templates/pages/news_cleaned.html@@ -3,8 +3,6 @@{% block title %}LDR News - AI-Powered Research Feed{% endblock %}{% block extra_head %}-<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">-<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/font/bootstrap-icons.css" integrity="sha384-EvBWSlnoFgZlXJvpzS+MAUEjvN7+gcCwH+qh7GRFOGgZO0PuwOFro7qPOJnLfe7l" crossorigin="anonymous"><link rel="stylesheet" href="{{ url_for('research.serve_static', path='css/news.css') }}">{% endblock %}@@ -151,10 +149,7 @@</div></div>-<!-- Add marked.js for markdown rendering -->-<script src="https://cdnjs.cloudflare.com/ajax/libs/marked/4.0.2/marked.min.js" integrity="sha384-pF+2qz7eFoUyrCTPr8gVboYJ7fNpmJKJzl0vPX6w3XDML+Of8bMSyd6fZIRJdwo7" crossorigin="anonymous"></script>-<!-- Add UI services for markdown rendering --><script src="{{ url_for('research.serve_static', path='js/services/ui.js') }}"></script>@@ -162,5 +157,4 @@<script src="{{ url_for('research.serve_static', path='js/pages/news.js') }}"></script><!-- Add Bootstrap JavaScript -->-<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous"></script>{% endblock %}diff --git a/src/local_deep_research/web/templates/pages/results.html b/src/local_deep_research/web/templates/pages/results.htmlindex 6840e3e4e1..e3b467b4a7 100644--- a/src/local_deep_research/web/templates/pages/results.html+++ b/src/local_deep_research/web/templates/pages/results.html@@ -61,13 +61,10 @@{% block styles %}{{ super() }}<!-- Bootstrap CSS for modal -->-<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">{% endblock %}{% block page_scripts %}<!-- Bootstrap JS for modal functionality -->-<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script>-<!-- Fallback utilities in case main services are not available --><script src="{{ url_for('research.serve_static', path='js/components/fallback/ui.js') }}"></script><script src="{{ url_for('research.serve_static', path='js/components/fallback/formatting.js') }}"></script>diff --git a/src/local_deep_research/web/templates/pages/star_reviews.html b/src/local_deep_research/web/templates/pages/star_reviews.htmlindex 8518b04904..0fc878280e 100644--- a/src/local_deep_research/web/templates/pages/star_reviews.html+++ b/src/local_deep_research/web/templates/pages/star_reviews.html@@ -3,7 +3,6 @@{% block title %}Star Reviews Analytics{% endblock %}{% block extra_head %}-<script src="https://cdn.jsdelivr.net/npm/chart.js"></script><style>.star-reviews-container {max-width: 1200px;diff --git a/src/local_deep_research/web/templates/pages/subscriptions.html b/src/local_deep_research/web/templates/pages/subscriptions.htmlindex bd63d2e626..052ec93cc0 100644--- a/src/local_deep_research/web/templates/pages/subscriptions.html+++ b/src/local_deep_research/web/templates/pages/subscriptions.html@@ -4,8 +4,6 @@{% block title %}Manage News Subscriptions - LDR{% endblock %}{% block extra_head %}-<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">-<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/font/bootstrap-icons.css" integrity="sha384-EvBWSlnoFgZlXJvpzS+MAUEjvN7+gcCwH+qh7GRFOGgZO0PuwOFro7qPOJnLfe7l" crossorigin="anonymous"><link rel="stylesheet" href="{{ url_for('research.serve_static', path='css/subscriptions.css') }}"><style>/* Override Bootstrap defaults to ensure dark theme */@@ -163,10 +161,8 @@<!-- Modals removed - using dedicated form pages instead -->-{% endblock %}{% block page_scripts %}-<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous"></script><script src="{{ url_for('research.serve_static', path='js/pages/subscriptions.js') }}"></script>{% endblock %}diff --git a/src/local_deep_research/web/utils/vite_helper.py b/src/local_deep_research/web/utils/vite_helper.pynew file mode 100644index 0000000000..aefd0da854--- /dev/null+++ b/src/local_deep_research/web/utils/vite_helper.py@@ -0,0 +1,101 @@+"""+Vite integration helper for Flask+Handles development and production asset loading+"""++import json+from pathlib import Path+from markupsafe import Markup+++class ViteHelper:+ """Helper class for Vite integration with Flask"""++ def __init__(self, app=None):+ self.app = app+ self.manifest = None+ self.is_dev = False++ if app:+ self.init_app(app)++ def init_app(self, app):+ """Initialize the helper with Flask app"""+ self.app = app+ self.is_dev = app.debug or app.config.get("VITE_DEV_MODE", False)++ if not self.is_dev:+ # Load manifest in production+ self._load_manifest()++ # Register template functions+ app.jinja_env.globals["vite_asset"] = self.vite_asset+ app.jinja_env.globals["vite_hmr"] = self.vite_hmr++ def _load_manifest(self):+ """Load Vite manifest file"""+ static_dir = self.app.config.get("STATIC_DIR", "static")+ manifest_path = Path(static_dir) / "dist" / ".vite" / "manifest.json"++ if manifest_path.exists():+ with open(manifest_path, "r") as f:+ self.manifest = json.load(f)+ else:+ # Fallback if manifest doesn't exist yet+ self.manifest = {}++ def vite_hmr(self):+ """Return HMR client script for development"""+ if self.is_dev:+ return Markup(+ '<script type="module" src="http://localhost:5173/@vite/client"></script>'+ )+ return ""++ def vite_asset(self, entry_point="js/app.js"):+ """+ Return appropriate script tags for the entry point++ In development: Points to Vite dev server+ In production: Uses manifest to get hashed filenames+ """+ if self.is_dev:+ # Development mode - use Vite dev server+ return Markup(+ f'<script type="module" src="http://localhost:5173/{entry_point}"></script>'+ )++ # Production mode - use manifest+ if not self.manifest:+ # Fallback to CDN references if build hasn't run yet+ return self._fallback_assets()++ # Get the built file from manifest+ if entry_point in self.manifest:+ file_info = self.manifest[entry_point]+ file_path = f"/static/dist/{file_info['file']}"++ # Include CSS if present+ css_tags = ""+ if "css" in file_info:+ for css_file in file_info["css"]:+ css_tags += f'<link rel="stylesheet" href="/static/dist/{css_file}">\n'++ # Include the main JS file+ js_tag = f'<script type="module" src="{file_path}"></script>'++ return Markup(css_tags + js_tag)++ return self._fallback_assets()++ def _fallback_assets(self):+ """Fallback to existing script tags if build hasn't run"""+ # This will be replaced once npm build is run+ return Markup("""+<!-- Vite build not found - run 'npm run build' to generate production assets -->+<!-- Using existing static files as fallback -->+ """)+++# Create global instance+vite = ViteHelper()diff --git a/tests/accessibility_tests/test_accessibility.js b/tests/accessibility_tests/test_accessibility.jsindex e056ba7287..448dee63b9 100644--- a/tests/accessibility_tests/test_accessibility.js+++ b/tests/accessibility_tests/test_accessibility.js@@ -266,9 +266,9 @@ test.describe('Accessibility Compliance', () => {await page.goto('/research/');await page.waitForLoadState('networkidle');- // Inject axe-core for accessibility testing+ // Inject axe-core for accessibility testing (from node_modules)await page.addScriptTag({- url: 'https://unpkg.com/[email protected]/axe.min.js'+ path: require.resolve('axe-core/axe.min.js')});// Run accessibility scandiff --git a/vite.config.js b/vite.config.jsnew file mode 100644index 0000000000..04b47b8107--- /dev/null+++ b/vite.config.js@@ -0,0 +1,69 @@+import { defineConfig } from 'vite';+import { resolve } from 'path';++export default defineConfig({+ root: 'src/local_deep_research/web/static',+ base: '/static/',++ // Ensure Vite handles Font Awesome fonts correctly+ assetsInclude: ['**/*.woff', '**/*.woff2', '**/*.ttf', '**/*.eot'],++ build: {+ // Output directory relative to root+ outDir: 'dist',++ // Generate manifest for Flask integration+ manifest: true,++ // Single entry point that includes all dependencies+ rollupOptions: {+ input: {+ app: resolve(__dirname, 'src/local_deep_research/web/static/js/app.js'),+ },+ output: {+ // Consistent file naming+ entryFileNames: 'js/[name].[hash].js',+ chunkFileNames: 'js/[name].[hash].js',+ assetFileNames: (assetInfo) => {+ if (assetInfo.name.endsWith('.css')) {+ return 'css/[name].[hash][extname]';+ }+ if (/\.(woff2?|ttf|eot|svg)$/.test(assetInfo.name)) {+ return 'fonts/[name].[hash][extname]';+ }+ return 'assets/[name].[hash][extname]';+ }+ }+ },++ // Optimize chunks+ chunkSizeWarningLimit: 1000,+ },++ server: {+ // Development server settings+ port: 5173,+ strictPort: true,++ // Proxy API requests to Flask+ proxy: {+ '/api': {+ target: 'http://localhost:5000',+ changeOrigin: true,+ },+ '/socket.io': {+ target: 'http://localhost:5000',+ ws: true,+ changeOrigin: true,+ }+ }+ },++ resolve: {+ alias: {+ '@': resolve(__dirname, 'src/local_deep_research/web/static'),+ '@js': resolve(__dirname, 'src/local_deep_research/web/static/js'),+ '@css': resolve(__dirname, 'src/local_deep_research/web/static/css'),+ }+ }+});