✨ Major Features Added: - AI Chat with conversation memory and university-specific knowledge base - Multi-tenant university support with white-label capabilities - Professional admin interface for knowledge base management - Advanced database schema with Prisma ORM - Comprehensive documentation and guides - Modern Next.js 15 + React 19 architecture - Bilingual support (English/Arabic) - Role-based access control - Real-time chat interface with loading states 🔧 Technical Improvements: - Fixed all linter errors and TypeScript issues - Cleaned up codebase and removed legacy files - Added comprehensive .gitignore - Updated README with detailed setup instructions - Optimized database schema and migrations - Enhanced error handling and user experience 📚 Documentation: - AI Conversation Memory Guide - AI Enhancement Summary - Developer Guide - User Guide - Complete setup and deployment instructions 🚀 Ready for GitHub deployment and production use!
419 lines
8.5 KiB
Markdown
419 lines
8.5 KiB
Markdown
# University Portal - Production Platform
|
|
|
|
A comprehensive, production-ready university portal platform with authentication, course management, and AI integration.
|
|
|
|
## 🚀 Features
|
|
|
|
### Core Platform
|
|
- **Multi-tenant Architecture**: Support for multiple universities
|
|
- **Authentication System**: Secure login/registration with JWT tokens
|
|
- **Role-based Access**: Student, Staff, Admin, and Super Admin roles
|
|
- **Database Management**: Prisma ORM with SQLite/PostgreSQL support
|
|
- **Responsive Design**: Modern UI with Tailwind CSS
|
|
|
|
### Academic Management
|
|
- **Programs & Majors**: Structured academic programs with course relationships
|
|
- **Course Management**: Detailed course information with prerequisites
|
|
- **Student Dashboard**: Personalized student experience with enrollment tracking
|
|
- **Admissions System**: Streamlined application process
|
|
- **Scholarship Management**: Scholarship listings and applications
|
|
|
|
### AI Integration
|
|
- **Ollama AI Chat**: Local AI assistant for university information
|
|
- **Knowledge Base**: University-specific AI responses
|
|
- **Pre-login Support**: AI assistance available before authentication
|
|
|
|
### Production Features
|
|
- **Environment Configuration**: Flexible environment setup
|
|
- **Database Migrations**: Automated schema management
|
|
- **Process Management**: PM2 integration for production
|
|
- **Nginx Configuration**: Reverse proxy setup
|
|
- **SSL Support**: Let's Encrypt integration
|
|
- **Backup System**: Automated database backups
|
|
- **Monitoring**: Log management and health checks
|
|
|
|
## 📋 Prerequisites
|
|
|
|
- Node.js 18+
|
|
- npm or yarn
|
|
- Git
|
|
- (Optional) PM2 for process management
|
|
- (Optional) Nginx for reverse proxy
|
|
- (Optional) Ollama for AI features
|
|
|
|
## 🛠️ Installation
|
|
|
|
### 1. Clone and Setup
|
|
|
|
```bash
|
|
git clone <repository-url>
|
|
cd university-portal
|
|
npm install
|
|
```
|
|
|
|
### 2. Environment Configuration
|
|
|
|
Create `.env.local` file:
|
|
|
|
```env
|
|
# Database
|
|
DATABASE_URL="file:./dev.db"
|
|
|
|
# Authentication
|
|
JWT_SECRET="your-super-secret-jwt-key"
|
|
|
|
# Ollama AI Configuration
|
|
OLLAMA_HOST="http://localhost:11434"
|
|
OLLAMA_MODEL="llama2"
|
|
|
|
# Application
|
|
NODE_ENV="development"
|
|
NEXT_PUBLIC_APP_URL="http://localhost:3000"
|
|
```
|
|
|
|
### 3. Database Setup
|
|
|
|
```bash
|
|
# Generate Prisma client
|
|
npx prisma generate
|
|
|
|
# Run migrations
|
|
npx prisma migrate dev
|
|
|
|
# Seed database with sample data
|
|
npx prisma db seed
|
|
```
|
|
|
|
### 4. Start Development Server
|
|
|
|
```bash
|
|
npm run dev
|
|
```
|
|
|
|
Access the application at: http://localhost:3000
|
|
|
|
## 🚀 Production Deployment
|
|
|
|
### Automated Deployment
|
|
|
|
Use the provided deployment script:
|
|
|
|
```bash
|
|
chmod +x scripts/deploy-production.sh
|
|
./scripts/deploy-production.sh
|
|
```
|
|
|
|
### Manual Deployment
|
|
|
|
1. **Build the Application**
|
|
```bash
|
|
npm ci --only=production
|
|
npm run build
|
|
```
|
|
|
|
2. **Database Setup**
|
|
```bash
|
|
npx prisma migrate deploy
|
|
npx prisma generate
|
|
```
|
|
|
|
3. **Process Management with PM2**
|
|
```bash
|
|
npm install -g pm2
|
|
pm2 start ecosystem.config.js
|
|
pm2 save
|
|
pm2 startup
|
|
```
|
|
|
|
4. **Nginx Configuration**
|
|
```bash
|
|
sudo cp nginx.conf /etc/nginx/sites-available/university-portal
|
|
sudo ln -s /etc/nginx/sites-available/university-portal /etc/nginx/sites-enabled/
|
|
sudo nginx -t
|
|
sudo systemctl reload nginx
|
|
```
|
|
|
|
5. **SSL Certificate**
|
|
```bash
|
|
sudo certbot --nginx -d your-domain.com
|
|
```
|
|
|
|
## 🗄️ Database Schema
|
|
|
|
### Core Models
|
|
|
|
- **University**: Multi-tenant university configuration
|
|
- **User**: Authentication and user management
|
|
- **AcademicProgram**: Majors and degree programs
|
|
- **Course**: Individual courses with prerequisites
|
|
- **Enrollment**: Student course enrollments
|
|
- **UniversityContent**: Dynamic content management
|
|
|
|
### Relationships
|
|
|
|
```
|
|
University (1) ←→ (N) AcademicProgram
|
|
University (1) ←→ (N) User
|
|
University (1) ←→ (N) Course
|
|
AcademicProgram (1) ←→ (N) Course
|
|
User (1) ←→ (N) Enrollment
|
|
Course (1) ←→ (N) Enrollment
|
|
```
|
|
|
|
## 🔐 Authentication System
|
|
|
|
### User Roles
|
|
|
|
- **STUDENT**: Access to courses, dashboard, and student services
|
|
- **STAFF**: Faculty and administrative access
|
|
- **ADMIN**: University-level administration
|
|
- **SUPER_ADMIN**: System-wide administration
|
|
|
|
### API Endpoints
|
|
|
|
- `POST /api/auth/login` - User login
|
|
- `POST /api/auth/register` - User registration
|
|
- `POST /api/auth/logout` - User logout
|
|
- `GET /api/auth/me` - Get current user
|
|
|
|
### Security Features
|
|
|
|
- JWT token-based authentication
|
|
- Password hashing with bcrypt
|
|
- Session management
|
|
- Role-based access control
|
|
- CSRF protection
|
|
|
|
## 🎓 Academic Structure
|
|
|
|
### Programs (Majors)
|
|
- Undergraduate, Postgraduate, and PhD levels
|
|
- Duration and credit requirements
|
|
- Entry requirements and fees
|
|
- Campus locations
|
|
|
|
### Courses
|
|
- Course codes and descriptions
|
|
- Credit hours and semesters
|
|
- Prerequisites and requirements
|
|
- Program associations
|
|
|
|
### Student Experience
|
|
- Personalized dashboard
|
|
- Course enrollment tracking
|
|
- Academic progress monitoring
|
|
- GPA calculation
|
|
|
|
## 🤖 AI Integration
|
|
|
|
### Ollama Setup
|
|
|
|
1. **Install Ollama**
|
|
```bash
|
|
curl -fsSL https://ollama.ai/install.sh | sh
|
|
```
|
|
|
|
2. **Start Ollama Service**
|
|
```bash
|
|
ollama serve
|
|
```
|
|
|
|
3. **Pull AI Model**
|
|
```bash
|
|
ollama pull llama2
|
|
```
|
|
|
|
### AI Features
|
|
|
|
- **Pre-login Chat**: AI assistance before authentication
|
|
- **University Context**: Institution-specific responses
|
|
- **Knowledge Base**: Dynamic Q&A system
|
|
- **Multi-language Support**: Arabic and English
|
|
|
|
## 📊 API Documentation
|
|
|
|
### Core Endpoints
|
|
|
|
#### Authentication
|
|
```http
|
|
POST /api/auth/login
|
|
Content-Type: application/json
|
|
|
|
{
|
|
"email": "user@university.edu",
|
|
"password": "password123"
|
|
}
|
|
```
|
|
|
|
#### Programs
|
|
```http
|
|
GET /api/programs
|
|
GET /api/programs/[id]
|
|
```
|
|
|
|
#### Courses
|
|
```http
|
|
GET /api/courses
|
|
GET /api/courses/[id]
|
|
```
|
|
|
|
#### AI Chat
|
|
```http
|
|
POST /api/chat/ollama
|
|
Content-Type: application/json
|
|
|
|
{
|
|
"message": "What programs do you offer?",
|
|
"context": "university_info"
|
|
}
|
|
```
|
|
|
|
## 🔧 Maintenance
|
|
|
|
### Database Backups
|
|
```bash
|
|
./maintenance.sh backup
|
|
```
|
|
|
|
### Application Updates
|
|
```bash
|
|
./maintenance.sh update
|
|
```
|
|
|
|
### Log Monitoring
|
|
```bash
|
|
./maintenance.sh logs
|
|
```
|
|
|
|
### Application Restart
|
|
```bash
|
|
./maintenance.sh restart
|
|
```
|
|
|
|
## 📈 Performance Optimization
|
|
|
|
### Database
|
|
- Indexed queries for fast retrieval
|
|
- Optimized relationships
|
|
- Connection pooling
|
|
|
|
### Frontend
|
|
- Next.js 14 with App Router
|
|
- Static generation where possible
|
|
- Image optimization
|
|
- Code splitting
|
|
|
|
### Caching
|
|
- Static asset caching
|
|
- API response caching
|
|
- Database query caching
|
|
|
|
## 🔒 Security Considerations
|
|
|
|
### Data Protection
|
|
- Input validation and sanitization
|
|
- SQL injection prevention
|
|
- XSS protection
|
|
- CSRF tokens
|
|
|
|
### Authentication
|
|
- Secure password hashing
|
|
- JWT token expiration
|
|
- Session management
|
|
- Rate limiting
|
|
|
|
### Infrastructure
|
|
- HTTPS enforcement
|
|
- Security headers
|
|
- Environment variable protection
|
|
- Regular security updates
|
|
|
|
## 🧪 Testing
|
|
|
|
### Unit Tests
|
|
```bash
|
|
npm run test
|
|
```
|
|
|
|
### Integration Tests
|
|
```bash
|
|
npm run test:integration
|
|
```
|
|
|
|
### E2E Tests
|
|
```bash
|
|
npm run test:e2e
|
|
```
|
|
|
|
## 📝 Environment Variables
|
|
|
|
| Variable | Description | Default |
|
|
|----------|-------------|---------|
|
|
| `DATABASE_URL` | Database connection string | `file:./dev.db` |
|
|
| `JWT_SECRET` | JWT signing secret | Required |
|
|
| `OLLAMA_HOST` | Ollama AI service URL | `http://localhost:11434` |
|
|
| `OLLAMA_MODEL` | AI model name | `llama2` |
|
|
| `NODE_ENV` | Environment mode | `development` |
|
|
| `NEXT_PUBLIC_APP_URL` | Public application URL | `http://localhost:3000` |
|
|
|
|
## 🐛 Troubleshooting
|
|
|
|
### Common Issues
|
|
|
|
1. **Database Connection**
|
|
```bash
|
|
npx prisma db push
|
|
npx prisma generate
|
|
```
|
|
|
|
2. **Authentication Issues**
|
|
- Check JWT_SECRET is set
|
|
- Verify database migrations
|
|
- Clear browser cookies
|
|
|
|
3. **AI Chat Not Working**
|
|
- Ensure Ollama is running
|
|
- Check OLLAMA_HOST configuration
|
|
- Verify model is downloaded
|
|
|
|
4. **Build Errors**
|
|
```bash
|
|
rm -rf .next node_modules
|
|
npm install
|
|
npm run build
|
|
```
|
|
|
|
## 📞 Support
|
|
|
|
For technical support and questions:
|
|
|
|
- **Documentation**: Check this README and inline code comments
|
|
- **Issues**: Create GitHub issues for bugs and feature requests
|
|
- **Discussions**: Use GitHub Discussions for general questions
|
|
|
|
## 📄 License
|
|
|
|
This project is licensed under the MIT License - see the LICENSE file for details.
|
|
|
|
## 🤝 Contributing
|
|
|
|
1. Fork the repository
|
|
2. Create a feature branch
|
|
3. Make your changes
|
|
4. Add tests if applicable
|
|
5. Submit a pull request
|
|
|
|
## 🎯 Roadmap
|
|
|
|
- [ ] Advanced analytics dashboard
|
|
- [ ] Mobile application
|
|
- [ ] Payment integration
|
|
- [ ] Video conferencing
|
|
- [ ] Advanced AI features
|
|
- [ ] Multi-language support
|
|
- [ ] Advanced reporting
|
|
- [ ] Integration APIs
|
|
|
|
---
|
|
|
|
**Built with ❤️ for modern education** |