# Project Mycelium - Design & Architecture **Last Updated:** 2025-08-23 10:21:27 (EDT) **Purpose:** Comprehensive architectural vision and complete UX specification (patterns, guidelines, ADRs) for the Project Mycelium. Roadmap and status live in the separate roadmap document. See also: [Roadmap](./projectmycelium-roadmap.md) ## 1. Architecture Vision (Target State) ### Core Design Principles #### **User Experience as Single Source of Truth** - Complete UX specification drives all development priorities - All features must support the defined user workflows - UX testing validates every implementation milestone - API development derives from UX requirements #### **Builder Pattern as Single Source of Truth** - [`SessionDataBuilder`](src/services/session_data.rs), [`ConfigurationBuilder`](src/config/builder.rs), [`ResponseBuilder`](src/utils/response_builder.rs), [`ServiceFactory`](src/services/factory.rs) centralize construction and lifecycles - All HTTP endpoints return via [`ResponseBuilder`](src/utils/response_builder.rs) with consistent JSON envelopes #### **ResponseBuilder Envelope & Frontend Contract** ```json { "success": true|false, "data": { ... }, "error"?: { ... } } ``` - Frontend must always unwrap: `const data = result.data || result;` before accessing fields #### **CSP-Compliant Frontend: External JS + JSON Hydration** - **Zero inline scripts/handlers** - code lives in [`src/static/js/*.js`](src/static/js/) and is served under `/static/js/*` - **Data hydration** via `