|
| 1 | +# Contributing to AlgoBuddy |
| 2 | + |
| 3 | +Thank you for your interest in contributing to AlgoBuddy. This document outlines the development workflow, project architecture, testing requirements, and submission process for pull requests. |
| 4 | + |
| 5 | +--- |
| 6 | + |
| 7 | +## Development Setup |
| 8 | + |
| 9 | +### Prerequisites |
| 10 | +- Rust 1.75 or later (`rustup update stable`) |
| 11 | +- Cargo (included with standard Rust installation) |
| 12 | +- Trunk (for WebAssembly builds): `cargo install trunk` |
| 13 | +- WASM target: `rustup target add wasm32-unknown-unknown` |
| 14 | + |
| 15 | +### Local Execution |
| 16 | + |
| 17 | +To run the native desktop application: |
| 18 | +```bash |
| 19 | +cargo run |
| 20 | +``` |
| 21 | + |
| 22 | +To run the WebAssembly application locally in a browser: |
| 23 | +```bash |
| 24 | +trunk serve |
| 25 | +``` |
| 26 | +Then navigate to `http://127.0.0.1:8080`. |
| 27 | + |
| 28 | +--- |
| 29 | + |
| 30 | +## Running Tests |
| 31 | + |
| 32 | +All algorithm step generators and parsing logic are validated using automated Rust unit tests. Run the full test suite with: |
| 33 | + |
| 34 | +```bash |
| 35 | +cargo test |
| 36 | +``` |
| 37 | + |
| 38 | +Ensure all tests pass before submitting a pull request. |
| 39 | + |
| 40 | +--- |
| 41 | + |
| 42 | +## Architecture Overview |
| 43 | + |
| 44 | +AlgoBuddy is structured into four core areas: |
| 45 | + |
| 46 | +1. `src/main.rs`: Application entry points for native execution (`eframe::run_native`) and WASM execution (`eframe::WebRunner`). |
| 47 | +2. `src/model.rs`: Problem definitions (`Problem`), category taxonomy (`Category`), difficulty levels (`Difficulty`), metadata specs (`ProblemDetails`), and visual state snapshots (`VisualState`). |
| 48 | +3. `src/app.rs`: Main GUI application state (`VisualizerApp`), UI view modes, navigation, playback controls, canvas renderers, and theme palettes. |
| 49 | +4. `src/algorithms/`: Step snapshot generator functions (`generate_*_steps`) for each algorithm. |
| 50 | + |
| 51 | +### Deterministic State Engine |
| 52 | +Algorithms in AlgoBuddy do not execute asynchronously during playback. Instead, generator functions in `src/algorithms/` execute synchronously upfront and produce a `Vec<Step>` snapshot vector. The GUI renders state snapshots based on the active timeline index (`current_step_idx`), allowing forward and backward scrubbing. |
| 53 | + |
| 54 | +### Release Mode and Audit Gating |
| 55 | +Problems in AlgoBuddy carry an audit status (`AuditStatus::Audited` or `AuditStatus::Unaudited`). |
| 56 | +- By default (Public Release Mode), the UI presents only audited problems. |
| 57 | +- Developer Mode (toggleable in Settings) displays all implemented problems, flagging unaudited implementations with an `[EXP]` tag. |
| 58 | + |
| 59 | +--- |
| 60 | + |
| 61 | +## How to Audit or Promote a Problem |
| 62 | + |
| 63 | +To audit an existing problem visualizer and promote it to Public Release status: |
| 64 | + |
| 65 | +1. Open the application in Developer Mode (`show_unaudited: true`). |
| 66 | +2. Verify that the algorithm step generator produces accurate state snapshots for standard and edge-case inputs. |
| 67 | +3. Ensure active line highlighting (`code_line`) matches the associated source code snippet. |
| 68 | +4. Add a unit test in `src/app.rs` under `#[cfg(test)] mod tests` asserting expected output values. |
| 69 | +5. In `src/model.rs`, update the `audit_status` match arm for the target problem to return `AuditStatus::Audited`. |
| 70 | +6. Run `cargo test` to verify build and test compliance. |
| 71 | + |
| 72 | +--- |
| 73 | + |
| 74 | +## Pull Request Guidelines |
| 75 | + |
| 76 | +1. **Branch Naming**: Use descriptive branch names such as `feat/audit-two-sum` or `fix/canvas-render-bounds`. |
| 77 | +2. **Code Formatting**: Format code using `cargo fmt` before committing. |
| 78 | +3. **Clippy Compliance**: Ensure `cargo clippy --all-targets -- -D warnings` reports zero warnings. |
| 79 | +4. **Test Coverage**: Include unit tests for any new algorithm step generators or parser utilities. |
| 80 | +5. **Commit Messages**: Write concise commit messages following standard conventions (e.g., `feat: add visualizer for problem #X`, `fix: resolve bounds checking on timeline scrubber`). |
0 commit comments