Web Server Requirements ======================= This document specifies component-level requirements for the web server functionality, enabling user interface, configuration, and WiFi setup capabilities. Component Overview ------------------ The web server component provides HTTP-based user interface and configuration capabilities. These requirements refine the high-level system requirement :need:`REQ_SYS_WEB_1`. Functional Requirements ----------------------- .. req:: Real-time Status Display :id: REQ_WEB_1 :links: REQ_SYS_WEB_1 :status: approved :priority: mandatory :tags: web, ui, monitoring **Description:** The system SHALL provide a web page that displays current system status with real-time updates for user monitoring. **Rationale:** Users need to monitor the device's operation remotely via web interface without requiring physical access. **Acceptance Criteria:** - AC-1: Main page SHALL display current system status - AC-2: Status values SHALL update with reasonable responsiveness - AC-3: Page SHALL indicate system state (normal, error, warning) - AC-4: Page SHALL be accessible via web browser on mobile and desktop devices .. req:: Configuration Interface :id: REQ_WEB_2 :links: REQ_SYS_WEB_1, REQ_CFG_JSON_7 :status: approved :priority: mandatory :tags: web, ui, configuration **Description:** The system SHALL provide a web page for configuring device parameters as defined in the configuration management requirements. **Rationale:** Users need to adjust device settings remotely without firmware recompilation or physical access. **Acceptance Criteria:** - AC-1: Settings page SHALL display all user-configurable parameters - AC-2: Settings page SHALL validate user input ranges before submission - AC-3: Settings page SHALL provide immediate feedback on invalid inputs - AC-4: Settings page SHALL confirm successful parameter updates - AC-5: Settings page SHALL handle configuration save errors gracefully .. req:: WiFi Setup Interface :id: REQ_WEB_3 :links: REQ_SYS_NET_1 :status: approved :priority: mandatory :tags: web, wifi, network **Description:** The system SHALL provide a captive portal WiFi setup page for initial network configuration. **Rationale:** Users need an intuitive method to configure WiFi credentials without serial console access or hardcoded credentials. **Acceptance Criteria:** - AC-1: Device SHALL start in AP mode when WiFi credentials are not configured - AC-2: WiFi setup page SHALL display available WiFi networks (SSID scan) - AC-3: WiFi setup page SHALL accept SSID and password input - AC-4: WiFi credentials SHALL be saved to NVS and validated on next boot - AC-5: WiFi setup page SHALL provide feedback on save success/failure - AC-6: Device SHALL switch to STA mode after successful WiFi configuration on next boot .. req:: Configuration REST API :id: REQ_WEB_CONF_1 :links: REQ_SYS_WEB_1, REQ_SYS_CFG_1 :status: approved :priority: mandatory :tags: web, api, config **Description:** The web server SHALL provide REST API endpoints for device configuration management. **Rationale:** Web interface needs standardized API to read and modify device configuration values stored in NVS. **Acceptance Criteria:** - AC-1: GET /api/config SHALL return all current configuration values as JSON - AC-2: POST /api/config SHALL accept configuration updates as JSON payload - AC-3: POST /api/config/reset SHALL trigger factory reset of configuration - AC-4: API SHALL integrate with configuration manager component - AC-5: API SHALL return appropriate HTTP status codes (200 OK, 400 Bad Request, 500 Internal Server Error) - AC-6: Configuration changes SHALL be persisted to NVS immediately - AC-7: Device SHALL restart after configuration changes for consistency .. req:: Schema-Driven Configuration Form :id: REQ_WEB_SCHEMA_1 :links: REQ_WEB_CONF_1, REQ_SYS_WEB_1 :status: approved :priority: optional :tags: web, ui, config **Description:** The web interface SHOULD dynamically generate configuration forms from schema definition. **Rationale:** Dynamic generation eliminates manual HTML maintenance and ensures UI stays in sync with configuration structure. **Acceptance Criteria:** - AC-1: Web server SHALL serve configuration schema as static file (e.g., /config_schema.json) - AC-2: Browser JavaScript SHALL fetch schema and generate form fields dynamically - AC-3: Form fields SHALL match parameter types from schema (text, password, number, checkbox) - AC-4: Browser SHALL validate inputs based on schema constraints before submission - AC-5: Invalid inputs SHALL display clear error messages to user .. req:: Web Interface Navigation :id: REQ_WEB_4 :links: REQ_SYS_WEB_1 :status: approved :priority: mandatory :tags: web, ui, navigation **Description:** The system SHALL provide navigation between multiple web pages (status, settings, WiFi setup). **Rationale:** Users need to access different functionality areas without memorizing URLs. **Acceptance Criteria:** - AC-1: All pages SHALL include navigation menu or links - AC-2: Navigation SHALL clearly indicate current page - AC-3: Navigation SHALL be accessible on mobile devices - AC-4: Page URLs SHALL be intuitive and RESTful (e.g., `/`, `/settings`, `/wifi`) .. req:: HTTP Server Concurrency :id: REQ_WEB_5 :links: REQ_SYS_WEB_1 :status: approved :priority: mandatory :tags: web, performance **Description:** The web server SHALL handle multiple simultaneous HTTP connections without blocking. **Rationale:** Multiple users or browser tabs may access the device simultaneously. **Acceptance Criteria:** - AC-1: Web server SHALL support at least 4 concurrent connections - AC-2: Server SHALL respond to new connections within 2 seconds under load - AC-3: Server SHALL not crash or hang under concurrent access - AC-4: Connection handling SHALL not interfere with real-time system operation Non-Functional Requirements ---------------------------- .. req:: Web UI Responsiveness :id: REQ_WEB_NF_1 :links: REQ_WEB_1, REQ_WEB_2 :status: approved :priority: optional :tags: web, performance, ux **Description:** Web pages SHOULD load and render within 3 seconds on typical mobile/desktop browsers. **Rationale:** Responsive UI improves user experience and reduces perceived latency. **Acceptance Criteria:** - AC-1: Initial page load SHALL complete within 3 seconds (excluding network latency) - AC-2: Navigation between pages SHALL feel instantaneous (<500ms) - AC-3: AJAX updates SHALL not cause page flickering or layout shifts .. req:: Mobile-First Design :id: REQ_WEB_NF_2 :links: REQ_WEB_1, REQ_WEB_2, REQ_WEB_3 :status: approved :priority: optional :tags: web, ui, mobile **Description:** Web interface SHOULD be optimized for mobile devices with responsive design. **Rationale:** Many users will access the device from smartphones in the field. **Acceptance Criteria:** - AC-1: UI SHALL be usable on screens as small as 320px width - AC-2: Touch targets SHALL be at least 44x44px for mobile usability - AC-3: Text SHALL be readable without zooming on mobile devices Traceability ------------ All traceability is automatically generated by Sphinx-Needs based on the `:links:` attributes in each requirement. .. needtable:: :columns: id, title, status, tags .. needflow:: REQ_WEB_1