Create a full-stack web application using Next.js App Router (app/ directory), Drizzle ORM with PostgreSQL, and Tailwind CSS. The application should be a 'Smart Investment Guide' (Akıllı Yatırım Rehberi) designed to help users manage unexpected windfalls. Implement a multi-page structure with robust CRUD operations for user profiles, investment portfolios, and financial goals.
**Core Functionality:**
1. **User Authentication:** Secure user registration and login using Clerk.js or NextAuth.js.
2. **User Profile Management:**
* **Schema:** `users` table with fields for `userId` (uuid, primary key), `clerkUserId` (string, unique, indexed), `name` (string), `email` (string, unique, indexed), `riskTolerance` (enum: 'low', 'medium', 'high'), `financialGoals` (jsonb or text[]), `emergencyFundStatus` (enum: 'funded', 'partially_funded', 'unfunded'), `debtStatus` (enum: 'none', 'low', 'high').
* **CRUD:** Allow users to create, read, update, and delete their profile information. Include a guided onboarding flow to collect initial data.
3. **Investment Portfolio Management:**
* **Schema:** `portfolios` table with `portfolioId` (uuid, primary key), `userId` (uuid, foreign key to `users.userId`, indexed), `name` (string, e.g., 'Retirement Fund', 'New Car Fund'), `initialInvestment` (decimal), `currentValue` (decimal), `creationDate` (timestamp), `lastUpdated` (timestamp).
* **Schema:** `portfolioAssets` table with `assetId` (uuid, primary key), `portfolioId` (uuid, foreign key to `portfolios.portfolioId`, indexed), `assetName` (string, e.g., 'Vanguard S&P 500 ETF'), `assetType` (enum: 'stock', 'bond', 'etf', 'mutual fund', 'real estate', 'other'), `quantity` (decimal), `purchasePrice` (decimal), `currentPrice` (decimal), `purchaseDate` (timestamp).
* **CRUD:** Allow users to create, read, update, and delete portfolios and the assets within them. Automatically calculate portfolio value and daily gains/losses.
4. **Financial Goal Setting & Tracking:**
* **Schema:** `goals` table with `goalId` (uuid, primary key), `userId` (uuid, foreign key to `users.userId`, indexed), `name` (string, e.g., 'Down Payment for House'), `targetAmount` (decimal), `targetDate` (timestamp), `currentSaved` (decimal), `priority` (enum: 'low', 'medium', 'high').
* **CRUD:** Enable users to define, monitor progress towards, and adjust their financial goals.
5. **Personalized Recommendation Engine (Simplified MVP):**
* Based on user's `riskTolerance`, `financialGoals`, and `emergencyFundStatus`, suggest a basic asset allocation strategy (e.g., % stocks, % bonds, % cash). This should be presented clearly on a 'Recommendations' page.
* For the MVP, this can be rule-based logic. For example, 'high' risk tolerance with 'long-term' goals might suggest a higher percentage of equities.
6. **Investment Simulation Tool:**
* A page where users can input hypothetical investment amounts, expected returns (based on asset class averages), and timeframes to see projected growth. No real-time market data integration in MVP, use static or user-inputted return rates.
7. **Financial Literacy Content:**
* A section with articles/guides on basic financial concepts (e.g., compound interest, diversification, risk management). This can be static content initially.
**Technical Stack & Implementation Details:**
* **Framework:** Next.js App Router (`app/` directory).
* **Database:** PostgreSQL with Drizzle ORM. Set up migrations.
* **Styling:** Tailwind CSS for rapid UI development.
* **State Management:** React Context API or Zustand for client-side state.
* **API Layer:** Use Next.js API Routes (`app/api/...`) for all backend logic and database interactions. Implement robust error handling and validation.
* **Deployment:** Assume deployment to Vercel.
**Project Structure:**
```
app/
(auth)/ // Authentication routes (login, register, reset password)
(dashboard)/ // Main application routes after login
profile/
page.tsx
[id]/edit/page.tsx
portfolios/
page.tsx
[id]/page.tsx
new/page.tsx
goals/
page.tsx
new/page.tsx
recommendations/
page.tsx
simulator/
page.tsx
learn/
page.tsx
[slug]/page.tsx
api/
auth/
[...nextauth]/route.ts (if using NextAuth.js)
users/
route.ts
portfolios/
route.ts
[id]/route.ts
goals/
route.ts
... etc. for other resources
lib/
db.ts // Drizzle setup
utils.ts
components/
... React components (e.g., Button, Input, PortfolioCard, GoalTracker)
styles/
globals.css
middleware.ts // For authentication checks
```
**Instructions for AI:**
* Generate the complete Next.js application structure.
* Define all database schemas using Drizzle ORM for PostgreSQL.
* Implement all API routes for CRUD operations, ensuring proper request handling and response formatting.
* Create React components for the UI using Tailwind CSS.
* Integrate user authentication.
* Build the user profile, portfolio management, and goal setting interfaces with corresponding CRUD logic.
* Develop the simplified recommendation engine and investment simulator pages.
* Include basic financial literacy content pages.
* Ensure the application is fully functional as an MVP, allowing users to interact with all core features.
* Avoid creating a simple landing page or a basic SPA. Focus on a multi-page application with a functional backend and database integration.