ideas-generator/server/models/User.js
DJP 77da1f44f0 Add comprehensive admin dashboard with analytics, full agent management, and complete system improvements
## Major Features Added:
- Complete admin dashboard with user, agent, conversation, and usage management
- Real-time usage analytics with interactive Chart.js visualizations
- Advanced trend analysis with line charts and bar graphs
- CSV export functionality for usage reports with date/user/agent filtering
- Full CRUD operations for agent management including system prompts and starter messages

## UI/UX Improvements:
- Professional top navigation bar with admin access and logout functionality
- Moved admin link from homepage to navigation for better UX
- Reduced all font sizes by 20% for better formatting consistency
- Changed color scheme from blue to orange (#e6a335) throughout application
- Fixed conversation double-click bug in chat interface
- Added separate starter message field distinct from system instructions

## Backend Enhancements:
- Added analytics API endpoints (/api/analytics/usage, /api/analytics/stats, /api/analytics/trends)
- Enhanced assistant API with admin-level data access and full CRUD operations
- Implemented starterMessage database field with automatic migration and data extraction
- Added comprehensive usage tracking and trend analysis capabilities
- Imported 34 additional agents from CSV (total: 53 agents)

## Technical Architecture:
- Integrated Chart.js with Vue.js for professional data visualization
- Implemented proper chart cleanup to prevent memory leaks
- Added comprehensive error handling and fallback states
- Enhanced API service layer with dedicated analytics methods
- Implemented role-based authentication and admin route protection

## Database Improvements:
- Added starterMessage field to Assistant model with automatic data migration
- Enhanced seed script with proper agent categorization and data cleanup
- Improved assistant API responses to include all necessary admin fields
- Implemented proper foreign key relationships for analytics queries

🚀 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-03 14:41:32 -04:00

43 lines
No EOL
889 B
JavaScript

const { DataTypes } = require('sequelize');
const { sequelize } = require('../config/database');
const User = sequelize.define('User', {
id: {
type: DataTypes.UUID,
defaultValue: DataTypes.UUIDV4,
primaryKey: true,
},
email: {
type: DataTypes.STRING,
allowNull: false,
unique: true,
validate: {
isEmail: true,
},
},
name: {
type: DataTypes.STRING,
allowNull: false,
},
preferences: {
type: DataTypes.JSONB,
defaultValue: {
theme: 'light',
notifications: true,
defaultAssistant: 'creator-bot-push-the-boundaries-of-technology',
},
},
isActive: {
type: DataTypes.BOOLEAN,
defaultValue: true,
},
}, {
tableName: 'users',
timestamps: true,
indexes: [
{ fields: ['email'] },
{ fields: ['isActive'] },
],
});
module.exports = User;