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.

All of ProtoPulse’s persistent state lives in PostgreSQL. The schema is defined in shared/schema.ts — a single TypeScript file that drives table structure, API validation (via Zod), and static typing simultaneously. This page documents each table group, its columns, and how the tables relate to one another.

Overview

  • ORM: Drizzle ORM (drizzle-orm + drizzle-kit)
  • Schema file: shared/schema.ts (single source of truth)
  • Zod validators: generated automatically from each table using createInsertSchema() from drizzle-zod
  • TypeScript types: inferred from the Drizzle schema using $inferSelect and z.infer<>
  • Soft deletes: projects, architecture_nodes, architecture_edges, and bom_items use a deleted_at timestamp; all other tables use hard deletes
The schema has grown beyond the original 27 tables documented here. As of the 0002 migration (2026-03-08), the core schema covers the 27 tables below. The Unified Parts Catalog (ADR 0010) and Arduino Workbench features introduce additional tables that will be documented in their respective feature guides.

Tables by domain

These tables form the authentication and project ownership foundation. All project-scoped tables cascade on projects.id.

users

Registered accounts. Password hashing uses scrypt.
ColumnTypeNotes
idserial PKAuto-increment
usernametextNOT NULL, UNIQUE
password_hashtextNOT NULL — scrypt output
created_attimestampDEFAULT NOW

sessions

Active login sessions. Sessions expire after 7 days.
ColumnTypeNotes
idtext PKUUID — sent as X-Session-Id header
user_idinteger FK → users.id CASCADE
expires_attimestampNOT NULL — 7-day TTL
created_attimestampDEFAULT NOW

api_keys

Encrypted AI provider API keys (Gemini, Anthropic). The key value is never stored in plaintext.
ColumnTypeNotes
idserial PK
user_idinteger FK → users.id CASCADE
providertexte.g. gemini, anthropic
encrypted_keytextAES-256-GCM ciphertext
ivtextInitialization vector (hex)
created_attimestampDEFAULT NOW

user_chat_settings

Per-user AI configuration. One row per user (unique on user_id).
ColumnTypeNotes
idserial PK
user_idinteger FK → users.id CASCADEUNIQUE
ai_providertextDEFAULT anthropic
ai_modeltextDEFAULT claude-sonnet-4-5-20250514
ai_temperaturerealDEFAULT 0.7
custom_system_prompttextDEFAULT ''
routing_strategytextuser | auto | quality | speed | cost; DEFAULT user
preview_ai_changesbooleanDEFAULT true
updated_attimestampDEFAULT NOW

projects

Top-level project container. All design data belongs to a project.
ColumnTypeNotes
idserial PK
nametextNOT NULL
descriptiontextDEFAULT ''
owner_idinteger FK → users.idNULLABLE
versionintegerDEFAULT 1 — incremented on update
created_attimestampDEFAULT NOW
updated_attimestampDEFAULT NOW
deleted_attimestampNULLABLE — soft delete marker
approved_attimestampNULLABLE — design review approval
approved_byinteger FK → users.idNULLABLE
Indexes: idx_projects_owner, idx_projects_owner_deleted
The architecture editor stores block diagrams as nodes and edges in React Flow format.

architecture_nodes

Individual blocks on the architecture canvas (MCU, sensor, power, connector, etc.).
ColumnTypeNotes
idserial PK
project_idinteger FK → projects.id CASCADE
node_idtextClient-generated UUID; UNIQUE per project
node_typetext1–100 chars; e.g. mcu, sensor, power, comm, connector
labeltextNOT NULL — display name
position_xrealCanvas X coordinate
position_yrealCanvas Y coordinate
datajsonbNULLABLE — { description?, componentPartId? }
versionintegerDEFAULT 1
updated_attimestampDEFAULT NOW
deleted_attimestampNULLABLE — soft delete
Indexes: idx_arch_nodes_project, idx_arch_nodes_project_deleted, unique uq_arch_nodes_project_node, GIN index on data (jsonb_path_ops)

architecture_edges

