✨ 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!
242 lines
8.4 KiB
TypeScript
242 lines
8.4 KiB
TypeScript
import { PrismaClient } from '@prisma/client';
|
|
import { hashPassword } from '../src/lib/auth';
|
|
|
|
const prisma = new PrismaClient();
|
|
|
|
async function main() {
|
|
console.log('🌱 Starting database seeding...');
|
|
|
|
// Create a test university
|
|
const university = await prisma.university.upsert({
|
|
where: { slug: 'test-university' },
|
|
update: {},
|
|
create: {
|
|
slug: 'test-university',
|
|
name: 'Test University',
|
|
shortName: 'TU',
|
|
domain: 'test-university.edu',
|
|
branding: {
|
|
primaryColor: '#3B82F6',
|
|
secondaryColor: '#1E40AF',
|
|
logo: '/logo.png'
|
|
},
|
|
contact: {
|
|
email: 'info@test-university.edu',
|
|
phone: '+1 (555) 123-4567',
|
|
address: '123 University Ave, City, State 12345'
|
|
},
|
|
features: {
|
|
aiChat: true,
|
|
multiLanguage: true,
|
|
cdn: false
|
|
},
|
|
ai: {
|
|
provider: 'ollama',
|
|
model: 'llama2',
|
|
enabled: true
|
|
},
|
|
status: 'ACTIVE'
|
|
}
|
|
});
|
|
|
|
console.log('✅ University created:', university.name);
|
|
|
|
// Create academic programs (majors)
|
|
const programs = [
|
|
{
|
|
title: 'Bachelor of Computer Science',
|
|
description: 'A comprehensive program covering software development, algorithms, and computer systems.',
|
|
level: 'UNDERGRADUATE',
|
|
duration: '4 years',
|
|
fees: '$12,000/year',
|
|
totalCredits: 120,
|
|
entryRequirements: 'High school diploma with strong mathematics background'
|
|
},
|
|
{
|
|
title: 'Master of Business Administration',
|
|
description: 'Advanced business management program with focus on leadership and strategy.',
|
|
level: 'POSTGRADUATE',
|
|
duration: '2 years',
|
|
fees: '$18,000/year',
|
|
totalCredits: 60,
|
|
entryRequirements: 'Bachelor\'s degree with 2+ years work experience'
|
|
},
|
|
{
|
|
title: 'PhD in Environmental Science',
|
|
description: 'Research-focused program in environmental studies and sustainability.',
|
|
level: 'PHD',
|
|
duration: '4-6 years',
|
|
fees: '$15,000/year',
|
|
totalCredits: 90,
|
|
entryRequirements: 'Master\'s degree in related field with research experience'
|
|
}
|
|
];
|
|
|
|
const createdPrograms = [];
|
|
for (const programData of programs) {
|
|
const program = await prisma.academicProgram.upsert({
|
|
where: {
|
|
id: `program-${programData.title.toLowerCase().replace(/\s+/g, '-')}`
|
|
},
|
|
update: {},
|
|
create: {
|
|
id: `program-${programData.title.toLowerCase().replace(/\s+/g, '-')}`,
|
|
...programData,
|
|
universityId: university.id,
|
|
level: programData.level as any
|
|
}
|
|
});
|
|
createdPrograms.push(program);
|
|
console.log('✅ Program created:', program.title);
|
|
}
|
|
|
|
// Create courses for each program
|
|
const coursesData = [
|
|
// Computer Science courses
|
|
{
|
|
programTitle: 'Bachelor of Computer Science',
|
|
courses: [
|
|
{ code: 'CS101', name: 'Introduction to Programming', description: 'Fundamentals of programming with Python', credits: 3, semester: '1', prerequisites: null },
|
|
{ code: 'CS201', name: 'Data Structures', description: 'Advanced data structures and algorithms', credits: 4, semester: '2', prerequisites: 'CS101' },
|
|
{ code: 'CS301', name: 'Database Systems', description: 'Database design and SQL programming', credits: 3, semester: '3', prerequisites: 'CS201' },
|
|
{ code: 'CS401', name: 'Software Engineering', description: 'Software development methodologies and practices', credits: 4, semester: '4', prerequisites: 'CS301' },
|
|
{ code: 'MATH101', name: 'Calculus I', description: 'Differential calculus and applications', credits: 4, semester: '1', prerequisites: null },
|
|
{ code: 'MATH201', name: 'Linear Algebra', description: 'Vector spaces and linear transformations', credits: 3, semester: '2', prerequisites: 'MATH101' }
|
|
]
|
|
},
|
|
// MBA courses
|
|
{
|
|
programTitle: 'Master of Business Administration',
|
|
courses: [
|
|
{ code: 'MBA501', name: 'Business Strategy', description: 'Strategic management and competitive analysis', credits: 3, semester: '1', prerequisites: null },
|
|
{ code: 'MBA502', name: 'Financial Management', description: 'Corporate finance and investment analysis', credits: 3, semester: '1', prerequisites: null },
|
|
{ code: 'MBA503', name: 'Marketing Management', description: 'Marketing strategy and consumer behavior', credits: 3, semester: '2', prerequisites: 'MBA501' },
|
|
{ code: 'MBA504', name: 'Operations Management', description: 'Supply chain and operations optimization', credits: 3, semester: '2', prerequisites: 'MBA502' }
|
|
]
|
|
},
|
|
// PhD courses
|
|
{
|
|
programTitle: 'PhD in Environmental Science',
|
|
courses: [
|
|
{ code: 'ENV601', name: 'Research Methods', description: 'Advanced research methodologies in environmental science', credits: 3, semester: '1', prerequisites: null },
|
|
{ code: 'ENV602', name: 'Environmental Policy', description: 'Environmental policy analysis and development', credits: 3, semester: '1', prerequisites: null },
|
|
{ code: 'ENV603', name: 'Climate Change Science', description: 'Advanced study of climate change mechanisms', credits: 3, semester: '2', prerequisites: 'ENV601' },
|
|
{ code: 'ENV604', name: 'Sustainability Systems', description: 'Systems thinking in sustainability', credits: 3, semester: '2', prerequisites: 'ENV602' }
|
|
]
|
|
}
|
|
];
|
|
|
|
for (const programCourses of coursesData) {
|
|
const program = createdPrograms.find(p => p.title === programCourses.programTitle);
|
|
if (program) {
|
|
for (const courseData of programCourses.courses) {
|
|
await prisma.course.upsert({
|
|
where: { code: courseData.code },
|
|
update: {},
|
|
create: {
|
|
code: courseData.code,
|
|
name: courseData.name,
|
|
description: courseData.description,
|
|
credits: courseData.credits,
|
|
semester: courseData.semester,
|
|
prerequisites: courseData.prerequisites,
|
|
universityId: university.id,
|
|
programId: program.id
|
|
}
|
|
});
|
|
console.log('✅ Course created:', courseData.code);
|
|
}
|
|
}
|
|
}
|
|
|
|
// Create sample users
|
|
const users = [
|
|
{
|
|
email: 'admin@test-university.edu',
|
|
name: 'Admin User',
|
|
password: 'admin123',
|
|
role: 'ADMIN',
|
|
universityId: university.id
|
|
},
|
|
{
|
|
email: 'student@test-university.edu',
|
|
name: 'John Student',
|
|
password: 'student123',
|
|
role: 'STUDENT',
|
|
universityId: university.id,
|
|
year: 2,
|
|
faculty: 'Computer Science'
|
|
},
|
|
{
|
|
email: 'staff@test-university.edu',
|
|
name: 'Jane Staff',
|
|
password: 'staff123',
|
|
role: 'STAFF',
|
|
universityId: university.id
|
|
}
|
|
];
|
|
|
|
for (const userData of users) {
|
|
const hashedPassword = await hashPassword(userData.password);
|
|
await prisma.user.upsert({
|
|
where: { email: userData.email },
|
|
update: {},
|
|
create: {
|
|
email: userData.email,
|
|
name: userData.name,
|
|
password: hashedPassword,
|
|
role: userData.role as any,
|
|
universityId: userData.universityId,
|
|
year: userData.year,
|
|
faculty: userData.faculty
|
|
}
|
|
});
|
|
console.log('✅ User created:', userData.email);
|
|
}
|
|
|
|
// Create sample content
|
|
const content = [
|
|
{
|
|
contentType: 'ABOUT',
|
|
title: 'About Our University',
|
|
content: 'Test University is a leading institution dedicated to academic excellence and innovation.',
|
|
isPublished: true
|
|
},
|
|
{
|
|
contentType: 'RANKINGS',
|
|
title: 'University Rankings',
|
|
content: 'Our university consistently ranks among the top institutions nationally and internationally.',
|
|
isPublished: true
|
|
}
|
|
];
|
|
|
|
for (const contentData of content) {
|
|
await prisma.universityContent.upsert({
|
|
where: {
|
|
id: `content-${contentData.contentType.toLowerCase()}`
|
|
},
|
|
update: {},
|
|
create: {
|
|
id: `content-${contentData.contentType.toLowerCase()}`,
|
|
contentType: contentData.contentType as any,
|
|
title: contentData.title,
|
|
content: contentData.content,
|
|
isPublished: contentData.isPublished,
|
|
universityId: university.id
|
|
}
|
|
});
|
|
console.log('✅ Content created:', contentData.title);
|
|
}
|
|
|
|
console.log('🎉 Database seeding completed successfully!');
|
|
}
|
|
|
|
main()
|
|
.catch((e) => {
|
|
console.error('❌ Error during seeding:', e);
|
|
process.exit(1);
|
|
})
|
|
.finally(async () => {
|
|
await prisma.$disconnect();
|
|
});
|