generate code for a Professional Loft Management Web Application

I'll provide a comprehensive plan for developing a professional loft management application using modern technologies and best practices.

## Core Functionalities

### Administrator/Owner Features

**Property Management**

- Multi-property dashboard with overview metrics
- Property details management (photos, descriptions, amenities)
- Unit configuration and pricing management
- Availability calendar and booking management
- Property performance analytics and reporting


**Tenant Management**

- Tenant profiles and contact information
- Lease agreement management and digital signing
- Rent collection and payment tracking
- Communication portal with messaging system
- Tenant screening and application processing


**Financial Management**

- Revenue tracking and financial reporting
- Expense management and categorization
- Tax document generation and storage
- Payment processing and reconciliation
- Profit/loss statements and cash flow analysis


**Maintenance & Operations**

- Work order management system
- Vendor management and scheduling
- Maintenance history tracking
- Preventive maintenance scheduling
- Asset management and inventory tracking


### Tenant Features

**Account Management**

- Personal dashboard with lease information
- Rent payment portal with payment history
- Document storage (lease, receipts, notices)
- Profile management and emergency contacts


**Communication & Support**

- Direct messaging with property management
- Maintenance request submission and tracking
- Community bulletin board and announcements
- FAQ and support documentation


**Convenience Features**

- Online rent payment with multiple payment methods
- Lease renewal requests and negotiations
- Guest registration and access management
- Utility usage tracking and reporting


## Technology Stack Recommendations

### Frontend & Backend

- **Framework**: Next.js 15 with App Router 
- **Components**: Server Components for optimal performance 
- **Styling**: Tailwind CSS with shadcn/ui components
- **State Management**: React Context + Server Actions
- **Form Handling**: React Hook Form with Zod validation


### Database & Storage

- **Database**: PostgreSQL (local development, cloud for production)
- **ORM**: Prisma for type-safe database operations
- **File Storage**: Vercel Blob for documents and images
- **Caching**: Redis for session management and caching


### Authentication & Security

- **Authentication**: NextAuth.js with multiple providers
- **Authorization**: Role-based access control (RBAC)
- **Security**: CSRF protection, rate limiting, input validation


### Deployment & Infrastructure

- **Hosting**: Vercel for seamless Next.js deployment
- **Database**: Neon or Supabase for managed PostgreSQL
- **Monitoring**: Vercel Analytics and error tracking
- **Email**: Resend for transactional emails


## Key UI/UX Considerations

### Responsive Design Principles

- **Mobile-First Approach**: Design for mobile devices first, then scale up
- **Flexible Grid System**: Use CSS Grid and Flexbox for adaptive layouts
- **Touch-Friendly Interface**: Minimum 44px touch targets for mobile
- **Progressive Enhancement**: Core functionality works without JavaScript


### Design Elements

- **Clean, Professional Aesthetic**: Minimalist design with clear hierarchy
- **Consistent Color Scheme**: Brand colors with accessibility compliance (WCAG 2.1)
- **Typography**: Clear, readable fonts with proper contrast ratios
- **Navigation**: Intuitive menu structure with breadcrumbs
- **Loading States**: Skeleton screens and progress indicators


### User Experience Features

- **Dashboard Customization**: Personalized widgets and layouts
- **Search & Filtering**: Advanced search capabilities across all data
- **Bulk Operations**: Multi-select actions for efficiency
- **Keyboard Navigation**: Full keyboard accessibility support
- **Offline Capability**: Service workers for basic offline functionality


## Security Protocols

### Data Protection

- **Encryption**: TLS 1.3 for data in transit, AES-256 for data at rest
- **PII Handling**: GDPR/CCPA compliant data processing
- **Data Backup**: Automated daily backups with point-in-time recovery
- **Access Logging**: Comprehensive audit trails for all user actions


### Authentication & Authorization

- **Multi-Factor Authentication**: SMS, email, and authenticator app support
- **Session Management**: Secure session handling with automatic timeout
- **Role-Based Permissions**: Granular permissions for different user types
- **API Security**: Rate limiting, API key management, and request validation


