How priyan-b/paletteforge works
Purpose and Entry Points
PaletteForge is an authenticated full-stack design workflow: create/edit simple wireframes, derive or manage palettes, and evaluate/apply WCAG accessibility guidance. The Express process starts at backend.js; the React SPA mounts at frontend/src/main.jsx and coordinates its two top-level modes in frontend/src/App.jsx.
Application Shell and Authentication
Authentication is session-based Passport Local with bcrypt-backed users. auth.js configures identity behavior, routes/auth.js exposes registration/login/logout/session endpoints, and middleware/requireAuth.js protects application API routes. On the client, frontend/src/components/AuthGate/AuthGate.jsx gates the entire SPA on the authenticated session.
HTTP and Persistence Boundary
Express mounts feature REST routes from routes/wireframes.js, routes/extractedPalettes.js, routes/contrastPalettes.js, and routes/contrastReports.js. These persist user-scoped documents through the native MongoDB driver in db/connection.js; no ORM layer exists. Frontend feature API wrappers—frontend/src/api/wireframes.js, frontend/src/api/palettes.js, and frontend/src/api/contrastApi.js—form the client/server boundary.
Wireframe Studio
frontend/src/components/WireframeStudio/WireframeStudio.jsx owns wireframe and extracted-palette editing state. WireframeBoard.jsx and Shape.jsx implement the interactive layout surface: selectable rectangle/circle shapes with drag, resize, fill, and labels. Saved layouts flow through WireframeLibrary.jsx to the wireframe API; saved image-derived palettes flow through PaletteExtractor.jsx and PaletteLibrary.jsx to extracted-palette storage.
Palette Extraction and Application
Image palette extraction is entirely browser-side in frontend/src/utils/extractPalette.js, using canvas-based quantization rather than an external service. PaletteApplyPanel.jsx applies palette colors to board shapes, supports direct swatch matching, and shuffles assignments using frontend/src/utils/shuffleArray.js, preserving a no-immediate-repeat constraint. The selected/applied palette is also the integration payload for accessibility review.
Accessibility Toolkit
frontend/src/components/AccessibilityToolkit/AccessibilityToolkit.jsx selects toolkit subviews. ContrastChecker/ContrastChecker.jsx provides live pairwise checks; PaletteBuilder/PaletteBuilder.jsx assigns fixed UI roles and saves role-based palettes; PaletteAudit/PaletteAudit.jsx evaluates defined role pairings and persists reports; AutoFix/AutoFix.jsx adjusts a failing foreground color toward its contrast target. Shared client math and role-pair definitions live in frontend/src/utils/wcag.js and frontend/src/utils/roles.js; matching server-side authority/support exists in utils/wcag.js and utils/roles.js.
Cross-Feature Flow and Runtime
The SPA uses useState tab switching rather than client-side routing. Wireframe Studio hands its applied colors directly into the Palette Builder, avoiding re-entry before audit or auto-fix. Development runs React 19/Vite, with frontend/vite.config.js proxying /api to Node/Express 5. Production Express serves the built frontend. Required infrastructure is MongoDB plus environment-provided MONGODB_URI, SESSION_SECRET, and port; deployment is documented on Render.
Main entry points: wireframes.js Feature REST routes · AccessibilityToolkit.jsx Toolkit selector · App.jsx App modes · WireframeStudio.jsx Studio state
Components 22
React SPA
Vite-built browser application.
Wireframe Studio
- Studio state · Owns wireframe and extracted-palette editing state.
frontend/src/components/WireframeStudio/WireframeStudio.jsx - Interactive board · Selectable, draggable, resizable shapes.
- Wireframe library
- Palette extraction
- Palette apply · Applies and shuffles palette assignments without immediate repeats.
- Canvas quantization · Extracts image colors entirely in the browser.
frontend/src/utils/extractPalette.js
Accessibility Toolkit
- Toolkit selector · Selects accessibility subviews.
frontend/src/components/AccessibilityToolkit/AccessibilityToolkit.jsx - Live contrast check
- Role palette builder · Receives applied Studio colors for role assignment.
- Palette audit · Evaluates role pairings and saves reports.
- Auto-fix contrast · Adjusts failing foreground colors toward their target.
- WCAG math and roles
frontend/src/utils/wcag.js
Express API
- Express runtime · Serves APIs and the production frontend build.
backend.js - Passport auth · Local strategy with bcrypt-backed users.
auth.js - Feature REST routes · Wireframes, extracted palettes, contrast palettes, and reports.
routes/wireframes.js - Auth endpoints · Registration, login, logout, and session endpoints.
routes/auth.js - Route protection
middleware/requireAuth.js - MongoDB driver · Persists user-scoped documents through the native driver.
db/connection.js
Other components
- MongoDB · Required external persistence infrastructure.
Connections 28
- SPA entry → App modes: mounts
- App modes → Auth gate: gated by
- Auth gate → Auth endpoints: session API
- App modes → Studio state: Studio mode
- App modes → Toolkit selector: Accessibility mode
- Studio state → Interactive board: edits
- Studio state → Wireframe library: saved layouts
- Studio state → Palette extraction: image palettes
- Palette extraction → Canvas quantization: quantizes image
- Palette apply → Interactive board: colors shapes
- Palette apply → Role palette builder: applied colors · Direct cross-feature payload.
- Toolkit selector → Live contrast check: selects
- Toolkit selector → Role palette builder: selects
- Toolkit selector → Palette audit: selects
- Toolkit selector → Auto-fix contrast: selects
- Live contrast check → WCAG math and roles: calculates
- Palette audit → WCAG math and roles: evaluates
- Express runtime → Passport auth: configures
- Express runtime → Auth endpoints: mounts
- Express runtime → Route protection: uses
- Route protection → Feature REST routes: protects
- Wireframe library → Feature REST routes: wireframe API
- Palette extraction → Feature REST routes: extracted-palette API
- Palette audit → Feature REST routes: report API
- Role palette builder → Feature REST routes: role-palette API
- Auth endpoints → MongoDB driver: users
- Feature REST routes → MongoDB driver: user documents
- MongoDB driver → MongoDB: native driver