🎉 Complete AI-Enhanced University Portal - Ready for Production

 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!
This commit is contained in:
Krikorios
2025-07-20 08:26:25 +04:00
parent 868c9b252c
commit aa459f4bd6
159 changed files with 25019 additions and 16607 deletions
+154 -113
View File
@@ -1,41 +1,41 @@
# UTAS Oman University Portal
# University Portal - AI-Enhanced Multi-Tenant Platform
A modern, bilingual (Arabic/English) university portal for the University of Tasmania's campus in Muscat, Sultanate of Oman. Features an AI-powered chatbot using OpenRouter API for intelligent student assistance.
A modern, AI-powered university portal built with Next.js 15, React 19, and Prisma. Features advanced AI integration with conversation memory, university-specific knowledge bases, and multi-tenant architecture.
## 🌟 Features
## 🚀 Features
### 🤖 AI-Powered Chatbot
- **Real AI**: Uses OpenRouter API with Meta LLaMA model or Ollama local models
- **Bilingual Support**: Automatically detects and responds in Arabic or English
- **UTAS Oman Context**: Specialized knowledge about campus, programs, and admissions
- **Personalized Responses**: Tailors answers based on user authentication and role
- **No Mock Data**: All responses generated by real AI
### Core Features
- **Multi-University Support**: White-label solution for multiple universities
- **AI-Powered Chat**: Intelligent chatbot with conversation memory
- **Knowledge Base Management**: University-specific Q&A system
- **Modern UI/UX**: Beautiful, responsive design with Tailwind CSS
- **Multi-Language Support**: English and Arabic support
- **Role-Based Access**: Student, Staff, Admin, and Super Admin roles
### 🎓 Academic Programs
- Comprehensive undergraduate and postgraduate program listings
- UTAS Oman-specific courses aligned with Oman Vision 2040
- Detailed program information, requirements, and career outcomes
- Search and filtering capabilities
### AI Integration
- **Conversation Memory**: AI remembers entire conversations
- **University-Specific Knowledge**: Custom Q&A for each university
- **Personalized Responses**: Context-aware based on user role and profile
- **Ollama Integration**: Local AI models with fallback to cloud APIs
- **Real-time Chat**: Professional chat interface with loading states
### 🌐 Bilingual Interface
- Arabic and English language support
- Cultural appropriateness for Omani students
- RTL (Right-to-Left) text support for Arabic
### Technical Features
- **Next.js 15**: Latest App Router with Turbopack
- **React 19**: Latest React features and optimizations
- **Prisma ORM**: Type-safe database operations
- **SQLite Database**: Lightweight, file-based database
- **TypeScript**: Full type safety throughout
- **Tailwind CSS**: Utility-first styling
- **ESLint**: Code quality and consistency
### 📱 Modern Design
- Responsive design for all devices
- Clean, professional interface
- UTAS Oman branding and colors
- Accessibility features
## 🚀 Getting Started
## 🛠️ Installation
### Prerequisites
- Node.js 18+
- OpenRouter API key
### Installation
- Node.js 18+
- npm or yarn
- Ollama (for local AI models)
### Setup
1. **Clone the repository**
```bash
git clone <repository-url>
@@ -47,129 +47,170 @@ A modern, bilingual (Arabic/English) university portal for the University of Tas
npm install
```
3. **Set up environment variables**
3. **Set up the database**
```bash
cp .env.example .env.local
```
Add your OpenRouter API key to `.env.local`:
```
OPENROUTER_API_KEY=your_openrouter_api_key_here
npx prisma generate
npx prisma db push
```
4. **Run the development server**
4. **Seed the database**
```bash
npm run seed
npm run seed:knowledge-base
```
5. **Start the development server**
```bash
npm run dev
```
5. **Open your browser**
6. **Open your browser**
Navigate to [http://localhost:3000](http://localhost:3000)
## 🤖 Chatbot Setup
## 🗄️ Database Setup
### Configuration
The project uses SQLite with Prisma ORM. Key models include:
1. Create a `.env.local` file in the project root with the following variables:
- **University**: Multi-tenant university configurations
- **User**: User accounts with role-based access
- **AcademicProgram**: University programs and courses
- **AIKnowledgeBase**: University-specific Q&A for AI
- **ChatSession/ChatMessage**: Conversation memory system
- **DomainConfig**: Multi-domain support for universities
```env
# OpenRouter API Key (for LLM access)
OPENROUTER_API_KEY=sk-your-key-here
# Ollama configuration (for local model fallback)
OLLAMA_URL=http://localhost:11434
MODEL_COMMAND_R7B=command-r7b-arabic
## 🤖 AI Configuration
### Local AI (Ollama)
1. **Install Ollama**: [https://ollama.ai](https://ollama.ai)
2. **Start Ollama service**:
```bash
ollama serve
```
3. **Pull a model**:
```bash
ollama pull llama2
```
2. To use the Ollama fallback:
- Install Ollama from [https://ollama.ai/](https://ollama.ai/)
- Pull the Arabic-capable model: `ollama pull command-r7b-arabic`
- Start the Ollama server locally: `ollama serve`
3. The chatbot automatically:
- Tries OpenRouter first if API key is available
- Falls back to Ollama if OpenRouter key is missing
- Detects language (Arabic/English) and responds accordingly
- Personalizes responses based on user authentication status
### Environment Variables
Create a `.env.local` file:
```env
# Database
DATABASE_URL="file:./dev.db"
### Testing the Chatbot
# AI Configuration
OLLAMA_HOST="http://localhost:11434"
OPENROUTER_API_KEY="your-api-key" # Optional fallback
Run the built-in chatbot tests:
```bash
npm run test:chat
# Authentication
NEXTAUTH_SECRET="your-secret-key"
NEXTAUTH_URL="http://localhost:3000"
```
Or run the integration tests:
## 📁 Project Structure
```bash
npm run test
```
university-portal/
├── src/
│ ├── app/ # Next.js App Router
│ │ ├── api/ # API routes
│ │ │ ├── chat/ # AI chat endpoints
│ │ │ └── knowledge-base/ # Knowledge base management
│ │ ├── admin/ # Admin dashboard
│ │ └── ... # Public pages
│ ├── components/ # React components
│ │ ├── Chat/ # AI chat components
│ │ ├── Navigation/ # Navigation components
│ │ └── ... # Other components
│ └── lib/ # Utility libraries
├── prisma/ # Database schema and migrations
├── public/ # Static assets
├── docs/ # Documentation
└── scripts/ # Utility scripts
```
### Personalization Features
## 🎯 Key Features in Detail
The chatbot provides different responses based on authentication:
### AI Chat System
- **Conversation Memory**: Stores chat history in database
- **University Context**: Uses university-specific knowledge base
- **User Personalization**: Adapts responses based on user role
- **Real-time Interface**: Professional chat UI with typing indicators
- **Anonymous Users**: Public information only (courses, admissions, etc.)
- **Authenticated Students**: Personalized responses with student profile data
- **Faculty/Staff**: More detailed institutional information
- **Administrators**: Full access to university systems information
### Knowledge Base Management
- **Admin Interface**: Full CRUD operations for Q&A items
- **Bilingual Support**: English and Arabic content
- **Priority System**: Important items appear first in AI responses
- **Active/Inactive Toggle**: Control which items are used by AI
## 🛠️ Technology Stack
### Multi-University Support
- **White-Label**: Each university gets its own branded experience
- **Domain Management**: Custom domains and subdomains
- **Content Isolation**: University-specific content and assets
- **Branch Management**: Multiple campuses per university
- **Framework**: Next.js 14+ with React 19
- **Styling**: Tailwind CSS
- **TypeScript**: Full type safety
- **AI Integration**: OpenRouter API
- **Database**: Prisma (for future enhancements)
## 🧪 Testing
## 🎯 AI Chatbot Features
### Manual Testing
1. **AI Chat**: Test conversation memory and knowledge base integration
2. **Knowledge Base**: Add/edit/delete Q&A items in admin panel
3. **Multi-University**: Test different university contexts
4. **Responsive Design**: Test on mobile and desktop
The AI chatbot is the centerpiece of this portal:
### API Testing
```bash
# Test AI chat
curl -X POST http://localhost:3000/api/chat/ollama \
-H "Content-Type: application/json" \
-d '{"message": "What are admission requirements?", "universitySlug": "default-university"}'
- **Language Detection**: Automatically detects Arabic or English input
- **Contextual Responses**: Uses UTAS Oman knowledge base for relevant information
- **OpenRouter Integration**: Powered by Meta LLaMA 3.1 8B model
- **Conversation Memory**: Maintains conversation history for context
- **Error Handling**: Graceful fallbacks when API is unavailable
# Test knowledge base
curl http://localhost:3000/api/knowledge-base
```
### Testing the Chatbot
## 🚀 Deployment
Try these sample queries:
### Vercel (Recommended)
1. **Connect repository** to Vercel
2. **Set environment variables** in Vercel dashboard
3. **Deploy automatically** on push to main branch
**English:**
- "Tell me about MBA programs"
- "What are the admission requirements?"
- "How can I apply for scholarships?"
### Other Platforms
- **Netlify**: Compatible with Next.js
- **Railway**: Good for full-stack applications
- **DigitalOcean App Platform**: Scalable deployment
**Arabic:**
- "أخبرني عن برامج الماجستير"
- "ما هي متطلبات القبول؟"
- "كيف يمكنني التقدم للحصول على منح دراسية؟"
## 📚 Documentation
## 🏫 About UTAS Oman
This portal represents the University of Tasmania's campus in Muscat, Sultanate of Oman:
- **Location**: Knowledge Oasis Muscat
- **Programs**: Aligned with Oman Vision 2040
- **Quality**: Australian education standards
- **Local Relevance**: Designed for Omani students and industry needs
## 📞 Contact Information
- **Phone**: +968 2414 3555
- **Email**: admissions@utas.edu.om
- **Address**: Knowledge Oasis Muscat, Sultanate of Oman
- [AI Conversation Memory Guide](docs/AI_CONVERSATION_MEMORY_GUIDE.md)
- [AI Enhancement Summary](docs/AI_ENHANCEMENT_SUMMARY.md)
- [Developer Guide](docs/DEVELOPER_GUIDE.md)
- [User Guide](docs/USER_GUIDE.md)
## 🤝 Contributing
This is a demo project showcasing AI-enhanced university portal capabilities. For improvements or suggestions, please open an issue.
1. **Fork the repository**
2. **Create a feature branch**: `git checkout -b feature/amazing-feature`
3. **Commit your changes**: `git commit -m 'Add amazing feature'`
4. **Push to the branch**: `git push origin feature/amazing-feature`
5. **Open a Pull Request**
## 📄 License
This project is for demonstration purposes.
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
## 🆘 Support
- **Issues**: Create an issue on GitHub
- **Documentation**: Check the `/docs` folder
- **AI Configuration**: See AI setup guide in documentation
## 🎉 Acknowledgments
- **Next.js Team**: For the amazing framework
- **Prisma Team**: For the excellent ORM
- **Tailwind CSS**: For the utility-first CSS framework
- **Ollama Team**: For local AI model support
---
**Built with ❤️ for UTAS Oman students and the future of education in Oman.**
**Built with ❤️ for modern university portals**