Create a full-stack web application using Next.js App Router (app/ directory), Drizzle ORM with PostgreSQL, and Tailwind CSS. The application should allow users to analyze the potential of buying their rental property from their landlord at a discount.
**Core Functionality:**
1. **User Authentication:** Implement secure user signup and login using NextAuth.js.
2. **Property Input Form:** A multi-step form for users to input details about their rental property (address, size, number of rooms, condition, lease end date, current rent) and their desired purchase price.
3. **Market Value Analysis:** Integrate with a real estate data API (e.g., Zillow API, Realtor.com API, or a mock API for MVP) to fetch comparable sales data for properties in the user's specified area. If no external API is available for the MVP, simulate this data retrieval.
4. **Discount Potential Calculation:** Based on the user's input and fetched market data, calculate an estimated fair market value and a potential discount range. This calculation should consider factors like the landlord's potential motivation (e.g., avoiding agent fees, quick sale), current market conditions, and the property's condition relative to comparable sales.
5. **Pazarlık Stratejileri (Negotiation Strategies) Module:** Provide curated content (text-based) offering negotiation tips, common landlord objections, and effective counter-arguments tailored to different scenarios.
6. **Agent/Appraiser Finder:** A feature to search for and connect with local real estate agents and property appraisers. Initially, this can be a list of recommended professionals or a simple search interface.
7. **User Dashboard:** Display a summary of the user's saved property analyses, negotiation tips, and connection to agents.
**Technical Stack & Implementation Details:**
* **Framework:** Next.js (App Router)
* **Database:** PostgreSQL with Drizzle ORM for type-safe database interactions.
* **Authentication:** NextAuth.js
* **Styling:** Tailwind CSS
* **State Management:** React Context API or Zustand for frontend state.
* **API Routes:** Implement API routes within the `app/api/` directory for all backend operations (CRUD).
* **Database Schema (Drizzle):**
* `users` table: id, name, email, emailVerified, image
* `accounts` table: ... (standard NextAuth.js accounts schema)
* `sessions` table: ... (standard NextAuth.js sessions schema)
* `verificationTokens` table: ... (standard NextAuth.js verificationTokens schema)
* `properties` table: id, userId (foreign key to users), address, city, state, zipCode, propertyType, squareFootage, numBedrooms, numBathrooms, conditionDescription, currentRent, leaseEndDate, estimatedMarketValue, estimatedDiscountPercentage, landlordNegotiationStrategy
* `marketComps` table: id, propertyId (foreign key to properties), comparableAddress, comparableSalePrice, comparableSquareFootage, saleDate, distanceToUserProperty
* `negotiationTips` table: id, title, content, category (e.g., 'initial offer', 'counter offer', 'objections')
* `agents` table: id, name, specialization, contactInfo, region
* **CRUD Operations:** Implement full CRUD for `properties` and `marketComps` (for analysis results).
* **API Routes Examples:**
* `POST /api/properties`: Save a new property analysis.
* `GET /api/properties/:id`: Get details of a specific property analysis.
* `PUT /api/properties/:id`: Update a property analysis.
* `DELETE /api/properties/:id`: Delete a property analysis.
* `GET /api/market-data?address=...`: Fetch market data (simulated or real API call).
* `GET /api/negotiation-tips?category=...`: Fetch relevant negotiation tips.
* `GET /api/agents?region=...`: Fetch local agents.
**MVP Focus:**
Ensure the core functionality (property input, market value estimation (can be simulated), discount calculation, and basic negotiation tips) is fully working with robust CRUD operations. The agent finder can be a simple list initially.
**Project Structure:**
```
app/
api/
properties/
[id]/ <-- dynamic route for CRUD
route.ts
route.ts <-- POST for creating properties
market-data/ <-- API route for market data (simulated)
route.ts
negotiation-tips/
route.ts
agents/
route.ts
(auth)/ <-- NextAuth.js routes
route.ts
dashboard/
page.tsx <-- User dashboard
properties/
new/page.tsx <-- Property input form
[id]/page.tsx <-- Property analysis detail page
negotiation-tips/
page.tsx <-- Negotiation tips listing
[slug]/page.tsx <-- Individual tip page
agents/
page.tsx <-- Agent finder page
layout.tsx <-- Root layout
page.tsx <-- Home/Landing page
components/
...
lib/
...
prisma/
schema.prisma <-- If using Prisma as the ORM, otherwise Drizzle config
drizzle.config.ts <-- Drizzle ORM configuration
```
**Development Instructions:**
1. Set up a new Next.js project with the App Router.
2. Configure PostgreSQL and Drizzle ORM.
3. Implement user authentication using NextAuth.js.
4. Build the multi-step property input form.
5. Develop the backend API routes for CRUD operations on properties.
6. Implement the market value and discount calculation logic (initially simulated).
7. Create the negotiation tips module and agent finder feature.
8. Style the application using Tailwind CSS for a clean and responsive UI.
9. Ensure all features are fully functional and integrated, demonstrating complete CRUD capabilities and multi-page navigation.