Carta documentation

Maintaining this documentation

This page is for people working on Carta itself.

How the site works

infra/docs-site/server.mjs is a small node:http server (markdown-it, github-slugger, highlight.js) that turns documentation/ into a site with sidebar navigation, search, a per-page outline and dark mode. Nothing is pre-built: HTML is produced per request and cached.

  • Rendering: markdown-it with raw HTML disabled. Headings get GitHub-compatible ids, so file.md#heading links work on GitHub and on the site. Blockquotes that start with **Note**, **Tip**, **Important**, **Warning** or **Caution** become styled callouts. External links open in a new tab; images lazy-load.
  • Navigation: built from documentation/README.md. Each ## is a sidebar group, each ### a subgroup, and the first .md link in each list item is an entry. That order also drives the Previous/Next links. Pages not linked from the README appear under Other pages.
  • Search: a JSON index of every page, filtered in the browser by public/app.js.
  • Live editing: pages are cached by file modification time and the site index is rebuilt at most every 2 seconds, so a bind-mounted documentation/ updates live.
  • Raw source: every page links to its Markdown (?raw).
  • Packaging: infra/Dockerfile.docs copies the server and documentation/ into node:22-alpine (DOCS_DIR=/docs, port 3000, /healthz health check). In docker-compose.yml it's the docs service. Set DOCUMENTATION_URL to its public URL to show Docs in the public nav, Documentation in the footer and Help & documentation in the app sidebar. The public pages are prerendered, so it's passed to the web build as well as its runtime environment; rebuild web after changing it.

Adding or changing a page

  1. Write the Markdown in the right folder. Start it with a single # title.
  2. Link it from documentation/README.md so it appears in the sidebar.
  3. Reference screenshots as ../assets/screenshots/<area>/<name>.png, and add the capture to scripts/doc-shots.mjs (see below).
  4. Check links (see below).

Screenshots

scripts/doc-shots.mjs drives a running Carta stack with playwright-core and headless Chromium. It walks the UI the way a user would and saves PNGs at the paths the Markdown references, under documentation/assets/screenshots/.

  • Target data: the demo corporation Maple & Pine Holdings Inc. (maple-pine) from scripts/demo_seed.py, signed in as [email protected], and the platform admin [email protected] for the admin console.
  • Deterministic browser: every context is 1440×900, light colour scheme, America/Toronto timezone, en-CA locale. It uses the cached Playwright Chromium build 1248 in new headless mode, which renders the PDF previews; the headless shell or Playwright's default is the fallback.
  • Groups run in a fixed order: public, shell, vault, registers, governance, settings, documents, compliance, administration, admin. public and admin use their own pages and sign-ins; the rest share one signed-in page. settings fills in the corporation profile, which documents needs.
  • Capture helper: shot(page, file, target) takes the viewport, the full page ("full", which lets the app's scrolling <main> grow first) or a single element (a locator).
  • Locating UI: by role, label and placeholder (getByRole, and a field(scope, label) helper that also handles labels not tied to their input), not CSS classes, so shots survive styling changes.
  • Data it creates: vault uploads, a debt obligation, settings values, a generated document (which locks the corporation's identity) and an invite code. Everything it names is prefixed Docs. Re-seed with --reset before a clean run.
  • Failure handling: each step is wrapped so one failure doesn't stop the run; page errors and failed shots are printed as an ISSUES list at the end, and the exit code is non-zero.

scripts/shot.mjs is the quick version: sign in (or LOGIN=0, or LOGIN=admin) and screenshot a list of paths into a folder. Paths may contain {tenant}. Useful for checking a page, not for the docs.

Running it

  1. Install the script dependency once: cd scripts && npm install.

  2. Start the stack: docker compose up -d. Publish the web and database ports (for example with an override file) so the scripts can reach them.

  3. Seed the demo data, then restart the web container so it brings the tenant schema up to date:

    python3 scripts/demo_seed.py --reset        # DB_HOST / DB_PORT if the database isn't on localhost:5432
    docker compose restart web
    
  4. Regenerate screenshots: node scripts/doc-shots.mjs, or only some groups with --only=vault,documents. Override BASE, EMAIL, PASSWORD, TENANT, ADMIN_EMAIL or ADMIN_PASSWORD as needed.

  5. Read the ISSUES list at the end, then review the PNG diffs in git before committing.

  6. Preview the docs live:

    docker build -f infra/Dockerfile.docs -t corpo-docs .
    docker run --rm -p 3001:3000 -v "$PWD/documentation:/docs:ro" corpo-docs
    

    Or run node infra/docs-site/server.mjs directly (after npm install in infra/docs-site); it defaults to ../../documentation and port 3000 (PORT to change it).

  7. Check links against the running site: node infra/docs-site/check-links.mjs http://localhost:3001/ (or npm run check in infra/docs-site).

  8. Commit the Markdown and screenshots together.