Connections between architecture nodes, carrying signal metadata.
ColumnTypeNotes
idserial PK
project_idinteger FK → projects.id CASCADE
edge_idtextClient-generated UUID; UNIQUE per project
sourcetextSource node_id
targettextTarget node_id
labeltextNULLABLE — e.g. SPI Bus
animatedbooleanDEFAULT false — React Flow animation
stylejsonbNULLABLE — { stroke?: string }
signal_typetextNULLABLE — SPI, I2C, UART, analog, etc.
voltagetextNULLABLE — e.g. 3.3V
bus_widthintegerNULLABLE
net_nametextNULLABLE — named net reference
versionintegerDEFAULT 1
deleted_attimestampNULLABLE — soft delete
Indexes: idx_arch_edges_project, idx_arch_edges_project_deleted, unique uq_arch_edges_project_edge
The circuit domain models schematic, breadboard, and PCB views. A project can have multiple circuit_designs (hierarchical sheets); each design has its own instances, nets, and wires.

circuit_designs

Top-level circuit schematic. Supports hierarchical sheets via parent_design_id.
ColumnTypeNotes
idserial PK
project_idinteger FK → projects.id CASCADE
parent_design_idintegerNULLABLE — links to parent sheet for hierarchy
nametextDEFAULT Main Circuit
descriptiontextNULLABLE
settingsjsonbNOT NULL, DEFAULT {}
versionintegerDEFAULT 1
created_at / updated_attimestampDEFAULT NOW

circuit_instances

Component placements within a circuit design. Tracks position across all three views (schematic, breadboard, PCB).
ColumnTypeNotes
idserial PK
circuit_idinteger FK → circuit_designs.id CASCADE
part_idinteger FK → component_parts.id SET NULL
reference_designatortexte.g. R1, U2
schematic_x/yrealDEFAULT 0
schematic_rotationrealDEFAULT 0
breadboard_x/yrealNULLABLE
pcb_x/yrealNULLABLE
pcb_rotationrealDEFAULT 0
pcb_sidetextDEFAULT front
propertiesjsonbNOT NULL, DEFAULT {}

circuit_nets

Electrical nets — the logical connections between component pins.
ColumnTypeNotes
idserial PK
circuit_idinteger FK → circuit_designs.id CASCADE
nametextNOT NULL
net_typetextsignal | power | ground | bus; DEFAULT signal
voltagetextNULLABLE
bus_widthintegerNULLABLE
segmentsjsonbDEFAULT [] — connection segments (instance + pin pairs)
labelsjsonbDEFAULT [] — net labels with positions
stylejsonbDEFAULT {} — visual style

circuit_wires

Physical wire routing for a net in a specific view.
ColumnTypeNotes
idserial PK
circuit_idinteger FK → circuit_designs.id CASCADE
net_idinteger FK → circuit_nets.id CASCADE
viewtextschematic | breadboard | pcb
pointsjsonbNOT NULL, DEFAULT [] — array of {x, y} points
layertextDEFAULT front
widthrealDEFAULT 1.0
wire_typetextDEFAULT wire
provenancetextDEFAULT manualmanual or autorouted

hierarchical_ports

Inter-sheet connection ports for hierarchical circuit designs.
ColumnTypeNotes
idserial PK
design_idinteger FK → circuit_designs.id CASCADE
port_nametextNOT NULL
directiontextinput | output | bidirectional; DEFAULT bidirectional
net_nametextNULLABLE
position_x/yrealDEFAULT 0
Bill of Materials tracking, point-in-time snapshots for diffing, and component lifecycle / obsolescence monitoring.

bom_items

Line items in a project’s bill of materials.
bom_items is a legacy table. New code should use the Unified Parts Catalog (parts + part_stock) introduced in ADR 0010. The bom_items table is kept for compatibility during the Phase 5–7 migration window.
ColumnTypeNotes
idserial PK
project_idinteger FK → projects.id CASCADE
part_numbertextNOT NULL
manufacturertextNOT NULL
descriptiontextNOT NULL
quantityintegerDEFAULT 1
unit_pricenumeric(10,4)NOT NULL
total_pricenumeric(10,4)Computed server-side: qty × unit_price
suppliertextNOT NULL
stockintegerDEFAULT 0
statustextIn Stock | Low Stock | Out of Stock | On Order
lead_timetextNULLABLE
deleted_attimestampNULLABLE — soft delete

bom_snapshots

