You are an expert Next.js full-stack developer. Your task is to build a fully functional MVP for a "Corporate Memory Bridge" application. This application aims to prevent the loss of institutional knowledge during employee turnovers, especially layoffs, by facilitating structured knowledge capture and transfer.Technology Stack:Next.js 14 (using the App Router structure in the `app/` directory)TypeScriptDrizzle ORMPostgreSQL (assume connection string is provided, focus on schema and queries)NextAuth.jsTailwind CSSCore Features & Functionality:1. User Management & Authentication:User Roles: Implement three distinct roles: `ADMIN`, `MANAGER`, `EMPLOYEE`.Authentication: Secure sign-in/sign-up using NextAuth.js.User Profiles: Basic user information (name, email, role, department, employment status).Role-Based Access Control (RBAC): Ensure different pages and API routes have appropriate access restrictions based on the user's role.2. Department & Project Management:CRUD for Departments: Admins can create, view, update, and delete company departments.CRUD for Projects: Admins/Managers can create, view, update, and delete company projects.3. Knowledge Item Management:Knowledge Item Creation: Departing employees (or their managers) can create "knowledge items" containing critical information. Fields include:`title`: Short descriptive title.`content`: Detailed explanation, guides, best practices (rich text editor placeholder).`associatedProjects`: Multi-select projects relevant to this knowledge.`tags`: Keywords for easy discoverability.`ownerId`: The user ID of the employee who owns/created this knowledge.`recipientId`: (Optional) User ID of the employee designated to receive/take over this knowledge.`status`: Enum `['DRAFT', 'PENDING_REVIEW', 'APPROVED', 'ARCHIVED', 'TRANSFERRED']`.CRUD for Knowledge Items:Employees can create and edit their own `DRAFT` knowledge items.Managers can review, approve, request revisions, and change the status of knowledge items owned by their direct reports or within their department.Admins have full control over all knowledge items.Search & Filtering: Users should be able to search knowledge items by title, content, tags, associated projects, owner, recipient, and status.Knowledge Transfer Workflow:A manager can initiate a "knowledge transfer request" for an employee marked as departing. This creates a notification/task for the employee to submit knowledge items.The system tracks the progress of knowledge item submission and approval.Database Schema (Drizzle ORM for PostgreSQL):```typescript// Define schema in a drizzle/schema.ts fileimport { pgTable, serial, text, varchar, timestamp, boolean, pgEnum, foreignKey } from 'drizzle-orm/pg-core';import { relations } from 'drizzle-orm';// Enumsexport const userRoleEnum = pgEnum('user_role', ['ADMIN', 'MANAGER', 'EMPLOYEE']);export const knowledgeItemStatusEnum = pgEnum('knowledge_item_status', ['DRAFT', 'PENDING_REVIEW', 'APPROVED', 'ARCHIVED', 'TRANSFERRED']);// Tablesexport const users = pgTable('users', { id: serial('id').primaryKey(), name: varchar('name', { length: 255 }).notNull(), email: varchar('email', { length: 255 }).unique().notNull(), passwordHash: text('password_hash').notNull(), // For NextAuth credentials provider or similar role: userRoleEnum('role').default('EMPLOYEE').notNull(), departmentId: serial('department_id').references(() => departments.id), employmentStatus: varchar('employment_status', { length: 50 }).default('ACTIVE').notNull(), // e.g., 'ACTIVE', 'DEPARTING', 'TERMINATED' createdAt: timestamp('created_at').defaultNow().notNull(), updatedAt: timestamp('updated_at').defaultNow().notNull(),});export const departments = pgTable('departments', { id: serial('id').primaryKey(), name: varchar('name', { length: 255 }).unique().notNull(), createdAt: timestamp('created_at').defaultNow().notNull(), updatedAt: timestamp('updated_at').defaultNow().notNull(),});export const projects = pgTable('projects', { id: serial('id').primaryKey(), name: varchar('name', { length: 255 }).unique().notNull(), description: text('description'), createdAt: timestamp('created_at').defaultNow().notNull(), updatedAt: timestamp('updated_at').defaultNow().notNull(),});export const knowledgeItems = pgTable('knowledge_items', { id: serial('id').primaryKey(), title: varchar('title', { length: 500 }).notNull(), content: text('content').notNull(), // Placeholder for rich text ownerId: serial('owner_id').references(() => users.id, { onDelete: 'SET NULL' }), // If owner leaves, item still exists recipientId: serial('recipient_id').references(() => users.id, { onDelete: 'SET NULL' }), // Optional designated recipient status: knowledgeItemStatusEnum('status').default('DRAFT').notNull(), createdAt: timestamp('created_at').defaultNow().notNull(), updatedAt: timestamp('updated_at').defaultNow().notNull(),});export const tags = pgTable('tags', { id: serial('id').primaryKey(), name: varchar('name', { length: 100 }).unique().notNull(), createdAt: timestamp('created_at').defaultNow().notNull(),});export const knowledgeItemToTags = pgTable('knowledge_item_to_tags', { knowledgeItemId: serial('knowledge_item_id').references(() => knowledgeItems.id, { onDelete: 'CASCADE' }), tagId: serial('tag_id').references(() => tags.id, { onDelete: 'CASCADE' }),});export const knowledgeItemToProjects = pgTable('knowledge_item_to_projects', { knowledgeItemId: serial('knowledge_item_id').references(() => knowledgeItems.id, { onDelete: 'CASCADE' }), projectId: serial('project_id').references(() => projects.id, { onDelete: 'CASCADE' }),});// Relations (for Drizzle)export const userRelations = relations(users, ({ one, many }) => ({ department: one(departments, { fields: [users.departmentId], references: [departments.id], }), ownedKnowledgeItems: many(knowledgeItems, { relationName: 'owned_items' }), receivedKnowledgeItems: many(knowledgeItems, { relationName: 'received_items' }),}));export const departmentRelations = relat