> ## Documentation Index
> Fetch the complete documentation index at: https://docs.khanhng.com/llms.txt
> Use this file to discover all available pages before exploring further.

# 1.2 Introduction and Goals

> Understand Report Automation Tool's current behavior, intended goals, requirements, quality targets, and stakeholders.

## Report Automation Tool

| Information | Description |
| - | - |
| Main Goal | Generate approved, auditable, high-quality standard reports for IoT devices. The current implementation processes only the first device in a request. |
| Business Domain | Stand-alone WebAPI Service |
| Size | Small Client-specific requirement service - single maintainer |
| Strategic Decision | <ul><li>Durable Functions orchestration of separate report-generation and email activities</li><li>Web automation</li><li>Rule-based PDF generation</li></ul> |
| Technologies | <ul><li>Azure Durable Functions</li><li>Azure Storage Account</li><li>Nodemailer SMTP Mailing</li><li>Puppeteer</li><li>Javascript</li></ul> |

## 1.2.1 Introduction

This document describes the Report Automation Tool, a standalone serverless API service that supports report generation for an existing facility management platform.

The service receives report-generation requests from corporate clients and produces auditable reports for IoT devices. Reports include temperature metrics and counts of readings matching alarm thresholds for the first selected device, an editable PDF format for recording actions, and sign-off fields for review and approval.

The existing orchestration workflow is described as deployed in production for limited client use. The separate `/v1` API contract in this documentation is proposed and has not been recorded as shipped.

## 1.2.2 Requirements

| ID | Requirement | Explanation |
| - | - | - |
| F1 | Perform Web automation to capture 3rd party app data | Perform series of browser task automation to retrieve the essential data for PDF generation |
| F1.1 | Retrieve and download csv data | Retrieve raw data based on user selected time range |
| F1.2 | Take screen capture of essential charts | Retrieve chart images |
| F2 | Orchestrate report generation and email delivery | Validate and process data retrieved from the portal, generate the PDF, then send it by email. |
| F2.1 | Processing csv data | Apply business logic and calculation to derived with metrics |
| F2.2 | Processing screenshots | Ensure image is in defined size and format |
| F2.3 | Retrieve client brand logo | Retrieve client brand logo and validate |
| F2.4 | Generate HTML from csv data and processing screenshots | Generate HTML based on processed data and images reference approved client's HTML template |
| F2.5 | Convert HTML to PDF | Utilizing Puppeteer to generate PDF from HTML |
| F2.6 | Send reports via email to user | Ensure reports are sent in batch with retry mechanism |

> F: Functional Requirements

## 1.2.3 Architecture quality goals

There are 3 quality goals that  drive the architecture decisions in this document

| ID | Priority | Quality Goal | Description |
| - | - | - | - |
| QG-1 | 1 | Accuracy | A valid request produces a PDF containing chart, temperature, and alarm information for the requested device and period following client approved report design |
| QG-2 | 2 | Real-time & Durable | Target: complete report generation before email delivery and prevent delivery of an invalid report. The current orchestrator catches activity errors without explicitly propagating failure, so this guarantee requires verification and remediation. |
| QG-3 | 3 | Availability | Run requests on schedule and demand during business hour |

## 1.2.4 Stakeholders

| Role | Responsibility | Expectation |
| - | - | - |
| Report requester | Receive a useful device report by email. | Simple UI to generate report and being able to receive correct report timely |
| System operator | Deploy, configure, monitor, and troubleshoot the Azure Functions application. | Being able scale to 0 at certain timeframe to save company cost |
| Security owner | Control credentials, report data, and caller access. | Authenticate and authorization based on RBAC configuration |
| Product owner | Define supported devices, report semantics, and service objectives. | Promote this new feature and gather feedback from user |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.