PRD-65: Branded Document Templates v2
Status: Parked (TODO) Priority: P2 — Enhancement (bells & whistles) Created: 2026-02-25 Dependencies: PRD-63 (Document Generation Module), PRD-08 (RAG/Document System) Estimated Effort: MVP 20h | Full 36h
Executive Summary
PRD-63 delivered the document generation pipeline (PDF/DOCX/XLSX via WeasyPrint + Jinja2). Templates exist in the database with HTML, JSON schemas, and sample data. But the LLM has no awareness of available templates or their schemas, rendering the template system decorative. Additionally, templates are generic — users cannot brand them with their company identity (logo, colors, header/footer, address).
This PRD upgrades templates from "developer-seeded HTML" to a user-owned branded document system where every generated report, invoice, and export carries the user's professional identity.
Problem Statement
Current State (PRD-63 shipped)
5 seed templates exist (Basic Report, Invoice, Executive Summary, Meeting Notes, Data Export)
Templates have
data_schema(JSON Schema) defining required fieldsTemplates have
template_content(HTML+CSS with Jinja2 tags)LLM calls
generate_document(title, format, data, template_name?)toolTemplates tab shows templates in the UI (CRUD works)
What's Broken
LLM is blind to templates — The
generate_documenttool description is static. The LLM doesn't know which templates exist in the workspace, what schemas they expect, or when to use each one. It always dumps data into{sections: [{title, content}]}regardless of template.No branding — Templates use generic Automatos styling. Users can't upload their logo, set company colors, define headers/footers, or add their address/contact info.
No template designer — Creating/editing templates requires writing raw HTML+CSS and JSON Schema. No visual builder, no preview, no drag-and-drop.
No data source integration — Templates can't pull data from RAG, connected apps (accounting, CRM), or database queries. The LLM must manually research and populate every field.
Goals
G1: LLM Template Awareness
The LLM must know which templates exist, understand their schemas, and select the right template for the task.
G2: Company Brand Identity
Users upload their logo, set brand colors, company name/address, and this identity is automatically applied to every generated document.
G3: Template Designer (Phase 2)
Visual template editor with live preview — no HTML/CSS knowledge required.
G4: Data Source Binding (Phase 3)
Templates can declare data sources (RAG collections, connected apps, SQL queries) that auto-populate fields before generation.
Technical Design
Phase 1: LLM Awareness + Brand Identity (MVP)
1a. Dynamic Tool Description
When building the tool list for an agent, query the workspace's active templates and inject them into the generate_document tool description:
This approach costs zero extra tool calls — the LLM sees templates in the tool description and picks the right one.
1b. Brand Identity Model
New database model workspace_brand:
1c. Brand Injection into Templates
All templates get automatic brand injection at render time:
{{ brand.logo }}— base64 data URI for the company logo{{ brand.company_name }},{{ brand.address }}, etc.CSS variables:
--brand-primary,--brand-secondary,--brand-accent,--brand-fontDefault header: logo + company name + document title + date
Default footer: company address + page number + "Generated by Automatos AI"
Templates can override header/footer or use the workspace default.
1d. Logo Upload API
Logo stored in S3: workspaces/{workspace_id}/brand/logo.{ext}
1e. Frontend: Brand Settings Page
Settings > Brand Identity:
Logo upload (drag & drop, crop/resize)
Company details form (name, address, email, phone, website)
Color picker (primary, secondary, accent)
Font selector
Live preview showing a sample document with current branding
Phase 2: Template Designer (Visual Editor)
Drag-and-drop section builder (header, metrics row, text section, table, chart, footer)
Live HTML preview powered by the actual Jinja2 renderer
Schema auto-detection from template variables
Template marketplace: share/import templates between workspaces
Version history with diff view
Phase 3: Data Source Binding
Templates declare
data_sourcesin their schema:Before generation, the system auto-executes each data source and merges results into the template data
LLM can still override/supplement auto-populated data
Expanded Template Library (Target: 20+)
Reports
Basic Report (exists)
Executive Summary (exists)
Quarterly Business Review
Project Status Report
Competitive Analysis
Market Research Report
Technical Specification
Financial
Invoice (exists)
Expense Report
Budget Summary
Financial Statement
Quote / Estimate
Operations
Meeting Notes (exists)
SOW (Statement of Work)
Project Proposal
Onboarding Checklist
Incident Report / Post-Mortem
Data
Data Export (exists)
Analytics Dashboard (PDF with charts)
KPI Scorecard
Survey Results Summary
Legal / Compliance
NDA Template
Terms of Service
Privacy Policy Summary
Success Metrics
LLM selects correct template
>80% of document generation requests
Brand identity configured
>50% of active workspaces
Template usage (non-Basic Report)
>40% of generated documents
User-created custom templates
>1 per active workspace
Implementation Order
Phase 1a: Dynamic tool description with template awareness (4h)
Phase 1b-c: Brand identity model + injection (8h)
Phase 1d: Logo upload API + S3 storage (4h)
Phase 1e: Frontend brand settings page (6h)
Expand template library to 20+ templates (8h)
Phase 2: Visual template designer (20h — separate sprint)
Phase 3: Data source binding (16h — separate sprint)
Non-Goals (for this PRD)
WYSIWYG document editor (Google Docs-style) — too complex, not needed yet
Real-time collaborative template editing — single-user is sufficient
Template versioning with rollback — v1 just overwrites
Print-to-PDF from browser — server-side WeasyPrint is the renderer
Open Questions
Should brand settings live at workspace level or organization level?
Do we need template permissions (admin-only vs all members can edit)?
Should the expanded template library be seeded per workspace or pulled from a shared marketplace?
Last updated

