# Foldnano Contributor Documentation ──────────────────────────────────────────────────────────── # Contributor Overview ## What Is Foldnano Foldnano is a browser-based DNA nanostructure design tool built with SvelteKit. It's local-first: designs live in the browser's IndexedDB working copy, with optional sync to a GitHub repository. It embeds a Python plugin runtime (via Pyodide, running in a Web Worker), so design operations can be scripted in Python without leaving the browser. It also supports importing and exporting the legacy cadnano `.json` format alongside its own native `.fn.json`. This section is a curated contributor guide. It is not a mirror of every internal file in the repository `docs/` folder. Public-facing contributor docs should explain how to work on Foldnano. Internal audits, release-review notes, and exploration reports stay in the repository's `docs/` folder rather than on this site, unless they are rewritten as stable guidance. ## What To Read First 1. Coming from Python (skip if you're already comfortable with JS/TS/pnpm) 2. Local setup 3. Architecture overview 4. Model and command invariants 5. Storage, autosave, and GitHub sync 6. Plugin runtime architecture 7. Code style and tests For deeper implementation detail, use the repo docs such as `docs/architecture.md`, `docs/dna-model.md`, `docs/commands-and-history.md`, and `docs/storage-architecture.md`. ## Branch Model And PR Workflow - `main` is the stable branch; open pull requests against it. - Name feature branches `feat/` and bug-fix branches `fix/`. - Run `pnpm check && pnpm test` before pushing. `pnpm test` scopes to suites affected by your changes; run `pnpm test:branch` (suites affected vs. `main`) before opening the PR. ## Contribution Principle Foldnano has a reactive editor, an undoable model, local persistence, and multi-tab protection. Most regressions come from bypassing one of those ownership boundaries. Prefer small changes that preserve the existing command, storage, and view-context contracts. ──────────────────────────────────────────────────────────── # Coming From Python Foldnano's frontend is TypeScript and Svelte, not Python. If you already work comfortably in a JS/TS toolchain, skip this page and go straight to Local Setup. If your background is Python (scripting, Jupyter, scientific computing), this page maps the ecosystem before you touch a terminal command. ## What Are JavaScript, TypeScript, And Svelte? If the names above are unfamiliar, here's the short version before anything else: - **JavaScript** is the programming language every web browser runs: the browser understands it natively, the same way it only understands HTML/CSS for markup and layout. It's dynamically typed, like Python. See [MDN's JavaScript guide](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide) for an introduction. - **TypeScript** is JavaScript plus a type system, checked before the code runs, not at runtime. Think Python type hints, except the compiler (`tsc`, run here via `pnpm check`) *enforces* them rather than just suggesting them, and strips the types out to produce plain JavaScript. This project is TypeScript throughout; see the [TypeScript handbook](https://www.typescriptlang.org/docs/handbook/intro.html). - **Svelte** is a UI framework for building interactive web pages out of reusable components, the same role [React](https://react.dev/) or [Vue](https://vuejs.org/) play, if you've heard of either. The difference that matters here: React/Vue ship a runtime library that does its work in the browser at page-load time, while Svelte is mostly a *compiler*. It turns your components into plain, minimal JavaScript ahead of time, so there's less framework code shipped to the browser. See [Svelte's introduction](https://svelte.dev/docs/svelte/overview). - **SvelteKit** is the application framework built on top of Svelte: it adds routing, server-side rendering, and API endpoints, the same relationship [Next.js](https://nextjs.org/) has to React, or Django has to plain Python. See [SvelteKit's introduction](https://svelte.dev/docs/kit/introduction). ## The Mental Model | Python world | JS/TS/Svelte equivalent here | | ------------------------------- | --------------------------------------------------------------------------- | | `python` / `pyenv` | [Node.js](https://nodejs.org/en/docs) / `nvm` | | `pip` / `conda` / `uv` | [pnpm](https://pnpm.io/) | | `venv` / `.venv` | `node_modules/` (auto-managed, never commit) | | `requirements.txt` | `package.json` + `pnpm-lock.yaml` | | a module (`.py`) | a [TypeScript](https://www.typescriptlang.org/docs/) module (`.ts`, or `.svelte.ts` if it uses reactive state) | | a function/class you call | a [Svelte](https://svelte.dev/docs/svelte) *component* (`.svelte` file: template, script, and scoped style together) | | a Flask/Django route | a [SvelteKit](https://svelte.dev/docs/kit) file-based route (`src/routes/.../+page.svelte`) | | a `@dataclass` field others read | a Svelte 5 [*rune*](https://svelte.dev/docs/svelte/what-are-runes) (`$state`, `$derived`, `$props`), an explicitly reactive field | | `pytest` | [Vitest](https://vitest.dev/) | | `python -m mymodule` / `uv run` | `pnpm run