Point-in-time BOM captures used for the BOM diff / comparison view.
ColumnTypeNotes
idserial PK
project_idinteger FK → projects.id CASCADE
labeltextNOT NULL — human-readable name, e.g. v1.0 release
snapshot_datajsonbNOT NULL — serialized BomItem[] at capture time
created_attimestampDEFAULT NOW

component_lifecycle

Obsolescence and lifecycle status tracking per BOM part number.
ColumnTypeNotes
idserial PK
project_idinteger FK → projects.id CASCADE
bom_item_idintegerNULLABLE — links to bom_items
part_numbervarchar(100)NOT NULL
manufacturervarchar(200)NULLABLE
lifecycle_statusvarchar(50)active | nrnd | eol | discontinued; DEFAULT active
last_checked_attimestampNULLABLE
alternate_part_numberstextNULLABLE — comma-separated alternates
data_sourcevarchar(100)NULLABLE
notestextNULLABLE
Custom component definitions used by the Component Editor and referenced by circuit instances.

component_parts

Project-scoped custom component definitions. Each part stores its visual representations (breadboard, schematic, PCB) and electrical connectors as JSONB.
ColumnTypeNotes
idserial PK
project_idinteger FK → projects.id CASCADE
node_idtextNULLABLE — links to architecture node
metajsonbPartMeta — title, family, manufacturer, tags, etc.
connectorsjsonbArray of Connector objects (pin definitions)
busesjsonbArray of Bus objects
viewsjsonbPartViews — breadboard, schematic, PCB shapes
constraintsjsonbArray of Constraint objects (DRC rules)
versionintegerDEFAULT 1 — auto-incremented on update
Indexes: GIN indexes on meta and connectors for JSONB path queries.

component_library

Global shared component library. Components can be public, forked, and downloaded by other users.
ColumnTypeNotes
idserial PK
titletextNOT NULL
descriptiontextNULLABLE
meta / connectors / buses / views / constraintsjsonbSame structure as component_parts
tagstext[]NOT NULL, DEFAULT []
categorytextNULLABLE
is_publicbooleanDEFAULT false
author_idtextNULLABLE
forked_from_idintegerNULLABLE — self-reference for forks
download_countintegerDEFAULT 0

spice_models

Global SPICE model library. Not project-scoped; seeded with ~20 standard models on first run.
ColumnTypeNotes
idserial PK
nametextNOT NULL — e.g. 2N2222
model_typetextEnum: NPN, PNP, DIODE, ZENER, NMOS, PMOS, OPAMP, TIMER, RESISTOR, CAPACITOR, INDUCTOR, and more
spice_directivetextFull .MODEL or .SUBCKT directive
parametersjsonbKey model parameters
categorytexttransistor | diode | opamp | passive | ic | voltage_regulator | mosfet | jfet
datasheettextNULLABLE — datasheet URL
Tables that record the AI conversation history, user action log, and AI tool execution audit trail.

chat_messages

Messages in the AI chat panel. Supports conversation branching.
ColumnTypeNotes
idserial PK
project_idinteger FK → projects.id CASCADE
roletextuser | assistant | system
contenttextNOT NULL — message body (may contain Markdown)
timestamptimestampDEFAULT NOW
modetextDEFAULT chat
branch_idtextNULLABLE — conversation branch identifier
parent_message_idintegerNULLABLE — parent message for branching
metadatatextNULLABLE
Indexes: idx_chat_messages_project, idx_chat_messages_project_ts (for chronological queries), idx_chat_messages_branch

history_items

Human-readable action history shown in the Sidebar history panel.
ColumnTypeNotes
idserial PK
project_idinteger FK → projects.id CASCADE
actiontextNOT NULL — description of the action
usertextNOT NULL — User or AI
timestamptimestampDEFAULT NOW

ai_actions

Audit log of every AI tool call — tool name, parameters, and result. Used for replay and debugging.
ColumnTypeNotes
idserial PK
project_idinteger FK → projects.id CASCADE
chat_message_idtextNULLABLE — links to the triggering chat message
tool_nametextNOT NULL — AI tool function name, e.g. addArchitectureNode
parametersjsonbNOT NULL, DEFAULT {} — tool call inputs
resultjsonbNOT NULL, DEFAULT {} — tool call output
statustextDEFAULT completed
created_attimestampDEFAULT NOW
DRC/ERC results and SPICE simulation outputs.

