You are an expert full-stack developer tasked with building a Minimum Viable Product (MVP) for a secure inheritance management platform called 'Inheritance Manager'. The platform must allow users to securely store and manage digital assets, passwords, and important documents of deceased individuals for their heirs. The MVP should be built using Next.js with the App Router (`app/` directory), Tailwind CSS for styling, Drizzle ORM for database interactions with PostgreSQL, and NextAuth.js for authentication. Implement a multi-page structure, full CRUD (Create, Read, Update, Delete) operations for all core features, and robust API routes.
**Core Features to Implement:**
1. **User Authentication:** Secure user registration, login, and logout using NextAuth.js with email/password and potentially OAuth (e.g., Google). Implement password reset functionality.
2. **Secure Digital Vault:**
* **Password Manager:** Users can securely add, view, edit, and delete passwords for various accounts (banking, investments, social media, etc.). Implement encryption for sensitive password data at rest.
* **Document Storage:** Users can upload, view, edit, and delete important documents (e.g., death certificates, wills, insurance policies, property deeds). Store these files securely, possibly using a cloud storage solution like AWS S3 or Vercel Blob, with secure pre-signed URLs for access.
3. **Asset Inventory:**
* Users can add, view, edit, and delete different types of assets (e.g., bank accounts, investment portfolios, real estate, vehicles, digital assets like crypto). Each asset type should have relevant fields (e.g., for bank accounts: institution name, account number, current balance; for real estate: address, estimated value).
4. **Inheritance Management:**
* **Deceased Profile:** Users can create a profile for the deceased individual, including their name, date of passing, and basic information.
* **Heir/Beneficiary Management:** Users can add and manage beneficiaries or heirs, assigning them specific roles or access levels to certain assets or documents. This requires careful consideration of privacy and security.
* **Access Control:** Implement logic to grant or revoke access to specific vault items or asset details for designated heirs based on predefined conditions (e.g., after verification of death certificate).
5. **Verification Process:**
* Implement a workflow for uploading and verifying crucial documents like the death certificate. This might involve a manual review flag or integration with a future verification service.
**Technical Requirements:**
* **Project Setup:** Initialize a new Next.js project using `create-next-app` with the App Router enabled.
* **Database Schema (Drizzle ORM with PostgreSQL):** Define the following tables (use migrations):
* `users`: Standard user information (id, name, email, password hash, etc.)
* `accounts`: User's own accounts for managing their profile.
* `deceasedProfiles`: Information about the deceased person.
* `assets`: Generic asset table with type, name, description, value, related deceased profile ID.
* `assetDetails`: Specific fields for different asset types (e.g., `bankAccountDetails`, `realEstateDetails`). Use a flexible approach, perhaps JSONB or separate tables linked by foreign keys.
* `vaultItems`: General table for passwords and documents, linking to deceased profiles.
* `passwordEntries`: Specific fields for password items (url, username, encrypted password).
* `documentEntries`: Specific fields for document items (file name, file URL, mime type).
* `heirs`: Information about heirs/beneficiaries, linked to deceased profiles and users.
* `accessPermissions`: Linking heirs/users to vault items or asset details with specific permissions.
* **API Routes:** Create API routes within the `app/api/` directory for all CRUD operations for each entity (users, deceased profiles, assets, vault items, heirs, permissions). Ensure proper request validation and error handling.
* **UI/UX:** Develop a clean, intuitive, and secure user interface using React components and Tailwind CSS. Each core feature should have dedicated pages/sections within the `app/` directory (e.g., `app/dashboard`, `app/vault`, `app/assets`, `app/deceased/[id]`, `app/heirs`).
* **Security:** Prioritize security throughout the development process. Encrypt sensitive data (passwords) using industry-standard algorithms (e.g., AES-256). Implement rate limiting and protection against common web vulnerabilities (XSS, CSRF).
* **State Management:** Utilize React's Context API or a suitable library for managing global state where necessary.
* **Error Handling:** Implement comprehensive error handling for API requests and user interactions.
* **Deployment:** Ensure the application is deployable to a platform like Vercel.
**Prompt Structure:**
Start by setting up the Next.js project with the App Router. Then, define the Drizzle schema, implement database migrations, and set up the PostgreSQL database connection. Proceed to implement authentication with NextAuth.js. Following that, create the API routes and corresponding UI components for each of the core features, ensuring full CRUD functionality and secure data handling. Pay close attention to the relationships between tables and implement robust access control logic for inheritance management.
**Example Drizzle Schema Snippets (Illustrative):**
```typescript
// users table
export const users = pgTable('users', {
id: text('id').primaryKey(),
name: text('name'),
email: text('email').notNull().unique(),
// ... other fields
});
// deceasedProfiles table
export const deceasedProfiles = pgTable('deceased_profiles', {
id: uuid('id').primaryKey(),
userId: text('user_id').notNull().references(() => users.id),
name: text('name').notNull(),
dateOfPassing: timestamp('date_of_passing'),
// ... other fields
});