Web Interface Guide
Relevant source files
The following files were used as context for generating this wiki page:
Introduction
The Rosy Web Interface serves as the primary user-facing layer for the AI-powered tax document processing system. It provides a streamlined workflow for taxpayers to upload financial documents, review AI-extracted data, and generate completed tax forms. The interface is built as a Single Page Application (SPA) architecture, utilizing a vanilla JavaScript frontend that communicates with a Flask-based REST API.
The guide covers the components responsible for document ingestion, real-time status reporting, interactive data validation, and the finalization of Form 1040 documents.
Sources: README.md:9-16, backend.py:15-18
System Architecture & Data Flow
The web interface acts as the entry point for the processing pipeline. Data flows from the user's local machine through the backend orchestration layer and back to the user as a processed PDF.
The diagram above illustrates the request-response lifecycle between the web interface and the backend processing modules.
Sources: frontend/app.js:1-60, backend.py:65-95, pipeline.py:44-55
Core Components
Document Upload Interface
The upload section allows users to submit multiple files (PDF, TXT, PNG, JPG) simultaneously. Users must also specify their filing status and optional withholding amounts which are used to initialize the tax calculation engine.
| Element | Type | Description |
|---|---|---|
filing_status | Select | Options: Single, Married. Used for standard deduction selection. |
withholding | Input (Number) | Optional manual withholding override. |
files | Input (File) | Multiple file selection for W-2 or 1099 documents. |
upload-form | Form | Triggers the async processing sequence. |
Sources: frontend/index.html:13-28, frontend/app.js:6-21
Interactive Review & Editing
Upon successful processing, the interface dynamically generates a review UI. This allows users to inspect the AI's "confidence" scores and manually correct any misidentified fields before the final tax calculation.
- Per-File Parsing: Each uploaded document is displayed in a dedicated box showing the detected document type (e.g., W-2, 1099) and its specific fields.
- Real-time Updates: The
Save changesbutton updates the client-side state and triggers a re-render of the "Aggregated Preview" section. - Field Mapping: Input fields are dynamically generated based on the keys returned in the
pf.fieldsobject from the backend.
Sources: frontend/app.js:46-85, pipeline.py:17-38
Finalization and PDF Generation
The final stage of the web interface workflow is the "Finalize & Download" action. This sends the validated and potentially edited data back to the server to produce the final document.
This sequence ensures that the final PDF reflects any manual corrections made by the user during the review phase.
Sources: frontend/app.js:100-116, backend.py:114-153
API Integration
The frontend interacts with the following primary endpoints defined in the backend:
1. File Processing (POST /upload)
- Payload:
multipart/form-datacontaining files and metadata. - Logic: Sanitizes filenames and passes them to the
run_pipeline_on_pathsfunction. - Response: Returns a JSON object containing
doc_type,confidence,per_fileresults, and an initialtax_estimate.
Sources: backend.py:65-101, frontend/app.js:25-39
2. PDF Finalization (POST /finalize)
- Payload:
application/jsoncontaining the editedper_filefield data. - Logic: Aggregates the edited values, recomputes the final tax liability using
compute_tax_estimate, and fills the PDF template. - Response: Binary stream of the generated PDF file.
Sources: backend.py:114-153, frontend/app.js:103-107
Styling and Layout
The interface utilizes a clean, centered layout optimized for document management.
- Max Width: 900px for readability.
- Visual Feedback: The
#statuselement provides asynchronous updates (e.g., "Uploading...", "Processing complete") usingaria-live="polite"for accessibility. - Code Previews: Aggregated data and tax estimates are rendered within
<pre>blocks for technical transparency during the prototype phase.
Sources: frontend/static.css:1-6, frontend/index.html:30, frontend/app.js:43-52
Conclusion
The Web Interface Guide demonstrates a modular approach to tax document processing. By separating the initial extraction from the final generation, the system allows for a "human-in-the-loop" validation step, ensuring high accuracy in the final Form 1040 production. The interface handles the complexities of asynchronous file processing and binary data management to provide a seamless user experience.