A comprehensive analytics dashboard for Open WebUI that provides real-time insights into your AI assistant usage, user engagement, model performance, and tool utilization.
git clone https://github.com/your-username/open-webui-analytics.git
cd open-webui-analytics
npm install
npm run dev
The application will start in development mode:
If no database is configured, the application will automatically launch in setup mode. You'll see a configuration interface where you can:
The easiest setup if you have an existing Open WebUI installation:
/app/backend/data/webui.db
(Docker default)~/.local/share/open-webui/webui.db
(Linux default)./backend/data/webui.db
(Development)./webui.db
(Local file)~
for home directory)For production deployments or shared databases:
# Environment variable method
export DATABASE_URL="postgresql://username:password@localhost:5432/openwebui"
npm run server
Or use the web interface to configure:
Create a .env
file in the project root:
# Database Configuration
DATABASE_URL=sqlite:///path/to/webui.db
# or
DATABASE_URL=postgresql://user:password@host:port/database
# Server Configuration
PORT=3001
# Optional: Custom data directory
DATA_DIR=/path/to/data
src/
āāā components/ # Reusable UI components
ā āāā Overview.svelte # Dashboard overview
ā āāā ModelUsage.svelte # Model analytics
ā āāā ActivityChart.svelte # Activity visualization
ā āāā UserStats.svelte # User statistics
ā āāā ToolUsage.svelte # Tool analytics
ā āāā Setup.svelte # Database configuration
āāā lib/
ā āāā api.js # API client functions
āāā App.svelte # Main application
āāā main.js # Application entry point
server.js # Express server with database abstraction
āāā Database Detection # SQLite vs PostgreSQL
āāā Query Abstraction # Cross-database compatibility
āāā API Endpoints # RESTful analytics API
āāā Setup Routes # Configuration interface
āāā CORS & Security # Cross-origin and security headers
The analytics service reads from your existing Open WebUI database:
GET /api/stats/overview
- Dashboard summary statisticsGET /api/stats/models
- Model usage analyticsGET /api/stats/activity?days=30
- Activity metricsGET /api/stats/users
- User statisticsGET /api/stats/tools
- Tool usage analyticsGET /setup
- Setup mode detectionPOST /setup/configure
- Database configurationPOST /setup/test-sqlite
- SQLite path validationPOST /setup/restart
- Server restartFROM node:18-alpine
WORKDIR /app
COPY package*.json ./
RUN npm ci --only=production
COPY . .
RUN npm run build
EXPOSE 3001
CMD ["npm", "run", "server"]
# Production environment
NODE_ENV=production
DATABASE_URL=postgresql://user:pass@db:5432/openwebui
PORT=3001
# Build and serve
npm run build
npm run server
server {
listen 80;
server_name analytics.yourdomain.com;
location / {
proxy_pass http://localhost:3001;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
<VirtualHost *:80>
ServerName analytics.yourdomain.com
ProxyPreserveHost On
ProxyRequests Off
ProxyPass / http://localhost:3001/
ProxyPassReverse / http://localhost:3001/
</VirtualHost>
Complete stack with database:
version: '3.8'
services:
analytics:
build: .
ports:
- "3001:3001"
environment:
- DATABASE_URL=postgresql://analytics:password@postgres:5432/analytics
depends_on:
- postgres
postgres:
image: postgres:15
environment:
- POSTGRES_DB=analytics
- POSTGRES_USER=analytics
- POSTGRES_PASSWORD=password
volumes:
- postgres_data:/var/lib/postgresql/data
volumes:
postgres_data:
# Clone repository
git clone https://github.com/your-username/open-webui-analytics.git
cd open-webui-analytics
# Install dependencies
npm install
# Start development servers
npm run dev
npm run dev
- Start both frontend and backend in development modenpm run dev:client
- Frontend only (Vite dev server)npm run server
- Backend only (Node.js server)npm run build
- Build frontend for production# Check database file permissions
ls -la /path/to/webui.db
# Verify PostgreSQL connection
psql -h localhost -U username -d database -c "SELECT 1;"
# Find process using port 3001
lsof -i :3001
# Kill process
kill -9 <PID>
# Or use different port
PORT=3002 npm run server
.env
filewebui.db
from project root# Enable debug logging
DEBUG=* npm run server
# Backend only debug
NODE_ENV=development npm run server
# Check API endpoints
curl http://localhost:3001/api/stats/overview
We welcome contributions! Please see our Contributing Guidelines for details.
git checkout -b feature/amazing-feature
)git commit -m 'Add amazing feature'
)git push origin feature/amazing-feature
)This project is licensed under the MIT License - see the LICENSE file for details.
Built with ā¤ļø for the Open WebUI community