Forms 4 Landlords - Project Documentation
1. Project Overview
Forms 4 Landlords is a web-based platform designed to simplify the process of creating and managing landlord forms across different Canadian provinces. The platform provides an intuitive interface for landlords to access, customize, and generate legally compliant PDF forms with province-specific requirements.
2. System Architecture
2.1 High-Level Architecture
3. Key Components
3.1 Frontend Components
Main Interface (index.html)
- Responsive design with modern UI/UX using custom CSS
- Interactive navigation with GSAP animations
- Dynamic form selection interface with hierarchical navigation
- Custom cursor implementation for enhanced interactivity
- Isotope layout for dynamic grid arrangement
- Lottie animations for visual feedback
Form Selection System
┌─────────────────────────────────────────┐
│ Province Selection │ ◄── provinces array with 10 Canadian provinces
└─────────────────────────────────────────┘
▼
┌─────────────────────────────────────────┐
│ Category Selection │ ◄── issuesStructure[province] categories
└─────────────────────────────────────────┘
▼
┌─────────────────────────────────────────┐
│ Subcategory Selection │ ◄── issuesStructure[province][category] subcategories
└─────────────────────────────────────────┘
▼
┌─────────────────────────────────────────┐
│ Issue Selection │ ◄── issuesStructure[province][category][subcategory] issues
└─────────────────────────────────────────┘
3.2 Backend Services
Form Management
- Dynamic form loading based on province and form code
- Serves form HTML and JSON content files
- Routes:
/get-form- Serves form content with metadata/search-forms- Handles form search requests/issues-structure- Provides hierarchical form structure data
Authentication System
- Firebase Authentication for user management
- Client-side auth using firebase-client-auth.js
- Server-side auth validation with Firebase Admin SDK
- Local persistence for session management
3.3 Data Structure
Firebase Data Structure
users/
├── _config/
│ └── subscriptionFields
└── [user_email]/
├── email
├── firstName
├── lastName
├── createdAt
├── subscriptions/
│ └── [province_formId]/
│ ├── startDateTime
│ ├── endDateTime
│ ├── formId
│ ├── province
│ └── autoRenew
└── accessHistory/
└── forms/
└── [province_formId]/
├── formId
├── province
├── lastAccessed
├── accessCount
└── accessLog
4. Technical Features
4.1 User Interface
Responsive Layout
- Mobile-first approach with fluid design
- Custom CSS with advanced positioning and effects
- Interactive elements with hover effects
Animation Systems
- GSAP animations for scroll effects and transitions
- ScrollTrigger plugin for scroll-based animations
- Lottie animations for decorative elements
Dynamic Components
- Custom cursor implementation with trail effect
- Isotope layout for form category grid system
- Dynamic navigation with smooth scrolling
4.2 Form Management
Form Selection Flow
Province Selection → Category Selection → Subcategory Selection → Issue Selection → Form Display
Search Functionality
- Real-time form search with server-side processing
- Province-specific search filtering
- Visual display of search results with form previews
Form Generation Process
┌───────────────┐ ┌───────────────┐ ┌───────────────┐ │ Form Input │ │ PDF Filling │ │ PDF Output │ │ Collection │────►│ (PDFLib.js) │────►│ Generation │ └───────────────┘ └───────────────┘ └───────────────┘
PDF Processing
- Client-side PDF generation using PDFLib.js
- Coordinate-based form filling for exact field positioning
- Support for text, dates, checkboxes, and signature images
- Watermarking based on subscription status
4.3 Subscription System
Subscription Management
- Hierarchical subscription tiers with different access levels
- Stripe integration for payment processing
- Per-form subscription management
- Access control based on subscription status
Access Control Flow
┌───────────────┐ ┌───────────────┐ ┌───────────────┐
│ Form Request │ │ Access Check │ │ Result │
│ │────►│ (Firebase) │────►│ Determination│
└───────────────┘ └───────────────┘ └───────────────┘
│
┌───────────────┐ │
│ Full Access │◄───Subscribed
│ (Download) │
└───────────────┘
│
▼
┌───────────────┐
│ Limited Access│◄───Not Subscribed
│ (Preview) │
└───────────────┘
5. Security Considerations
5.1 Authentication
- Firebase Authentication with email/password
- Secure token management with Firebase SDK
- Role-based access control for administrative functions
- Client persistence with
firebase.auth.Auth.Persistence.LOCAL
5.2 Data Protection
- Form data processing occurs client-side for privacy
- Secure API endpoints with server-side validation
- Input validation and sanitization before processing
- Firebase security rules to enforce data access control
6. Performance Optimization
6.1 Frontend
- CSS optimizations with critical styles loaded first
- Deferred script loading for non-critical resources
- Efficient state management with vanilla JavaScript
- Dynamic loading of form components
6.2 Backend
- Efficient PDF processing with client-side generation
- Static asset delivery for core form templates
- Optimized Firebase queries with specific document references
- Request batching for related data operations
7. Current Implementation Details
7.1 Form Selection Implementation
- Province selection from predefined array of 10 Canadian provinces
- Dynamic loading of categories based on issuesStructure[province] data
- Selection summary breadcrumb navigation for easy hierarchy traversal
- Tag-based categorization for direct forms and regular categories
7.2 Form Generation Implementation
- HTML forms with client-side validation for data collection
- PDFLib.js for client-side PDF generation without server roundtrip
- Coordinate-based text placement system for precise form filling
- Base64 encoding of generated PDFs for direct browser display
7.3 Subscription Implementation
- Firebase Firestore database for subscription storage
- Document structure with users/{email}/subscriptions/{formId} pattern
- Subscription checking via SubscriptionCheck class
- Multiple subscription tiers with different access levels
- Access tracking in users/{email}/accessHistory for usage statistics
8. Deployment Architecture
┌─────────────────────────────────────────────────────────────────┐
│ Deployment Flow │
├─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ Development │ │ Staging │ │ Production │
│ (Local/Dev) │◄───►│ (Testing) │◄───►│ (Live) │
└─────────────────┘ └─────────────────┘ └─────────────────┘
▲ ▲ ▲
│ │ │
└──────────────────────┴──────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────┐
│ Monitoring │
├─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ Error Tracking│ │ Performance │ │ Analytics │
│ (Console Logs) │◄───►│ (Metrics) │◄───►│ (User Stats) │
└─────────────────┘ └─────────────────┘ └─────────────────┘
Last Updated: