22 Commits

Author SHA1 Message Date
ea66086b44 Remove named volume from prod compose, use bind mount for notebooks
The base docker-compose.yml already mounts ./notebooks:/app/notebooks.
The named Docker volume was shadowing it in prod, preventing example
notebooks from being visible. Bind mount ensures examples ship with
the repo and user notebooks persist on the host filesystem.
2026-02-14 13:16:18 -07:00
c9116c5d86 Add SEO meta tags, OG image generation, and astro-icon integration
Wire astro-seo-meta for OG, Twitter Card, and canonical tags on all
pages. Add Satori + resvg dynamic OG image endpoints at /og/[id].png
with branded dark-theme cards. Replace inline SVGs with zero-JS
astro-icon rendering. SSR fetches use 5s AbortController timeout and
shared ID validation across all dynamic routes.
2026-02-14 13:15:52 -07:00
99e47685aa Add Mims verification confirmation for embed bugfixes
All 4 embed bugs verified fixed by Mims library testing:
postMessage type sync, waveform theme colors, chart remount,
and shared component light-mode overrides. Thread closed.
2026-02-13 18:14:52 -07:00
e8ade01662 Fix embed integration bugs from Mims library testing
- postMessage type: 'theme-change' → 'spicebook-theme' to match
  SimulationEmbed.tsx namespace convention
- WaveformViewer: read axis/grid/tick colors from CSS custom
  properties via getComputedStyle instead of hardcoded dark hex
- Theme switch forces WaveformViewer remount via React key so
  uPlot picks up new CSS variable values
- Light-mode CSS overrides for shared components (SchematicViewer
  toolbar, SimulationLog borders, slate utility classes)
2026-02-13 16:31:32 -07:00
b0dc46edc2 Merge feature/schematic-phase1: schematics + Mims embed integration
Brings in auto-generated schematics from SPICE netlists with
click-to-edit values, graph paper backgrounds, and Mims-style
connected layout. Also adds embeddable notebook viewer for
cross-site iframe integration with the Mims library.
2026-02-13 15:46:43 -07:00
3f3ca58521 Add embeddable notebook viewer for Mims library integration
New /embed/[id] route renders notebooks in a read-only, chromeless
layout for iframe embedding. Supports light/dark themes via URL
param and postMessage from the parent window.

- EmbedLayout: minimal HTML shell, no navbar/footer
- EmbedViewer: fetches notebook, runs simulations, syncs theme
- EmbedCell: read-only markdown + SPICE cell renderer
- SpiceEditor: added readOnly prop (EditorState.readOnly + editable.of)
- embed-theme.css: light mode CSS variable overrides
- Astro middleware: CSP frame-ancestors on /embed/* routes
- Backend: env-configurable CORS origins, CSP header middleware

Security hardening from review:
- postMessage origin validation (ALLOWED_MESSAGE_ORIGINS)
- markdown XSS fix: isSafeUrl() blocks javascript: URIs in links
- escapeHtml now covers single quotes
- Notebook ID validated against /^[a-zA-Z0-9_-]+$/
- Theme param normalized at Astro boundary
- classList.remove/add instead of className stomping
2026-02-13 15:46:37 -07:00
a8c53f34f4 Add click-to-edit schematic values and DOMPurify sanitization
SchematicViewer now supports inline editing of component values
directly on the SVG. Clicking an editable value opens an overlay
input that updates the SPICE netlist on commit, triggering an
auto-redraw after 800ms debounce.

Added DOMPurify for SVG sanitization, netlist-utils for safe
value substitution in netlists, and wired schematic generation
through the notebook store with generation counters to discard
stale responses.
2026-02-13 15:46:14 -07:00
4f174e9d0f Add Mims-style graph paper background to schematics
Sage-green grid (minor 10pt, major 50pt) on warm off-white canvas,
injected as nested SVG patterns behind all schematic content.
Works across all three renderers (loop, connected, grid).
2026-02-13 09:14:52 -07:00
c120a179c8 Improve connected schematic label placement (Mims-style)
- Add lead stub wires (0.75 unit) from collector and emitter pins
  for clearance between transistor and first component
- Transistor label placed right of body, all chain labels on left
- Offset parallel paths (RE/CE) label on right, facing outward
- Wider parallel path spacing (2.5 units) for label breathing room
- Down-turning components label outward based on path direction
- Parameterized label_loc in _draw_vert_chain for context-aware placement
2026-02-13 08:43:11 -07:00
4bc68a58bd Add connected schematic layout for single-active-device circuits
Replace the disconnected grid fallback with a topology-aware renderer
that places BJTs/MOSFETs at center and draws connected wire paths using
SchemDraw push/pop for branching at junction points.

Layout pipeline: trace component chains from each device terminal,
classify paths by direction (supply/ground/input/output), draw with
proper Vdd/Ground terminators and junction dots at branch points.

Fallback cascade: loop → connected → grid. Supply sources shown as Vdd
rail symbols; signal sources drawn inline as SourceV in input paths.
2026-02-13 07:18:50 -07:00
de7a29c69e Add auto-schematic generation from SPICE netlists
Parse netlists into component graphs and render circuit diagrams via
SchemDraw. Two layout strategies: loop layout for simple 2-terminal
circuits (RC, RL, voltage divider) and labeled grid for complex
circuits with active devices (BJT amplifiers, MOSFET).

Backend: netlist parser, schematic engine, POST API endpoint.
Frontend: SchematicViewer with zoom/download, stacked cell layout
showing schematic + SPICE editor + waveform simultaneously.
2026-02-13 06:07:30 -07:00
42f4428295 Add 7 advanced example notebooks with real-world circuits
Buck converter, Class AB amplifier, AM radio receiver, Dickson
charge pump, transmission line signal integrity, 4th-order
Sallen-Key filter, and Colpitts RF oscillator. Multi-cell
notebooks with engineering narratives and multiple simulation
views per circuit.
2026-02-13 04:29:33 -07:00
da3532c1aa Add example notebook population script
Creates 8 curated example notebooks via the API:
- RC Lowpass Filter (AC analysis)
- Voltage Divider (DC operating point)
- RC Step Response (transient)
- RLC Bandpass Filter (AC analysis)
- Diode Half-Wave Rectifier (transient)
- LED I-V Characteristic (DC sweep)
- Inverting Op-Amp Amplifier (transient)
- CMOS Inverter (DC transfer characteristic)
2026-02-13 03:55:55 -07:00
9b2737ef77 Set PUBLIC_API_URL at build time for production
Vite inlines import.meta.env.PUBLIC_* at build time, not runtime.
Without this, the frontend falls back to localhost:8099 which doesn't
exist from the browser. Empty string means same-origin requests,
letting Caddy route /api/* to the backend.
2026-02-13 03:45:23 -07:00
fb5b911ea1 Use named volume for notebooks in production
Bind mounts inherit host UID which conflicts with the container's
non-root user. Named volumes are initialized from the image layer,
preserving the chown from the Dockerfile.
2026-02-13 03:43:09 -07:00
7ffd3f1bd3 Fix notebook directory permissions for non-root user
Pre-create /app/notebooks/{user,examples} with correct ownership
before switching to the spicebook user. Without this, the app crashes
with PermissionError when it tries to create these directories at
runtime.
2026-02-13 03:41:42 -07:00
a24375accb Fix Docker build: remove missing readme ref, disable astro telemetry 2026-02-13 03:39:00 -07:00
5aa36b252a Remove unsupported --no-editable flag from backend Dockerfile 2026-02-13 03:38:08 -07:00
4600a7b0a9 Production deployment: SSR frontend, Caddy path routing
Update frontend Dockerfile prod stage from Caddy static to Node.js
running Astro SSR server. Configure caddy-docker-proxy labels to
route /api/* to backend and everything else to frontend on the same
domain. Support empty PUBLIC_API_URL for same-origin API calls.
2026-02-13 03:37:14 -07:00
5a2c5730c0 Add project README and screenshots
Document architecture, features, quick start, file format, API
endpoints, configuration, roadmap, and tech stack. Include screenshots
of the notebook with AC Bode plot and transient step response.
2026-02-13 02:33:13 -07:00
72eb073787 Clean URLs and waveform rendering fixes
Switch from query-param routing (/notebook/?id=X) to Astro dynamic
routes (/notebook/rc-lowpass-filter). Add @astrojs/node adapter with
output: 'server' for on-demand route handling.

Fix formatEng/formatAxisValue crash on null values passed by uPlot
axis tick formatters. Add CORS origin for port 4322.
2026-02-13 02:16:11 -07:00
8abd7719bf Initial SpiceBook MVP: notebook interface for circuit simulation
Phase 1 implementation with ngspice backend and Astro/React frontend:

Backend (FastAPI):
- ngspice subprocess engine with custom .raw file parser
- Notebook CRUD with .spicebook JSON format (filesystem storage)
- Simulation endpoints (standalone + cell-in-notebook)
- SVG waveform export endpoint
- 18 REST API routes, 5 passing tests

Frontend (Astro 5 + React 19):
- Notebook editor as React island with Zustand state management
- CodeMirror 6 with custom SPICE language mode (syntax highlighting
  for dot commands, components, engineering notation, comments)
- uPlot waveform viewer with transient and AC/Bode plot modes
- Markdown cells with edit/preview toggle
- Notebook list with card grid UI
- Dark theme, Tailwind CSS 4, Lucide icons

Infrastructure:
- Docker Compose with dev/prod targets
- Caddy-based frontend prod serving
- 3 example notebooks (RC filter, voltage divider, CE amplifier)
2026-02-13 01:44:38 -07:00