Feature Specification: Template Configuration
1. Overview & Vision
Template Configuration is the design-time interface for automated reporting. It allows admins to define the "How" and "What" of a report by selecting data sources and providing custom LLM instructions, enabling the platform to generate consistent, professional summaries without manual intervention.
2. Personas & Stakeholders
| Persona | Goal |
|---|---|
| Admin | Create reusable report blueprints for the organization. |
| Executive | Receive structured insights tailored to their specific needs. |
| Developer | Define new data source endpoints for the template engine. |
3. User Stories
- As an admin, I want to create a "Weekly Hiring" template that ingests HRM data so I don't have to write it manually every Monday.
- As an admin, I want to provide a specific system prompt (e.g., "Be concise and use bullet points") to control the AI's tone.
- As a manager, I want to preview a report before activating its schedule.
4. Functional Requirements (FR)
- REQ-TEMP-001: CRUD operations for report templates.
- REQ-TEMP-002: Multi-module data source selection (HRM, Drive, Document).
- REQ-TEMP-003: Custom System Prompt editor with variable support (e.g.,
). - REQ-TEMP-004: Real-time "Preview" generation using sample data.
5. Non-Functional Requirements (NFR)
- Latency: Template saving < 200ms.
- Preview Speed: Sample report generation < 30 seconds.
6. Business Logic & Rules
- Disconnected Inheritance: Changes to a template do not retroactively modify already generated reports.
- Validation: System prompts must not exceed 4000 tokens.
- Draft Status: Templates must be "Active" to be picked up by the scheduler.
7. User Interface (UI/UX)
- Template Editor: Side-by-side view with Source Selection on the left and Prompt Editor on the right.
- Source Picker: Tree-style selection of available module endpoints.
- Preview Panel: Modal window showing the Markdown output of the AI.
8. Information Architecture
- "Templates" tab in the Auto Report dashboard.
- Part of the primary navigation for the reporting module.
9. Data Model & Persistence
- Table:
report_templates. - Fields:
name,description,sources(jsonb),system_prompt,status.
10. API & Service Layer
GET /templatesPOST /templatesPOST /templates/:id/preview
11. Integration Patterns
- Module Discovery: Fetches available data sources from the Shell Registry.
- OpenAI: Uses GPT-4o-mini for the preview generation.
12. Security & Permissions
- RBAC:
reports:managerequired to create or edit templates. - Isolation: Templates are strictly scoped to the
organizationId.
13. Error Handling & Resilience
- Invalid Sources: Alert the admin if a selected data source endpoint is unreachable.
- Prompt Error: Validation for empty or malicious prompt injections.
14. Performance & Scalability
- Metadata is cached in the API layer.
- Preview requests are rate-limited to prevent LLM cost spikes.
15. Globalization & i18n
- Multi-language support for template names and descriptions.
16. Accessibility (a11y)
- Accessible form fields with proper error messaging (Aria-invalid).
17. Observability & Analytics
- Tracking of "Generation Success Rate" per template.
18. Testing & Quality
- Integration tests for the preview pipeline.
- Schema validation for the
sourcesJSON field.
19. Constraints & Assumptions
- Assumes that satellite modules expose a standard JSON reporting endpoint.
20. Future Enhancements
- Visual "Drag-and-Drop" prompt builder.
- Community template gallery (Public templates shared across orgs).