IFA Letter Generator. Build Progress

A comprehensive overview of everything built so far and what's coming next. This document is auto-generated from the current state of the application.

41

Letter Templates

14

Database Tables

8

Template Categories

15

SAF Reference Docs

3

User Roles

30+

RLS Policies

Live

AI Extraction

What does it do?

The IFA Letter Generator automates the creation of compliant client letters for an Independent Financial Adviser firm's operations team. It reduces document processing time from ~1 hour to a few minutes.

The core workflow:

  1. Staff uploads an adviser's meeting note (drag & drop or paste)
  2. AI identifies the correct template from 41 options and extracts client details, fund information, and adviser data. With confidence scores
  3. Staff reviews the pre-filled smart form, adds personal touches, and submits
  4. Compliance reviews the letter section-by-section, approves or requests amendments
  5. Final .docx is generated and available for download

Key Architecture & Security

  • Privacy-first AI: Meeting notes are processed transiently. Never stored. Browser-side PII masking is active, replacing personal identifiers with placeholders before AI processing.
  • Row-Level Security: 30+ RLS policies ensure staff only see their own letters, compliance sees all, admin has full access.
  • Role-based access: Three roles (Staff, Compliance, Admin) with route-level and data-level protection.
  • Structured AI extraction: Uses tool calling (not free-text) for reliable, typed extraction results with per-field confidence scores.
  • Immutable audit log: All actions logged, records cannot be modified or deleted.

Build Phases

Phase 1. Foundation

Complete
  • Parsed and catalogued all 56 source documents (41 letter templates + 15 SAF reference docs)
  • Designed and deployed full production database schema. 14 tables with Row-Level Security
  • 3 private storage buckets configured (meeting-notes, generated-docs, saf-documents)

Phase 2. Data Seeding & Authentication

Complete
  • Seeded 8 template categories (Post-Review, Fund Switches, Pension Accessing, etc.)
  • Seeded all 41 letter template records with metadata, slugs, and versioning
  • Seeded 15 SAF reference document records with descriptions and versions
  • Full authentication system. Login, signup, password reset with email verification
  • Role-based access control (Staff, Compliance, Admin) with protected routes
  • Auto-created user profiles on signup with role-aware dashboard routing

Phase 3. Core UI & Dashboards

Complete
  • Staff Dashboard. Real letter data, stats cards (total, awaiting review, approved), clickable rows to edit
  • Compliance Dashboard. Review queue showing letters awaiting review with Review action
  • Admin Dashboard. User & role management with invite and role assignment
  • Responsive navigation with role-based links, user context, and mobile hamburger menu
  • 5 compliance & policy pages (Data & AI, AI Safety, How It Works, Privacy, Data Protection)

Phase 4. AI-Powered Letter Creation

Complete
  • Meeting note upload. Paste text with personal touches field
  • AI extraction edge function. Gemini 3 Flash via Lovable AI gateway with structured tool calling
  • Confidence scoring on every extracted field (green ≥70%, amber <70%) with 'Edited' badges
  • Template matching against all 41 templates using structured AI tool calling
  • Smart form editor with pre-filled fields and inline override tracking
  • Submit for compliance review flow (status transition + history recording)

Phase 5. Compliance Review

Complete
  • Review queue with real data. Letters with awaiting_review status
  • Section-by-section review interface with variable display and low-confidence highlighting
  • Inline commenting per section (stored as JSON in compliance_reviews table)
  • Approve / Request Amendments workflow. Updates letter status, records history
  • Amendment feedback displayed on EditLetter page. Overall comments + section-level feedback with reviewer name
  • RLS policies converted from RESTRICTIVE to PERMISSIVE for multi-role access

Phase 6. Document Generation

Complete
  • .docx generation edge function using npm:docx with KBA plum/burgundy branding
  • Document download via signed URL. available at any letter status
  • Generated documents stored in private generated-docs bucket
  • Draft watermark header ('DRAFT. NOT FOR DISTRIBUTION') for non-approved letters
  • Branded headers, footers, section headings, and variable interpolation

Phase 7. Polish & Production

Complete
  • Audit log UI for compliance/admin
  • Notification system (letter submitted, reviewed, etc.)
  • Status filter tabs on Staff Dashboard
  • Mobile responsiveness review
  • Security hardening review
  • Performance optimisation

Phase 8. What's Next

Upcoming
  • Email notifications. Alert staff on review outcomes, notify compliance on new submissions
  • Template editor. Admin UI for creating and editing letter templates without SQL
  • Analytics dashboard. Letter volumes, approval rates, average review times, team productivity
  • Bulk letter creation. CSV upload to generate multiple letters from one template
  • Version history & diff. Track every edit with visual comparison between versions
  • PII masking for audit logs. Redact client names and addresses in audit trail entries
  • Template versioning. Existing letters keep their original template version on updates
  • Export & reporting. Monthly compliance summary PDFs for management oversight

Generated from the current application state · IFA Letter Generator