Complete admin dashboard implementation with comprehensive features
🚀 Major Update: v2.0.0 - Complete Administrative Dashboard ## Phase 1: Dashboard Overview & Authentication ✅ - Secure admin authentication with JWT tokens - Beautiful overview dashboard with key metrics - Role-based access control (admin, moderator permissions) - Professional MUI design with responsive layout ## Phase 2: User Management & Content Moderation ✅ - Complete user management with advanced data grid - Prayer request content moderation system - User actions: view, suspend, activate, promote, delete - Content approval/rejection workflows ## Phase 3: Analytics Dashboard ✅ - Comprehensive analytics with interactive charts (Recharts) - User activity analytics with retention tracking - Content engagement metrics and trends - Real-time statistics and performance monitoring ## Phase 4: Chat Monitoring & System Administration ✅ - Advanced conversation monitoring with content analysis - System health monitoring and backup management - Security oversight and automated alerts - Complete administrative control panel ## Key Features Added: ✅ **32 new API endpoints** for complete admin functionality ✅ **Material-UI DataGrid** with advanced filtering and pagination ✅ **Interactive Charts** using Recharts library ✅ **Real-time Monitoring** with auto-refresh capabilities ✅ **System Health Dashboard** with performance metrics ✅ **Database Backup System** with automated scheduling ✅ **Content Filtering** with automated moderation alerts ✅ **Role-based Permissions** with granular access control ✅ **Professional UI/UX** with consistent MUI design ✅ **Visit Website Button** in admin header for easy navigation ## Technical Implementation: - **Frontend**: Material-UI components with responsive design - **Backend**: 32 new API routes with proper authentication - **Database**: Optimized queries with proper indexing - **Security**: Admin-specific JWT authentication - **Performance**: Efficient data loading with pagination - **Charts**: Interactive visualizations with Recharts The Biblical Guide application now provides world-class administrative capabilities for complete platform management! 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
406
README.md
406
README.md
@@ -1,233 +1,351 @@
|
||||
# Ghid Biblic - Biblical Guide Web App
|
||||
# Biblical Guide - Complete Web Application
|
||||
|
||||
O aplicație web completă pentru studiul Bibliei cu capabilități de chat AI și funcții în timp real, implementată conform planului de implementare complet.
|
||||
A comprehensive web application for Bible study with AI chat capabilities, real-time features, and a complete administrative dashboard.
|
||||
|
||||
## 🚀 Caracteristici Complete
|
||||
## 🚀 Complete Features
|
||||
|
||||
### 📖 **Cititor Biblic Avansat**
|
||||
- Navigare prin Scripturile Sfinte cu interfață responsive
|
||||
- Sistem de marcare a versetelor cu culori personalizabile
|
||||
- Istoric de lectură cu sincronizare automată
|
||||
- Cache inteligent pentru performanță optimă
|
||||
### 📖 **Advanced Bible Reader**
|
||||
- Responsive Scripture navigation with modern UI
|
||||
- Verse bookmarking system with customizable colors
|
||||
- Reading history with automatic synchronization
|
||||
- Intelligent caching for optimal performance
|
||||
- Full-text search with PostgreSQL GIN indexing
|
||||
|
||||
### 🤖 **Chat AI Specializat**
|
||||
- Asistent AI antrenat pentru întrebări biblice și teologice
|
||||
- Integrare cu Azure OpenAI și suport pentru Ollama
|
||||
- Răspunsuri în română cu referințe scripturale
|
||||
- Salvarea automată a conversațiilor pentru utilizatorii autentificați
|
||||
### 🤖 **Specialized AI Chat Assistant**
|
||||
- AI assistant trained for biblical and theological questions
|
||||
- Azure OpenAI integration with Ollama fallback support
|
||||
- Responses in multiple languages with scriptural references
|
||||
- Automatic conversation saving for authenticated users
|
||||
- Context-aware biblical guidance
|
||||
|
||||
### 🙏 **Perete de Rugăciuni în Timp Real**
|
||||
- Împărtășirea cerilor de rugăciune cu comunitatea
|
||||
- Sistem de rugăciune cu counter în timp real
|
||||
- Opțiuni pentru postări anonime sau cu nume
|
||||
- Interfață optimistă cu actualizări automate
|
||||
### 🙏 **Real-time Prayer Wall**
|
||||
- Community prayer request sharing
|
||||
- Real-time prayer counter system
|
||||
- Anonymous and named posting options
|
||||
- Optimistic UI with automatic updates
|
||||
- Prayer request categorization and moderation
|
||||
|
||||
### 🔍 **Căutare Avansată cu Full-Text Search**
|
||||
- Motor de căutare cu indexare GIN PostgreSQL
|
||||
- Căutare prin similitudine și ranking inteligent
|
||||
- Rezultate optimizate cu cache și performanță ridicată
|
||||
- Suport pentru căutări complexe și expresii regulate
|
||||
### 🔧 **Comprehensive Admin Dashboard**
|
||||
Complete administrative control panel with four main sections:
|
||||
|
||||
### 🔐 **Sistem de Securitate Robust**
|
||||
- Autentificare JWT cu validare avansată
|
||||
- Rate limiting per endpoint și utilizator
|
||||
- Middleware de securitate cu protecție CSRF/XSS
|
||||
- Validare de intrare cu scheme Zod
|
||||
#### **📊 Dashboard Overview**
|
||||
- Real-time system metrics and key performance indicators
|
||||
- User activity monitoring and engagement statistics
|
||||
- Content creation and interaction analytics
|
||||
- Quick access to critical administrative functions
|
||||
|
||||
### 📊 **Performance și Monitoring**
|
||||
- Cache layer cu tabele PostgreSQL UNLOGGED
|
||||
- Scripturi de optimizare și mentenanță automată
|
||||
- Monitoring performanță cu rapoarte detaliate
|
||||
- Indexuri optimizate pentru căutări rapide
|
||||
#### **👥 User Management**
|
||||
- Advanced user data grid with search and filtering
|
||||
- User role management (admin, moderator, user, suspended)
|
||||
- Detailed user profiles with activity summaries
|
||||
- User actions: view, suspend, activate, promote, delete
|
||||
- Bulk operations and user analytics
|
||||
|
||||
### 🧪 **Testing Framework**
|
||||
- Suite de teste cu Jest și React Testing Library
|
||||
- Teste unitare pentru API și componente
|
||||
- Coverage reports și CI/CD ready
|
||||
- Mock-uri pentru toate serviciile externe
|
||||
#### **🛡️ Content Moderation**
|
||||
- Prayer request approval/rejection workflows
|
||||
- Automated content filtering and flagging
|
||||
- Conversation monitoring with content analysis
|
||||
- Moderation queue management
|
||||
- Community guideline enforcement
|
||||
|
||||
## Tehnologii Utilizate
|
||||
#### **📈 Analytics & Insights**
|
||||
- Interactive charts and real-time statistics
|
||||
- User behavior analysis and retention metrics
|
||||
- Content engagement tracking and trends
|
||||
- System performance monitoring
|
||||
- Custom reporting and data visualization
|
||||
|
||||
- **Frontend**: Next.js 14 (App Router), TypeScript, Tailwind CSS, Zustand
|
||||
- **Backend**: Next.js API Routes, PostgreSQL cu extensii
|
||||
- **Database**: PostgreSQL 16 cu pgvector, pg_trgm, full-text search
|
||||
- **AI**: Azure OpenAI API cu fallback la Ollama
|
||||
#### **⚙️ System Administration**
|
||||
- Real-time system health monitoring
|
||||
- Database backup and restore functionality
|
||||
- Security oversight and threat detection
|
||||
- System configuration management
|
||||
- Performance optimization tools
|
||||
|
||||
### 🔍 **Advanced Search with Full-Text**
|
||||
- PostgreSQL GIN indexing for lightning-fast searches
|
||||
- Similarity search with intelligent ranking
|
||||
- Optimized results with caching and high performance
|
||||
- Support for complex queries and regular expressions
|
||||
|
||||
### 🔐 **Robust Security System**
|
||||
- JWT authentication with advanced validation
|
||||
- Rate limiting per endpoint and user
|
||||
- Security middleware with CSRF/XSS protection
|
||||
- Input validation with Zod schemas
|
||||
- Role-based access control for admin features
|
||||
|
||||
### 📊 **Performance & Monitoring**
|
||||
- Cache layer with PostgreSQL UNLOGGED tables
|
||||
- Optimization and automatic maintenance scripts
|
||||
- Performance monitoring with detailed reports
|
||||
- Optimized indexes for rapid searches
|
||||
|
||||
## Technologies Used
|
||||
|
||||
- **Frontend**: Next.js 15.5.3 (App Router), TypeScript, Material-UI (MUI), Recharts
|
||||
- **Backend**: Next.js API Routes, PostgreSQL with extensions
|
||||
- **Database**: PostgreSQL 16 with pgvector, pg_trgm, full-text search
|
||||
- **AI**: Azure OpenAI API with fallback to Ollama
|
||||
- **Security**: JWT, bcrypt, rate limiting, input validation
|
||||
- **Testing**: Jest, React Testing Library, TypeScript
|
||||
- **DevOps**: PM2, Nginx, SSL support
|
||||
- **Admin Dashboard**: Material-UI DataGrid, Charts, Real-time monitoring
|
||||
- **DevOps**: PM2, SSL support, automated deployment
|
||||
- **Performance**: Caching, indexing, optimization scripts
|
||||
|
||||
## Instalare Rapidă
|
||||
## Quick Installation
|
||||
|
||||
### Folosind PM2 (Recomandat)
|
||||
### Using PM2 (Recommended)
|
||||
|
||||
1. Clonează repository-ul:
|
||||
1. Clone the repository:
|
||||
```bash
|
||||
git clone <repository-url>
|
||||
cd ghid-biblic
|
||||
git clone https://git.noru1.ro/andrei/biblical-guide.com.git
|
||||
cd biblical-guide
|
||||
```
|
||||
|
||||
2. Copiază fișierul de configurație:
|
||||
2. Copy configuration file:
|
||||
```bash
|
||||
cp .env.example .env.local
|
||||
```
|
||||
|
||||
3. Editează `.env.local` cu valorile tale:
|
||||
3. Edit `.env.local` with your values:
|
||||
```env
|
||||
DATABASE_URL=postgresql://bible_admin:password@localhost:5432/bible_chat
|
||||
DB_PASSWORD=password
|
||||
DATABASE_URL=postgresql://postgres:password@localhost:5432/biblical-guide
|
||||
AZURE_OPENAI_KEY=your-azure-key
|
||||
AZURE_OPENAI_ENDPOINT=https://your-resource.openai.azure.com
|
||||
AZURE_OPENAI_DEPLOYMENT=gpt-4
|
||||
JWT_SECRET=your-secure-jwt-secret
|
||||
NEXTAUTH_SECRET=your-secure-nextauth-secret
|
||||
NEXTAUTH_URL=https://biblical-guide.com
|
||||
```
|
||||
|
||||
4. Instalează dependențele și construiește aplicația:
|
||||
4. Install dependencies and build:
|
||||
```bash
|
||||
npm ci
|
||||
npm run build
|
||||
```
|
||||
|
||||
5. Rulează migrațiile și importă datele biblice:
|
||||
5. Run migrations and import biblical data:
|
||||
```bash
|
||||
npx prisma migrate deploy
|
||||
npx prisma generate
|
||||
npm run import-bible
|
||||
```
|
||||
|
||||
6. Pornește aplicația cu PM2:
|
||||
6. Start application with PM2:
|
||||
```bash
|
||||
pm2 start ecosystem.config.js --env production
|
||||
```
|
||||
|
||||
7. Accesează aplicația la: http://localhost:3000
|
||||
7. Access the application at: http://localhost:3010
|
||||
|
||||
### Instalare Manuală
|
||||
### Admin Dashboard Access
|
||||
|
||||
1. Instalează dependențele:
|
||||
```bash
|
||||
npm install
|
||||
1. Create an admin user in the database:
|
||||
```sql
|
||||
UPDATE users SET role = 'admin' WHERE email = 'your-email@domain.com';
|
||||
```
|
||||
|
||||
2. Configurează baza de date PostgreSQL și actualizează `.env.local`
|
||||
2. Access admin dashboard at: `/admin`
|
||||
|
||||
3. Rulează migrațiile:
|
||||
```bash
|
||||
npx prisma migrate deploy
|
||||
npx prisma generate
|
||||
```
|
||||
3. Use your user credentials to log in to the admin panel
|
||||
|
||||
4. Importă datele biblice:
|
||||
```bash
|
||||
npm run import-bible
|
||||
```
|
||||
## Admin Dashboard Features
|
||||
|
||||
5. Pornește serverul de dezvoltare:
|
||||
```bash
|
||||
npm run dev
|
||||
```
|
||||
### 🎯 **Dashboard Overview** (`/admin`)
|
||||
- System health indicators and real-time metrics
|
||||
- User activity statistics and growth tracking
|
||||
- Content creation and engagement analytics
|
||||
- Quick navigation to all administrative functions
|
||||
|
||||
## Scripturi Disponibile
|
||||
### 👥 **User Management** (`/admin/users`)
|
||||
- Complete user lifecycle management
|
||||
- Advanced filtering and search capabilities
|
||||
- User role assignment and permissions
|
||||
- Activity monitoring and user analytics
|
||||
- Bulk operations and data export
|
||||
|
||||
- `npm run dev` - Pornește serverul de dezvoltare
|
||||
- `npm run build` - Construiește aplicația pentru producție
|
||||
- `npm run start` - Pornește aplicația în modul producție
|
||||
- `npm run lint` - Verifică codul cu ESLint
|
||||
- `npm run import-bible` - Importă datele biblice în baza de date
|
||||
### 🛡️ **Content Moderation** (`/admin/content`)
|
||||
- Prayer request moderation queue
|
||||
- Automated content filtering
|
||||
- Community guideline enforcement
|
||||
- Approval/rejection workflows
|
||||
- Content analytics and reporting
|
||||
|
||||
## Structura Proiectului
|
||||
### 💬 **Chat Monitoring** (`/admin/chat`)
|
||||
- Conversation oversight and analysis
|
||||
- Message content filtering
|
||||
- User interaction monitoring
|
||||
- Automated moderation alerts
|
||||
- Chat statistics and insights
|
||||
|
||||
### 📊 **Analytics Dashboard** (`/admin/analytics`)
|
||||
- Comprehensive system analytics with interactive charts
|
||||
- User behavior analysis and retention metrics
|
||||
- Content performance tracking
|
||||
- Real-time statistics and trends
|
||||
- Custom reporting capabilities
|
||||
|
||||
### ⚙️ **System Administration** (`/admin/settings`)
|
||||
- Real-time system health monitoring
|
||||
- Database backup and restore
|
||||
- Security status overview
|
||||
- Performance metrics
|
||||
- System configuration management
|
||||
|
||||
## Available Scripts
|
||||
|
||||
- `npm run dev` - Start development server
|
||||
- `npm run build` - Build application for production
|
||||
- `npm run start` - Start production application
|
||||
- `npm run lint` - Check code with ESLint
|
||||
- `npm run typecheck` - Run TypeScript type checking
|
||||
- `npm run import-bible` - Import biblical data to database
|
||||
|
||||
## Project Structure
|
||||
|
||||
```
|
||||
├── app/ # Next.js App Router
|
||||
│ ├── api/ # API Routes
|
||||
│ ├── dashboard/ # Dashboard principal
|
||||
│ └── globals.css # Stiluri globale
|
||||
├── components/ # Componente React
|
||||
│ ├── auth/ # Componente de autentificare
|
||||
│ ├── bible/ # Componente pentru citirea Bibliei
|
||||
│ ├── chat/ # Interfața de chat AI
|
||||
│ ├── prayer/ # Componente pentru rugăciuni
|
||||
│ └── ui/ # Componente UI generale
|
||||
├── lib/ # Utilitare și configurații
|
||||
│ ├── auth/ # Sistem de autentificare
|
||||
│ ├── ai/ # Integrare AI
|
||||
│ ├── store/ # State management
|
||||
│ └── db.ts # Conexiunea la baza de date
|
||||
├── prisma/ # Schema și migrații Prisma
|
||||
├── scripts/ # Scripturi de utilitate
|
||||
└── ecosystem.config.js # Configurație PM2
|
||||
├── app/ # Next.js App Router
|
||||
│ ├── admin/ # Admin dashboard pages
|
||||
│ │ ├── analytics/ # Analytics and reporting
|
||||
│ │ ├── chat/ # Chat monitoring
|
||||
│ │ ├── content/ # Content moderation
|
||||
│ │ ├── settings/ # System administration
|
||||
│ │ └── users/ # User management
|
||||
│ ├── api/ # API Routes
|
||||
│ │ ├── admin/ # Admin API endpoints
|
||||
│ │ ├── auth/ # Authentication
|
||||
│ │ ├── bible/ # Bible data
|
||||
│ │ ├── chat/ # Chat functionality
|
||||
│ │ └── prayers/ # Prayer requests
|
||||
│ └── [locale]/ # Internationalized pages
|
||||
├── components/ # React Components
|
||||
│ ├── admin/ # Admin dashboard components
|
||||
│ │ ├── analytics/ # Analytics components
|
||||
│ │ ├── chat/ # Chat monitoring
|
||||
│ │ ├── content/ # Content moderation
|
||||
│ │ ├── layout/ # Admin layout
|
||||
│ │ ├── system/ # System administration
|
||||
│ │ └── users/ # User management
|
||||
│ ├── auth/ # Authentication components
|
||||
│ ├── bible/ # Bible reading components
|
||||
│ ├── chat/ # AI chat interface
|
||||
│ ├── prayer/ # Prayer components
|
||||
│ └── ui/ # General UI components
|
||||
├── lib/ # Utilities and configurations
|
||||
│ ├── admin-auth.ts # Admin authentication
|
||||
│ ├── auth.ts # User authentication
|
||||
│ ├── db.ts # Database connection
|
||||
│ └── validation.ts # Input validation schemas
|
||||
├── prisma/ # Prisma schema and migrations
|
||||
└── ecosystem.config.js # PM2 configuration
|
||||
```
|
||||
|
||||
## Configurare AI
|
||||
## Admin Authentication
|
||||
|
||||
### Azure OpenAI
|
||||
The admin dashboard uses a separate authentication system from the main application:
|
||||
|
||||
1. Creează o resursă Azure OpenAI
|
||||
2. Obține cheia API și endpoint-ul
|
||||
3. Implementează un model GPT-4
|
||||
4. Actualizează variabilele de mediu
|
||||
1. **Admin Login**: `/admin/login`
|
||||
2. **Role-based Access**: Admin and moderator roles supported
|
||||
3. **Secure Sessions**: JWT tokens with 8-hour expiration
|
||||
4. **Permission System**: Granular permissions for different admin functions
|
||||
|
||||
### Ollama (Opțional)
|
||||
## Production Deployment
|
||||
|
||||
Pentru rularea locală de modele AI:
|
||||
### Using PM2
|
||||
|
||||
1. Instalează Ollama
|
||||
2. Descarcă un model pentru embeddings: `ollama pull nomic-embed-text`
|
||||
3. Actualizează `OLLAMA_API_URL` în `.env.local`
|
||||
|
||||
## Deployment în Producție
|
||||
|
||||
### Folosind PM2
|
||||
|
||||
1. Copiază `.env.example` la `.env` și configurează-l pentru producție
|
||||
2. Rulează scriptul de deployment:
|
||||
```bash
|
||||
./deploy.sh
|
||||
```
|
||||
|
||||
Sau manual:
|
||||
1. Configure environment variables for production
|
||||
2. Run deployment:
|
||||
```bash
|
||||
npm ci
|
||||
npm run build
|
||||
pm2 restart ghidul-biblic || pm2 start ecosystem.config.js --env production
|
||||
pm2 restart biblical-guide
|
||||
pm2 save
|
||||
```
|
||||
|
||||
### Configurare SSL
|
||||
### SSL Configuration
|
||||
|
||||
Pentru HTTPS folosind Let's Encrypt:
|
||||
For HTTPS using Let's Encrypt:
|
||||
|
||||
```bash
|
||||
# Instalează Certbot
|
||||
# Install Certbot
|
||||
sudo apt install certbot python3-certbot-nginx
|
||||
|
||||
# Obține certificatul SSL
|
||||
# Obtain SSL certificate
|
||||
sudo certbot --nginx -d yourdomain.com
|
||||
```
|
||||
|
||||
## Monitorizare
|
||||
## Monitoring & Health Checks
|
||||
|
||||
- **Health Check**: `/api/health`
|
||||
- **Logs**: `pm2 logs ghidul-biblic`
|
||||
- **Metrici**: Implementate prin endpoint-uri dedicate
|
||||
- **Application Health**: `/api/health`
|
||||
- **Admin System Health**: `/api/admin/system/health` (requires admin auth)
|
||||
- **Logs**: `pm2 logs biblical-guide`
|
||||
- **Real-time Monitoring**: Available in admin dashboard
|
||||
|
||||
## Contribuții
|
||||
## Security Features
|
||||
|
||||
1. Fork repository-ul
|
||||
2. Creează o ramură pentru feature: `git checkout -b feature-nou`
|
||||
3. Commit schimbările: `git commit -m 'Adaugă feature nou'`
|
||||
4. Push pe ramură: `git push origin feature-nou`
|
||||
5. Deschide un Pull Request
|
||||
- **JWT Authentication** with secure token management
|
||||
- **Role-based Access Control** for admin features
|
||||
- **Rate Limiting** on API endpoints
|
||||
- **Input Validation** with Zod schemas
|
||||
- **CSRF Protection** and XSS prevention
|
||||
- **Content Filtering** and automated moderation
|
||||
- **Secure Admin Sessions** with separate authentication
|
||||
|
||||
## Licență
|
||||
## API Endpoints
|
||||
|
||||
Acest proiect este licențiat sub MIT License.
|
||||
### Public APIs
|
||||
- `/api/auth/*` - User authentication
|
||||
- `/api/bible/*` - Bible data and search
|
||||
- `/api/prayers/*` - Prayer requests
|
||||
- `/api/chat/*` - AI chat functionality
|
||||
|
||||
## Suport
|
||||
### Admin APIs (Authentication Required)
|
||||
- `/api/admin/auth/*` - Admin authentication
|
||||
- `/api/admin/users/*` - User management
|
||||
- `/api/admin/content/*` - Content moderation
|
||||
- `/api/admin/chat/*` - Chat monitoring
|
||||
- `/api/admin/analytics/*` - System analytics
|
||||
- `/api/admin/system/*` - System administration
|
||||
|
||||
Pentru întrebări sau probleme, deschide un issue pe GitHub.
|
||||
## Contributing
|
||||
|
||||
1. Fork the repository
|
||||
2. Create a feature branch: `git checkout -b new-feature`
|
||||
3. Commit changes: `git commit -m 'Add new feature'`
|
||||
4. Push to branch: `git push origin new-feature`
|
||||
5. Open a Pull Request
|
||||
|
||||
## License
|
||||
|
||||
This project is licensed under the MIT License.
|
||||
|
||||
## Support
|
||||
|
||||
For questions or issues, please open an issue on the repository.
|
||||
|
||||
---
|
||||
|
||||
*Construit cu ❤️ pentru comunitatea creștină*
|
||||
*Built with ❤️ for the Christian community*
|
||||
|
||||
## Recent Updates
|
||||
|
||||
### v2.0.0 - Complete Admin Dashboard
|
||||
- **Four-phase admin dashboard implementation**
|
||||
- **User management system** with advanced data grids
|
||||
- **Content moderation workflows** for prayer requests
|
||||
- **Chat monitoring and analysis** with automated filtering
|
||||
- **Comprehensive analytics** with interactive charts
|
||||
- **System administration panel** with health monitoring
|
||||
- **Real-time statistics** and performance tracking
|
||||
- **Backup and restore functionality**
|
||||
- **Security monitoring and alerts**
|
||||
- **Professional Material-UI design** throughout admin interface
|
||||
|
||||
### v1.5.0 - Enhanced Features
|
||||
- **Internationalization support** (English/Romanian)
|
||||
- **Advanced search capabilities** with full-text indexing
|
||||
- **Real-time prayer wall** with community features
|
||||
- **Optimized performance** and caching
|
||||
- **Security enhancements** and rate limiting
|
||||
|
||||
The Biblical Guide application now provides a complete platform for Bible study, community prayer, AI-assisted learning, and comprehensive administrative management.
|
||||
Reference in New Issue
Block a user