# Difference Equation Analyzer (DEA) - Architecture & Functionality ## Overview DEA is a specialized tool for designing, visualizing, and validating discrete-time filters. It bridges the gap between theoretical filter design (floating-point) and hardware implementation (fixed-point/MCU). ## 🏗 System Architecture ### 1. Backend (Python 3.12 + FastAPI) The backend is responsible for heavy mathematical computations and data processing. - **API Entry (`dea_api.py`)**: Routes requests to appropriate modules and serves the Vue.js frontend from `static/`. - **Computation Engine (`dea/`)**: - `filter_design.py`: Uses `scipy.signal` to calculate coefficients for various filter topologies. - `bode.py`: Computes magnitude and phase response. Supports comparing "Ideal" (float) vs "Fixed" (quantized) responses. - `csv_processing.py`: Processes time-domain CSV data. It applies the current filter to the signal and downsamples the result for efficient visualization. - `validation.py`: Protects against unstable filter designs and invalid inputs. ### 2. Frontend (Vue 3 + Vite + Tailwind) A reactive "Single Page Application" (SPA) approach. - **Reactive Logic (`src/app-options.js`)**: - Manages the state of all coefficients. - Implements "Fine-tuning" sliders that allow real-time adjustment of poles/zeros. - Handles Fixed-Point conversion logic (Q-format shifting). - **UI Components (`src/App.vue`)**: - **Control Sidebar**: Interactive inputs for all filter parameters. - **Visualization**: Dual-plot system using Plotly.js for Bode plots and Time-domain waveforms. - **Hardware Bridge**: Uses the **Web Serial API** to send commands directly to connected MCUs (requires HTTPS). ## 🚀 Execution Flow 1. **Design**: User selects a filter type or enters coefficients manually. 2. **Quantize**: User adjusts Q-format bits to see how quantization affects the frequency response. 3. **Verify**: User uploads a CSV to see how the filter behaves with real-world signals. 4. **Deploy**: User clicks "Write to MCU" to send the coefficients to their hardware. ## 🛠 Tech Stack - **Backend**: FastAPI, NumPy, SciPy, Pandas, Uvicorn. - **Frontend**: Vue 3, Vite, Tailwind CSS, Plotly.js. - **Security**: Restricted to LAN/Loopback; implemented security headers and HTTPS support.