### Infrastructure Security

- **Environment Variables**: Secure storage of sensitive configuration
- **CORS Configuration**: Proper cross-origin resource sharing setup
- **Content Security Policy**: XSS protection through CSP headers
- **Regular Security Audits**: Automated vulnerability scanning


## Scalability Considerations

### Architecture Design

- **Microservices Approach**: Modular architecture for independent scaling
- **Database Optimization**: Proper indexing, query optimization, and connection pooling
- **Caching Strategy**: Multi-layer caching (browser, CDN, application, database)
- **Load Balancing**: Horizontal scaling with load distribution


### Performance Optimization

- **Code Splitting**: Automatic code splitting with Next.js 
- **Image Optimization**: Next.js Image component with WebP support 
- **Database Scaling**: Read replicas and database sharding strategies
- **CDN Integration**: Global content delivery for static assets


### Monitoring & Analytics

- **Performance Monitoring**: Real-time application performance tracking
- **Error Tracking**: Comprehensive error logging and alerting
- **Usage Analytics**: User behavior tracking and feature adoption metrics
- **Capacity Planning**: Proactive scaling based on usage patterns


## Monetization Strategies

### Subscription Models

- **Tiered Pricing**: Basic, Professional, Enterprise plans
- **Per-Property Pricing**: Scaling costs based on portfolio size
- **Feature-Based Pricing**: Premium features as add-ons
- **Annual Discounts**: Incentives for long-term commitments


### Revenue Streams

- **Transaction Fees**: Small percentage on rent payments processed
- **Premium Support**: Priority customer support for higher tiers
- **White-Label Solutions**: Custom branding for large property management companies
- **Marketplace Integration**: Commission from vendor partnerships


### Multi-Currency Support

- **Global Payment Processing**: Support for major currencies (USD, EUR, GBP, CAD)
- **Localized Pricing**: Regional pricing strategies
- **Currency Conversion**: Real-time exchange rates for international properties
- **Tax Compliance**: Automated tax calculations for different jurisdictions


## Integration Possibilities

### Payment Gateways

- **Stripe**: Primary payment processor with ACH, credit cards, and international payments
- **PayPal**: Alternative payment option for tenant convenience
- **Bank Integration**: Direct bank transfers and automated clearing house (ACH)
- **Cryptocurrency**: Bitcoin and stablecoin payment options


### Calendar & Scheduling

- **Google Calendar**: Synchronization for maintenance and showing schedules
- **Calendly**: Automated scheduling for property viewings
- **Outlook Integration**: Enterprise calendar synchronization
- **iCal Support**: Universal calendar format compatibility


### Smart Home & IoT

- **Smart Lock Integration**: Keyless entry management
- **Utility Monitoring**: Smart meter integration for usage tracking
- **Security Systems**: Integration with security cameras and alarms
- **HVAC Control**: Remote temperature and climate management


### Communication & Notifications

- **SMS Gateway**: Twilio for text message notifications
- **Email Services**: Transactional and marketing email automation
- **Push Notifications**: Mobile app notifications for important updates
- **Video Conferencing**: Zoom/Teams integration for virtual tours


## Application Architecture & Module Structure

### Core Modules

**1. Authentication & User Management**

- User registration and login
- Role-based access control
- Profile management
- Password reset and security


**2. Property Management**

- Property CRUD operations
- Unit management and configuration
- Photo and document management
- Availability and pricing management


**3. Tenant Management**

- Tenant profiles and applications
- Lease management and digital signing
- Communication and messaging
- Tenant portal and self-service features


**4. Financial Management**

- Payment processing and tracking
- Financial reporting and analytics
- Expense management
- Tax document generation


**5. Maintenance & Operations**

- Work order management
- Vendor management and scheduling
- Asset tracking and inventory
- Preventive maintenance scheduling


**6. Reporting & Analytics**

- Dashboard and KPI tracking
- Financial reports and statements
- Occupancy and performance metrics
- Custom report generation