# 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 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**