Create a full-stack Minimum Viable Product (MVP) for 'Girişimci Rehberi (Entrepreneur's Guide)', a platform designed to help small and medium-sized business owners value their businesses, connect with potential buyers, and streamline the selling process. The application should be built using Next.js App Router, TypeScript, Tailwind CSS, Drizzle ORM with PostgreSQL, and NextAuth.js for authentication. The core functionalities must include user authentication, business listing creation, an automated business valuation tool (based on simplified financial inputs), a matching engine for buyers and sellers, secure in-app messaging, and a document template section.
**Project Structure:**
Use the Next.js App Router structure (app/ directory).
**Core Features & Requirements:**
1. **Authentication:**
* Implement secure user authentication using NextAuth.js with email/password and potentially OAuth (Google/GitHub).
* User roles: 'Seller' and 'Buyer'.
2. **User Profiles:**
* Sellers should be able to create detailed profiles for their businesses, including industry, location, revenue range, employee count, and a brief description.
* Buyers should be able to create profiles outlining their investment interests, preferred industries, and budget.
3. **Business Valuation Tool (MVP):**
* A simple, interactive tool where sellers input key financial metrics (e.g., annual revenue, profit margin, years in business).
* The tool should provide an estimated valuation range based on a simplified formula (e.g., multiple of profit or revenue, adjustable by industry). This is an MVP, so a basic multiplier model is sufficient.
* Store valuation results associated with the business listing.
4. **Business Listing Management (CRUD):**
* Sellers must be able to Create, Read, Update, and Delete business listings.
* Listings should include business name, description, industry, location, valuation range, and contact information (hidden until connection).
5. **Matching Engine:**
* Implement a basic algorithm to suggest potential matches between buyers and sellers based on industry, location, and financial criteria (e.g., buyer budget vs. seller valuation).
* Display matched businesses to users based on their profile preferences.
6. **In-App Messaging (Secure Communication):**
* Allow authenticated users (buyers and sellers) to initiate secure, one-on-one conversations after a mutual connection or interest is established.
* Implement real-time or near real-time messaging functionality.
7. **Document Templates:**
* Provide basic, downloadable document templates (e.g., Letter of Intent - LOI, Non-Disclosure Agreement - NDA) that users can adapt.
* These should be static files initially, downloadable from a dedicated page.
8. **Database Schema (Drizzle ORM with PostgreSQL):**
* Define the following tables (minimum required):
* `users`: id, name, email, password (hashed), role, createdAt, updatedAt
* `accounts`: (NextAuth.js related)
* `sessions`: (NextAuth.js related)
* `verificationTokens`: (NextAuth.js related)
* `businesses`: id, sellerId (fk to users), name, description, industry, location, revenueRange, employeeCount, valuationMin, valuationMax, status, createdAt, updatedAt
* `valuationInputs`: id, businessId (fk to businesses), annualRevenue, profitMargin, yearsInBusiness, createdAt
* `messages`: id, senderId (fk to users), receiverId (fk to users), content, createdAt, readAt (optional)
* `connections`: id, userId1, userId2, status (pending, accepted, rejected), createdAt (for buyer-seller connection requests)
9. **API Routes:**
* Create API routes within the `app/api` directory for all CRUD operations related to businesses, profiles, and potentially messages.
* Ensure proper request handling, validation, and error management.
10. **Frontend (Next.js App Router & Tailwind CSS):**
* Design a clean, responsive user interface using Tailwind CSS.
* Implement multi-page navigation (e.g., Home, Dashboard, Browse Businesses, My Listings, Messages, Profile Settings, Valuation Tool).
* Ensure all features are accessible and functional through the UI, interacting with the API routes.
**Development Instructions:**
* Set up a new Next.js project with TypeScript.
* Integrate Drizzle ORM with a PostgreSQL database (use a local instance like Supabase or a Dockerized Postgres).
* Configure NextAuth.js for authentication.
* Implement Tailwind CSS for styling.
* Develop the backend API routes and database models.
* Build the frontend components and pages, ensuring seamless integration with the backend.
* Focus on the core CRUD operations and the valuation/matching logic for the MVP.
* Do NOT create just a landing page or a simple SPA. The application must be a functional multi-page application with backend persistence and dynamic features.