validation_issues

Design rule check and electrical rules check results. Populated by the AI’s validation tools and the client-side DRC engine.
ColumnTypeNotes
idserial PK
project_idinteger FK → projects.id CASCADE
severitytexterror | warning | info
messagetextNOT NULL — human-readable description
component_idtextNULLABLE — references a node label or reference designator
suggestiontextNULLABLE — suggested fix

simulation_results

Stored SPICE simulation outputs. Each row is one simulation run.
ColumnTypeNotes
idserial PK
circuit_idinteger FK → circuit_designs.id CASCADE
analysis_typetextop | tran | ac | dc
configjsonbSimulation parameters (stop time, step, frequency range, etc.)
resultsjsonbNode voltages, branch currents, waveform data
statustextcompleted | failed; DEFAULT completed
engine_usedtextNULLABLE — simulator engine name
elapsed_msintegerNULLABLE — wall-clock time
size_bytesintegerNULLABLE — result payload size
errortextNULLABLE — error message if status is failed

design_preferences

AI-learned per-project user preferences (component families, routing styles, etc.). Unique per (project_id, category, key).
ColumnTypeNotes
idserial PK
project_idinteger FK → projects.id CASCADE
categorytextPreference category, e.g. component, routing
keytextPreference key, e.g. preferred_mcu_family
valuetextPreference value
sourcetextai | user; DEFAULT ai
confidencerealAI confidence score; DEFAULT 0.8
Unique index: uq_design_prefs_project_cat_key on (project_id, category, key)
Point-in-time captures and threaded code-review-style comments on design elements.

design_snapshots

Point-in-time captures of the architecture diagram (nodes + edges JSON). Used for visual diff and rollback.
ColumnTypeNotes
idserial PK
project_idinteger FK → projects.id CASCADE
namevarchar(200)NOT NULL — e.g. Before major refactor
descriptiontextNULLABLE
nodes_jsonjsonbNOT NULL — serialized node array at capture time
edges_jsonjsonbNOT NULL — serialized edge array at capture time
created_attimestampDEFAULT NOW

design_comments

Threaded, spatially-anchored comments for design review. Comments can be attached to nodes, edges, BOM items, or placed at arbitrary canvas coordinates.
ColumnTypeNotes
idserial PK
project_idinteger FK → projects.id CASCADE
user_idinteger FK → users.idNULLABLE
parent_idintegerNULLABLE — self-reference for thread replies
target_typetextgeneral | node | edge | bom_item | spatial
target_idtextNULLABLE — ID of the target element
spatial_x/yrealNULLABLE — canvas coordinates for spatial pins
spatial_viewtextarchitecture | schematic | pcb | breadboard
contenttextNOT NULL — Markdown supported
statustextopen | resolved | blocked | wontfix; DEFAULT open
status_updated_byinteger FK → users.idNULLABLE
status_updated_attimestampNULLABLE
Indexes: idx_design_comments_project, idx_design_comments_project_target, idx_design_comments_parent

Viewing and modifying the schema

Browse the schema interactively

Drizzle Studio provides a web-based database browser:
npm run db:studio
This opens a local web UI where you can browse tables, run queries, and inspect row data.

Modify the schema

All schema changes start in shared/schema.ts. After editing, sync the changes to your local database:
# Development — fast direct sync (no migration file)
npm run db:push

# Generate a migration file for production deployments
npm run db:generate
Never edit the database directly with ALTER TABLE or psql when using Drizzle. All schema changes must go through shared/schema.ts so that TypeScript types and Zod validators stay in sync. Out-of-band changes will cause type errors and potential runtime failures.
The generated migration files are stored in migrations/ and should be committed to source control. In production deployments, apply them with npm run db:migrate.

Add a new table

  1. Define the table in shared/schema.ts using pgTable()
  2. Add a createInsertSchema() call to generate the Zod validator
  3. Export InsertX and X TypeScript types with z.infer<> and $inferSelect
  4. Add the corresponding IStorage methods to server/storage.ts
  5. Run npm run db:push locally to apply the change
  6. Run npm run check to verify TypeScript is still clean
For related reading, see System Architecture and the API Overview.

Build docs developers (and LLMs) love