Index: README.md
===================================================================
--- README.md	(revision 92c45a3d4ce7df33941d34706b6684bb837042b7)
+++ README.md	(revision 38387ceb48afdaac1fa1f6f49357e6aa5a0d672d)
@@ -75,4 +75,44 @@
 - `yarn db:seed` - Seed the database with initial data
 
+## Database Features
+
+### Transactions
+
+The application uses database transactions in several key operations:
+
+- Invoice creation: When creating a new invoice, a transaction ensures that both the invoice and its items are created atomically
+- Status updates: Invoice status changes are handled within transactions to maintain data consistency
+- Client updates: When updating client information, related operations are wrapped in transactions
+
+Transactions are implemented in the following files:
+
+- `src/app/api/invoices/[id]/route.ts`: For updating and deleting invoices
+- `src/app/api/invoices/route.ts`: For creating new invoices
+
+### Triggers
+
+The system implements a sophisticated trigger system for invoice management:
+
+- `invoice_status_update_trigger`: Automatically fires when an invoice status changes
+  - Logs status changes in `InvoiceStatusHistory`
+  - Creates notifications in `InvoiceNotifications`
+  - Updates client status based on payment history
+  - Automatically extends due dates when needed
+  - Calculates and updates financial metrics
+
+### Indexes
+
+Several optimized indexes are implemented for better query performance:
+
+- Client email lookups:
+  - `idx_client_email`: Basic email search optimization
+  - `idx_client_email_tenant`: Composite index for tenant-specific email searches
+  - `idx_client_email_lower`: Case-insensitive email searches
+- Invoice management:
+  - `idx_invoice_status_history_invoice_id`: Optimizes status history lookups
+  - `idx_invoice_status_history_changed_at`: Improves date-based queries
+  - `idx_invoice_notifications_invoice_id`: Speeds up notification retrieval
+  - `idx_invoice_notifications_processed`: Partial index for unprocessed notifications
+
 ## Troubleshooting
 
Index: prisma/schema.prisma
===================================================================
--- prisma/schema.prisma	(revision 92c45a3d4ce7df33941d34706b6684bb837042b7)
+++ prisma/schema.prisma	(revision 38387ceb48afdaac1fa1f6f49357e6aa5a0d672d)
@@ -73,7 +73,4 @@
 
   items LineItem[]
-
-  // Note: Complex trigger for status updates is handled via raw SQL
-  // in sql/01_invoice_status_trigger.sql
 
   // Performance indexes for common queries
Index: src/app/api/invoices/[id]/route.ts
===================================================================
--- src/app/api/invoices/[id]/route.ts	(revision 92c45a3d4ce7df33941d34706b6684bb837042b7)
+++ src/app/api/invoices/[id]/route.ts	(revision 38387ceb48afdaac1fa1f6f49357e6aa5a0d672d)
@@ -1,4 +1,4 @@
 import { NextRequest, NextResponse } from 'next/server';
-import { invoiceSchema, updateInvoiceSchema } from 'src/schemas';
+import { updateInvoiceSchema } from 'src/schemas';
 import prisma from 'src/lib/prisma';
 import { authenticateRequest } from 'src/lib/auth-middleware';
