How nickysemenza/ingredient-parser works
Project Type and Purpose
• This is a Rust‐centric monorepo containing:
– Core libraries for fetching and parsing recipe data.
– Multiple consumer apps: CLI (food_cli), TUI/desktop UI (food_ui), a Trunk‐based web app (food_web), and a React+WASM demo (demo-site).
• Purpose: scrape recipe pages (recipe-scraper, recipe_scraper_fetcher), parse ingredient lines (ingredient-parser), and expose functionality via CLIs, UIs, and web frontends (including WASM builds).
File Structure
• Top-level crates (each a Cargo workspace member):
– ingredient-parser/ – core parsing library + unit testing.
– recipe-scraper/ & recipe_scraper_fetcher/ – HTML/JSON-LD scraper + HTTP utilities.
– ingredient-wasm/ – builds ingredient-parser to WebAssembly for browser use.
– food_cli/, food_ui/ – command-line and desktop UI frontends linking core libs.
– food_web/ – Rust/WASM web app served via Trunk.
• Standalone frontend:
– demo-site/ – React+TypeScript + Vite, consuming ingredient-wasm via wasmContext.
README for Additional Insights
• The main README points to ingredient-parser/readme.md for detailed API docs.
• CI/CD workflows target Rust tests (.github/workflows/rust.yml) and demo-site deployment.
Main Components & Interactions
a. Core Library Layer
• recipe_scraper_fetcher: HTTP client utilities (fetch raw HTML).
• recipe-scraper: parse scraped HTML + JSON-LD into structured recipe objects.
• ingredient-parser: tokenize and parse ingredient‐line strings into structured data.
b. WASM Bridge
• ingredient-wasm: compiles ingredient-parser to WebAssembly + JS glue.
c. Application Layer
• food_cli: CLI entrypoint; uses scraper + parser to fetch & display recipes.
• food_ui: possibly a TUI or desktop UI; links the same core libs.
• food_web: Rust/WebAssembly SPA built with Trunk; serves interactive recipe viewer in browser.
• demo-site: React app that imports ingredient-wasm via ES modules; demo UI for browser usage.
d. External Systems
• Recipe websites (NYTimes, SeriousEats, etc.) – HTTP endpoints.
• Browser environment (for web frontends).
Architectural Patterns & Design Principles
• Layering: clear separation between core domain libraries and UIs.
• Modularity: each crate has a single responsibility.
• Cross-compilation: core parsing logic reused in native CLI/UI and WASM.
• Monorepo Workspace: shared CI, versioning, and dependency management (Cargo workspace).