Create a full-stack web application using Next.js App Router (app/ directory), TypeScript, Tailwind CSS, and Drizzle ORM with PostgreSQL. The application, named 'Inheritance Manager', should allow users to securely manage inherited assets, calculate tax liabilities, and provide guidance on legal processes related to inheritance.
**Core Features (MVP):
1. User Authentication:
- Implement secure email/password authentication using NextAuth.js.
- Ensure password hashing with bcrypt.
2. Asset Management:
- Users can add, view, edit, and delete inherited assets (e.g., annuities, stocks, real estate).
- Each asset should have fields for: name, type, purchase/inheritance date, initial value, current value, source (e.g., deceased individual's name), and any associated documentation links.
- Implement full CRUD operations for assets.
3. Tax Calculation:
- Develop a module to calculate potential tax liabilities based on asset type, value, and user-provided tax jurisdiction.
- Include calculations for past due taxes, estimated interest, and penalties.
- Allow users to input historical tax return data or links to tax documents.
4. Guidance & Notifications:
- Provide step-by-step guidance for amending past tax returns.
- Offer information and links to relevant tax authority resources (e.g., IRS website).
- Implement a notification system for upcoming deadlines or required actions.
5. Dashboard & Reporting:
- A central dashboard summarizing total inherited asset value, estimated tax liability, and upcoming tasks.
- Generate downloadable reports (e.g., CSV, PDF) of asset inventory and tax summaries.
**Technical Stack & Implementation Details:
1. Next.js App Router:
- Structure the application using the `app/` directory for routing.
- Implement server components and client components where appropriate.
2. Drizzle ORM & PostgreSQL:
- Set up Drizzle ORM with a PostgreSQL database.
- Define database schemas for users, assets, and tax information using Drizzle's schema definition language.
- Implement all data interactions (CRUD) through Drizzle ORM.
- **Database Schema (Drizzle):**
```typescript
// schema.ts
import { pgTable, serial, text, timestamp, numeric, pgEnum } from 'drizzle-orm/pg-core';
export const assetTypeEnum = pgEnum('asset_type', ['annuity', 'stock', 'real_estate', 'other']);
export const users = pgTable('users', {
id: serial('id').primaryKey(),
email: text('email').notNull().unique(),
hashedPassword: text('hashed_password').notNull(),
createdAt: timestamp('created_at').defaultNow(),
});
export const assets = pgTable('assets', {
id: serial('id').primaryKey(),
userId: serial('user_id').references(() => users.id, { onDelete: 'cascade' }).notNull(),
name: text('name').notNull(),
type: assetTypeEnum('type').notNull(),
inheritanceDate: timestamp('inheritance_date').notNull(),
initialValue: numeric('initial_value').notNull(),
currentValue: numeric('current_value'),
source: text('source'),
documentationLink: text('documentation_link'),
createdAt: timestamp('created_at').defaultNow(),
});
export const taxRecords = pgTable('tax_records', {
id: serial('id').primaryKey(),
userId: serial('user_id').references(() => users.id, { onDelete: 'cascade' }).notNull(),
assetId: serial('asset_id').references(() => assets.id, { onDelete: 'cascade' }), // Can be null if tax applies to overall income
taxYear: serial('tax_year').notNull(),
reportedIncome: numeric('reported_income').default(0),
unreportedIncome: numeric('unreported_income').default(0),
calculatedTax: numeric('calculated_tax').default(0),
interest: numeric('interest').default(0),
penalties: numeric('penalties').default(0),
status: text('status').default('pending'), // e.g., 'pending', 'amended', 'filed'
createdAt: timestamp('created_at').defaultNow(),
updatedAt: timestamp('updated_at').defaultNow(),
});
```
3. API Routes (Route Handlers):
- Create API routes within the `app/api/` directory for all CRUD operations related to users, assets, and tax records.
- Ensure proper request validation and error handling.
- Examples:
- `POST /api/auth/signup`
- `POST /api/auth/signin`
- `GET /api/assets`
- `POST /api/assets`
- `PUT /api/assets/[id]`
- `DELETE /api/assets/[id]`
- `GET /api/tax-records`
- `POST /api/tax-records`
- `PUT /api/tax-records/[id]`
4. State Management:
- Utilize React Context API or a lightweight state management library if needed for complex client-side state.
5. Styling:
- Use Tailwind CSS for efficient and responsive UI design.
6. Deployment:
- Ensure the application is deployable to platforms like Vercel or Netlify.
**Project Structure (Example):
```
app/
api/
auth/
[...nextauth]/route.ts
assets/
route.ts
[id]/route.ts
tax-records/
route.ts
[id]/route.ts
(routes for dashboard, assets, tax-filing, etc.)
layout.tsx
page.tsx
components/
drizzle/
index.ts
schema.ts
lib/
auth.ts
db.ts
utils.ts
public/
styles/
```
**Focus on Security:**
- Sanitize all user inputs to prevent XSS attacks.
- Implement appropriate authorization checks for API routes to ensure users can only access their own data.
- Use environment variables for sensitive information (database credentials, JWT secrets).
**Deliverables:**
- A fully functional Next.js application with all described features.
- Clean, well-documented code.
- A README file explaining setup and usage.