Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/wtyler2505/ProtoPulse/llms.txt

Use this file to discover all available pages before exploring further.

ProtoPulse is a ~30,000-line TypeScript monorepo. The browser runs a React 19 single-page application; the server runs an Express 5 API that serves both the compiled frontend and all REST + SSE endpoints from a single process on port 5000. PostgreSQL stores all persistent state, accessed exclusively through Drizzle ORM. This page maps out how those layers connect.

High-level overview

Browser (React 19)

  │  HTTP REST + Server-Sent Events

Express 5 Server (:5000)
  ├── Middleware stack (Helmet, gzip, rate-limit, session auth)
  ├── 21 domain routers  (server/routes/)
  ├── 13 circuit routers (server/circuit-routes/)
  ├── AI engine          (server/ai.ts — Claude + Gemini, 82 tools, SSE streaming)
  └── Storage layer      (server/storage.ts — IStorage + DatabaseStorage + LRU cache)


      PostgreSQL (Drizzle ORM — shared/schema.ts)
Every request flows through a deterministic middleware stack before reaching a route handler. Route handlers validate input with Zod, call IStorage methods, and return JSON. The AI engine is the only path that opens a long-lived SSE stream back to the client.

Request lifecycle

Each incoming HTTP request passes through the following pipeline in order:
  1. CSP nonce generation — a random nonce is attached to res.locals for Helmet’s Content-Security-Policy header
  2. Helmet — sets security headers (CSP, HSTS, X-Frame-Options, etc.); CSP runs in reportOnly mode in development
  3. Compression — gzip response bodies
  4. Request ID — generates a UUID, attached as req.id and returned as X-Request-Id
  5. API version header — appends X-API-Version: 1 to all responses
  6. Rate limiter — 300 requests per 15-minute window per IP (10 req/15 min for auth endpoints)
  7. JSON body parser — 1 MB default; individual routes override with payloadLimit()
  8. CSRF check — validates Origin against Host for state-mutating requests
  9. Request timeout — 30-second hard timeout
  10. Session auth middleware — validates X-Session-Id, populates req.userId
  11. Audit log — records authenticated mutations
  12. Route handler — Zod validation → IStorage → response
  13. Error handlerHttpError status-aware; messages are sanitized in production

Frontend architecture

The frontend lives entirely under client/src/ and is a React 19 single-page application built with Vite 7.

State management

There is no Redux or Zustand. All server state is managed by TanStack React Query v5 (@tanstack/react-query). Local ephemeral state uses React’s built-in useState and useReducer. The apiRequest() helper in client/src/lib/queryClient.ts wraps fetch and attaches the X-Session-Id header to every request.The central ProjectProvider context (client/src/lib/project-context.tsx) exposes 40+ state values and React Query mutations to the entire workspace. All views subscribe to this context rather than fetching data independently.

Routing

Client-side routing uses Wouter — a lightweight alternative to React Router. There are three routes:
  • / — redirects to the project list
  • /projects/:idProjectWorkspace, the main three-panel layout
  • *not-found.tsx (404)

UI layer

The component library is shadcn/ui (60+ primitives in client/src/components/ui/) backed by Radix UI for accessible headless primitives. Styling is Tailwind CSS v4 with CSS variable-based theming. The canvas views use:
  • @xyflow/react (React Flow v12) — Architecture diagram and circuit schematic canvas
  • Recharts — BOM price charts and simulation output plots
  • CodeMirror 6 — Firmware/code editor with syntax highlighting

Key components

ComponentPathRole
ProjectWorkspacepages/ProjectWorkspace.tsxRoot three-panel layout: Sidebar + Main Views + Chat Panel
Sidebarcomponents/layout/Sidebar.tsxNavigation, component library tree, history panel
ArchitectureViewcomponents/views/ArchitectureView.tsxReact Flow block diagram canvas
SchematicCanvascomponents/circuit-editor/SchematicCanvas.tsxCircuit schematic editor
ChatPanelcomponents/panels/ChatPanel.tsxAI chat, SSE streaming, action parsing and execution
ExportPanelcomponents/panels/ExportPanel.tsxMulti-format export UI (KiCad, Eagle, Gerber, SPICE, etc.)
ProcurementViewcomponents/views/ProcurementView.tsxBOM management and snapshot diff
ValidationViewcomponents/views/ValidationView.tsxDRC/ERC results with “Mark Resolved” actions

Context providers

Domain-specific state is split across several React contexts co-located under client/src/lib/contexts/:
ContextPurpose
ProjectProviderCentral 40+ state values; React Query mutations for all project data
AuthContextSession state and current user
ArchitectureContextArchitecture view local state
BomContextBOM view state and filters
ChatContextChat history and streaming state
ValidationContextValidation issue list and filter state
HistoryContextAction history list
OutputContextSystem log entries

Shared code

The shared/ directory contains code that runs on both client and server:
FilePurpose
shared/schema.tsDrizzle ORM schema (47 tables), Zod insert schemas, TypeScript types
shared/component-types.tsComponent editor type system — shapes, connectors, buses, DRC rules
shared/drc-engine.tsDesign Rule Check engine (runs client-side in real time)
shared/drc-templates.tsStandard DRC rule templates
shared/bom-diff.tsBOM snapshot comparison engine
shared/netlist-diff.tsNetlist comparison and ECO engine
shared/api-types.generated.tsGenerated API type definitions (regenerate with npm run types:generate)
The @shared path alias (configured in vite.config.ts and tsconfig.json) lets both client and server code import from the shared directory with import { ... } from "@shared/schema" instead of relative paths.

Tech stack summary

LayerTechnologyVersion
Frontend frameworkReact19
Build toolVite7
Server frameworkExpress5
RuntimeNode.js20+
LanguageTypeScript5.6
DatabasePostgreSQL14+
ORMDrizzle ORM0.45+
Server stateTanStack React Query5
Client routingWouter3
UI primitivesRadix UI + shadcn/ui
Canvas / diagrams@xyflow/react (React Flow)12
StylingTailwind CSSv4
AI runtimeGoogle Genkit1.30+
AI modelsClaude (Anthropic), Gemini (Google)
Authscrypt + AES-256-GCM (custom)
TestingVitest4
E2E testingPlaywright1.58+
Desktop shellTauri2

Build docs developers (and LLMs) love