Create a full-stack web application using Next.js App Router (app directory). The application will be a Travel Planner where users can manage all their trip details.
**Database Schema (using Drizzle ORM with PostgreSQL):**
1. **users table:**
* id (UUID, primary key)
* email (VARCHAR, unique)
* password (VARCHAR)
* name (VARCHAR)
* created_at (TIMESTAMP)
* updated_at (TIMESTAMP)
2. **trips table:**
* id (UUID, primary key)
* user_id (UUID, foreign key to users.id)
* title (VARCHAR)
* start_date (DATE)
* end_date (DATE)
* destination (VARCHAR)
* created_at (TIMESTAMP)
* updated_at (TIMESTAMP)
3. **bookings table:**
* id (UUID, primary key)
* trip_id (UUID, foreign key to trips.id)
* booking_type (VARCHAR - e.g., 'flight', 'hotel', 'activity', 'other')
* provider (VARCHAR - e.g., 'Turkish Airlines', 'Marriott')
* booking_reference (VARCHAR)
* details (JSONB - for flexible additional info like flight numbers, room types, times, locations)
* start_datetime (TIMESTAMP)
* end_datetime (TIMESTAMP)
* notes (TEXT)
* created_at (TIMESTAMP)
* updated_at (TIMESTAMP)
4. **notes table:**
* id (UUID, primary key)
* trip_id (UUID, foreign key to trips.id)
* content (TEXT)
* created_at (TIMESTAMP)
* updated_at (TIMESTAMP)
5. **trip_collaborators table:** (For basic sharing/viewing)
* id (UUID, primary key)
* trip_id (UUID, foreign key to trips.id)
* collaborator_user_id (UUID, foreign key to users.id)
* permission_level (VARCHAR - e.g., 'viewer')
* created_at (TIMESTAMP)
**Frontend (Next.js App Router):**
* Use `app/` directory for routing.
* Implement protected routes for logged-in users.
* **Pages:**
* `/auth/signin` (Sign In page)
* `/auth/signup` (Sign Up page)
* `/dashboard` (List of user's trips)
* `/trips/[tripId]` (Details of a specific trip, showing bookings and notes)
* `/trips/new` (Form to create a new trip)
* `/trips/[tripId]/edit` (Form to edit an existing trip)
* `/trips/[tripId]/bookings/new` (Form to add a new booking)
* `/trips/[tripId]/bookings/[bookingId]/edit` (Form to edit a booking)
* `/trips/[tripId]/notes/new` (Form to add a new note)
* `/trips/[tripId]/notes/[noteId]/edit` (Form to edit a note)
* `/trips/[tripId]/collaborators` (Page to manage collaborators for a trip - MVP is viewer only)
* Use a UI library like Tailwind CSS with Shadcn UI for components.
* Implement client-side and server-side form handling with validation.
**Backend (API Routes and Server Actions):**
* Use Next.js API Routes (`app/api/...`) or Server Actions for all backend logic.
* **Authentication:** Implement JWT-based authentication or NextAuth.js.
* **CRUD Operations:** Implement full CRUD for `trips`, `bookings`, and `notes`.
* **Database Interaction:** Use Drizzle ORM for all database operations. Ensure proper transaction management where applicable.
* **API Endpoints (Examples):**
* `POST /api/trips` (Create trip)
* `GET /api/trips` (Get user's trips)
* `GET /api/trips/[tripId]` (Get single trip)
* `PUT /api/trips/[tripId]` (Update trip)
* `DELETE /api/trips/[tripId]` (Delete trip)
* Similar endpoints for `bookings` and `notes`.
* **Error Handling:** Implement robust error handling and return appropriate HTTP status codes.
**MVP Requirements:**
* User registration and login.
* Ability to create, read, update, and delete trips.
* Ability to add, read, update, and delete bookings (with type, provider, reference, date/time, and details).
* Ability to add, read, update, and delete notes within a trip.
* Basic collaborator functionality: A trip owner can invite another registered user by email to view their trip details (read-only).
* Ensure data integrity and security.