Create a full-stack web application using Next.js App Router, Drizzle ORM with PostgreSQL, and Tailwind CSS. The application should serve as a platform for businesses to define their ideal customer profiles, including specific 'not for you if...' criteria, and to filter potential leads based on these criteria. The goal is to improve lead quality and reduce churn by pre-qualifying customers. Ensure all CRUD operations are implemented for relevant entities.
**Core Functionality:**
1. **User Authentication:** Implement secure user registration and login using NextAuth.js. Differentiate between 'Business' users and 'Admin' users.
2. **Business Profile Management:**
* Businesses should be able to create and manage their profile, including company name, industry, website, and a detailed description.
* Crucially, businesses must be able to define specific 'not for you if...' criteria. This should be a flexible field, potentially allowing multiple text-based exclusions (e.g., 'not for you if you need enterprise permissions', 'not for you if you require SOC2 compliance', 'not for you if you need offline functionality').
* Businesses should also define their 'ideal customer profile' characteristics.
3. **Lead Management:**
* Leads (potential customers) should be able to create a profile, providing information about their needs and requirements.
* Implement a matching algorithm that compares lead profiles against business 'not for you if...' criteria and ideal customer profiles. Leads that match exclusions should be flagged or filtered out.
* Leads should be able to search or browse businesses based on their needs and see which businesses are a good fit.
4. **Dashboard & Analytics:**
* **Business Dashboard:** Display a list of qualified leads, leads filtered out, and basic analytics on lead quality and conversion potential.
* **Lead Dashboard:** Display suitable businesses based on the lead's profile and criteria.
5. **Widget Integration:** Provide a code snippet (JavaScript) that businesses can embed on their own landing pages to pre-qualify visitors. This widget should dynamically fetch and display the business's 'not for you if...' criteria.
**Technical Stack & Implementation Details:**
* **Framework:** Next.js 14+ (App Router)
* **Database:** PostgreSQL
* **ORM:** Drizzle ORM (with DrizzleKit for schema management)
* **Styling:** Tailwind CSS
* **Authentication:** NextAuth.js
* **State Management:** React Context API or Zustand for simpler global state.
* **Deployment:** Vercel recommended.
**Database Schema (Drizzle ORM):**
* `users` table: `id`, `name`, `email`, `emailVerified`, `image`, `role` ('business' or 'admin'), `createdAt`, `updatedAt`.
* `accounts`, `sessions` tables (for NextAuth.js).
* `business_profiles` table: `id`, `userId` (FK to users), `companyName`, `industry`, `website`, `description`, `idealCustomerProfile` (text), `notForYouIfCriteria` (jsonb or text array), `createdAt`, `updatedAt`.
* `lead_profiles` table: `id`, `userId` (optional, for registered leads), `name`, `email`, `requirements` (text), `createdAt`, `updatedAt`.
* `lead_business_matches` table: `id`, `leadId` (FK to lead_profiles), `businessId` (FK to business_profiles), `matchScore` (float), `isQualified` (boolean), `notes` (text), `createdAt`.
**API Routes (app/api/):**
* Implement API routes for all CRUD operations for `business_profiles` and `lead_profiles`.
* Create an API route for the matching algorithm (`/api/match-leads` or similar) that businesses can call to find suitable leads, or that runs periodically.
* Create an API route to serve the widget configuration (`/api/widget-config/[businessId]`).
**Project Structure:**
* `app/` directory for routing.
* `components/` for reusable UI components.
* `lib/` for utility functions, database connection, and ORM setup.
* `styles/` for global styles.
* `db/` for Drizzle schema and migrations.
**MVP Focus:** Ensure the core functionality of profile creation, criteria definition, lead matching, and basic dashboard views are fully implemented and functional. The widget generation should also be a primary focus. Error handling and user feedback should be considered throughout.