You are an expert AI assistant tasked with building a comprehensive SaaS MVP for managing layoff communications. The application should be built using Next.js App Router (app/ directory), a multi-page structure, and utilize Drizzle ORM with PostgreSQL for the database. The core functionality should revolve around securely and humanely communicating layoff decisions to employees, while ensuring legal compliance and providing support resources. The application must support full CRUD operations for all relevant entities.
**Project Structure:**
- `app/` directory for routing and page components.
- `components/` for reusable UI elements.
- `lib/` for utility functions and Drizzle configuration.
- `prisma/` or `migrations/` for database schema and migrations.
- `api/` routes for backend logic.
**Database Schema (Drizzle ORM with PostgreSQL):**
1. **`companies` table:**
- `id` (UUID, primary key)
- `name` (string, not null)
- `industry` (string)
- `createdAt` (timestamp, default now())
- `updatedAt` (timestamp, default now())
2. **`employees` table:**
- `id` (UUID, primary key)
- `companyId` (UUID, foreign key to `companies.id`)
- `firstName` (string, not null)
- `lastName` (string, not null)
- `email` (string, not null, unique)
- `employeeId` (string, unique)
- `hireDate` (date)
- `terminationDate` (date, nullable)
- `status` (enum: 'active', 'terminated')
- `createdAt` (timestamp, default now())
- `updatedAt` (timestamp, default now())
3. **`layoffNotifications` table:**
- `id` (UUID, primary key)
- `companyId` (UUID, foreign key to `companies.id`)
- `employeeId` (UUID, foreign key to `employees.id`)
- `notificationDate` (timestamp, not null)
- `messageSubject` (string, not null)
- `messageBody` (text, not null)
- `status` (enum: 'draft', 'sent', 'acknowledged', 'read')
- `sentAt` (timestamp, nullable)
- `createdAt` (timestamp, default now())
- `updatedAt` (timestamp, default now())
4. **`supportResources` table:**
- `id` (UUID, primary key)
- `companyId` (UUID, foreign key to `companies.id`, nullable for general resources)
- `title` (string, not null)
- `description` (text)
- `url` (string)
- `type` (enum: 'legal', 'career_coaching', 'hr_contact', 'faq')
- `createdAt` (timestamp, default now())
- `updatedAt` (timestamp, default now())
**Core Features (MVP):**
1. **Company Onboarding & Management:**
- Allow companies to register and manage their profile.
- CRUD operations for `companies` table.
2. **Employee Management:**
- CRUD operations for `employees` table within a company.
- Ability to mark employees as 'terminated' and set `terminationDate`.
3. **Layoff Notification System:**
- **Create Notification:** Interface for HR managers to draft layoff notifications.
- Select employee(s).
- Customize message subject and body using templates and placeholders (e.g., `[Employee Name]`, `[Company Name]`, `[Last Day]`).
- Define `notificationDate` (immediate or scheduled).
- Include links to relevant `supportResources`.
- **Send Notification:** Securely send notifications to terminated employees via email (use a transactional email service like Resend or Nodemailer).
- **Status Tracking:** Track the status of notifications ('draft', 'sent', 'read', 'acknowledged'). Employees should be able to 'acknowledge' receipt.
- CRUD operations for `layoffNotifications` table.
4. **Support Resource Management:**
- Companies can add, edit, and delete support resources (links to legal advice, career coaching, HR contacts, FAQs).
- These resources should be linkable to layoff notifications.
- CRUD operations for `supportResources` table.
5. **Employee View (Secure Portal):**
- A secure, authenticated portal for terminated employees.
- Employees can log in (using email and a secure token/password) to view their layoff notification details.
- Access to associated support resources.
- Option to acknowledge receipt of the notification.
**Technical Requirements:**
- **Next.js App Router:** Implement routing using the `app/` directory. Utilize server components where appropriate for data fetching and mutations.
- **Drizzle ORM:** Use Drizzle ORM with a PostgreSQL database (e.g., Neon, Supabase, or a self-hosted instance).
- **API Routes:** Create API routes (`app/api/...`) for all backend logic, including database interactions (CRUD operations).
- **Authentication:** Implement secure authentication for both company admins and terminated employees. Consider NextAuth.js or a similar library.
- **Email Service:** Integrate a transactional email service for sending layoff notifications.
- **UI/UX:** Focus on a clean, empathetic, and professional user interface. Ensure the employee portal is particularly sensitive and easy to navigate.
- **Security:** Implement robust security measures, including input validation, protection against common web vulnerabilities (XSS, CSRF), and secure handling of sensitive employee data.
- **Error Handling:** Implement comprehensive error handling and logging.
- **Deployment:** The MVP should be deployable (e.g., Vercel, Netlify, or a cloud provider).