Dyad AI App Builder

repository·main·Indexed 12 days ago

https://github.com/dyad-sh/dyad

A free, local, open-source AI application builder for Mac and Windows. Dyad allows developers to build applications on their own machines using their own AI API keys (BYOK), providing a private, vendor-neutral alternative to cloud-based AI coding tools. The ecosystem includes component tagging loaders for Next.js and Vite, as well as PostgreSQL schema utilities like pg-schema-classifier and ts-pg-schema-diff.

Tokens
225K
Snippets
372
Records
929
Agent score
97%

What's inside Dyad

  1. What is Dyad?

    main

    Dyad is a local, open-source AI application builder designed to run on your machine. It provides a development experience similar to Lovable, v0, or Bolt, but emphasizes privacy, speed, and user control.

    Key characteristics include:

    • Local Execution: Runs on your machine for speed and privacy.
    • Bring Your Own Keys (BYOK): You use your own AI API keys, preventing vendor lock-in.
    • Cross-platform Support: Available for both Mac and Windows.
  2. Future roadmap for Chat History Search

    main

    The development roadmap for Chat History Search includes the following planned enhancements:

    • User-facing Search: Reusing the FTS-backed (Full-Text Search) service in a dedicated user-facing chat-search dialog once the agent tool behavior is validated.
    • Semantic Retrieval: Adding semantic retrieval as an explicit, provider-flexible layer. This will require separate user consent and clear data-egress disclosures.
    • Cross-app Search: Implementing cross-app chat search using an explicit referenced-app identity and authorization design (moving beyond simple referencedApps paths).
  3. Success criteria for Dynamic Models implementation

    main

    A successful implementation of the Dynamic Models architecture must meet these criteria:

    1. Remote Fetching: Builtin cloud providers and models are successfully fetched from api.dyad.sh when available.
    2. Local Fallback: The application correctly falls back to language_model_constants.ts upon API failure or invalid data.
    3. IPC Compatibility: Existing IPC provider/model queries remain functional and unchanged.
    4. Decoupled Model IDs: The following components must no longer hardcode specific builtin model IDs, instead using aliases or dynamic lookups:
      • Theme generator
      • Auto mode
      • Help bot
    5. Alias Sufficiency: The minimal alias set provided is sufficient for all current product behaviors.
  4. Use Safe Git Tools for Local Agent

    main

    Dyad provides a suite of six Git tools designed for local agents. These tools are categorized into read-only tools (available in ask and plan modes) and a state-changing tool (available only in writable agent mode).

    Read-only tools:

    • git_status: View branch state and file statuses (staged, unstaged, untracked, conflicted).
    • git_diff: View changes between the index, working tree, or HEAD.
    • git_log: View commit history.
    • git_show_commit: View commit metadata and patches.
    • git_show_file: View historical file content.

    State-changing tool:

    • git_restore_file: Restores a single file from a specific revision into the working tree. This tool overwrites dirty or untracked content but does not change the Git index (staged changes remain staged).
  5. Understand the Multi-Platform Roadmap for Dyad

    main
    The Dyad multi-platform roadmap outlines the transition from a desktop-only Electron application to a unified ecosystem supporting Web (MVP), Mobile (PWA), and Cross-Device Sync. The plan follows a phased approach to extract business logic from the Electron main process into platform-agnostic services, allowing the same core logic to power both the desktop app and a new web-based Node.js backend.
  6. Understand the Dyad Multi-Platform Roadmap

    main

    Dyad is transitioning from a desktop-only Electron application to a multi-platform ecosystem. The strategy involves maintaining the Desktop app as a free, local, open-source flagship, while introducing a Web version (browser-based, freemium model) and a Mobile/PWA version (for monitoring and lightweight interaction).

    Platform Comparison

    FeatureDesktopWebMobile/PWA
    Primary Use CaseFull creation (chat, code, preview, deploy, git, local models)Full creation (cloud-backed, minus local-only features)Monitoring, reviewing, lightweight chat
    LayoutThree-panel: sidebar + chat + previewThree-panel: sidebar + chat + previewSingle-panel with bottom tab navigation
    Code EditingMonaco editorMonaco editorRead-only code viewer
    PreviewLocal dev serverRemote containerFull-screen with toggle
    Sync MethodLocal filesGitHub-based syncGitHub-based sync

    Data Synchronization

    • Code: Synced between platforms via GitHub.
    • Metadata: Settings, chat history, and app metadata sync via proprietary cloud sync.
  7. Architecture: Transitioning from Electron IPC to Web/Mobile HTTP

    main

    To support web and mobile platforms, Dyad moves from a local Electron IPC model to a standalone Node.js server model.

    The Model:

    • Desktop: Electron shell $\rightarrow$ Local Node.js server $\rightarrow$ Local SQLite + Local filesystem.
    • Web/PWA: Browser $\rightarrow$ Cloud Node.js server $\rightarrow$ Cloud DB + Container filesystem.

    Key Implementation Details:

    • IPC to HTTP Mapping: IPC contracts (Zod schemas) map mechanically to HTTP routes. A channel name becomes a route, Zod input becomes the request body, and Zod output becomes the response body.
    • Streaming: Stream contracts (e.g., onChunk, onEnd) are transformed into Server-Sent Events (SSE).
    • Client Abstraction: The createClient() function in src/ipc/contracts/core.ts serves as the single point of abstraction to swap ipcRenderer.invoke() for fetch() depending on the platform.
    // IPC Pattern (Desktop)
    ipcMain.handle("create-app", handler)
    ipcRenderer.invoke("create-app", data)
    
    // HTTP Pattern (Web)
    POST /api/create-app
    fetch("/api/create-app", { body: data })
  8. Convex Backend Integration Overview

    main

    Dyad supports Convex as a reactive backend platform. Unlike traditional databases, Convex is treated as a 'backend'. The integration uses a CLI-driven approach via npx convex for deployment operations and reads convex/schema.ts directly for schema introspection.

    Key Integration Details:

    • Deployment: Uses npx convex deploy within the app directory.
    • Schema Management: The schema is defined in the convex/schema.ts file.
    • Development Mode: Uses concurrently to run both the Vite dev server and npx convex dev simultaneously.
    • Credential Storage: Convex deploy keys are stored at the app level (per-app) in the apps table, rather than in global settings.

    Important Note: Convex requires an active internet connection for development; offline development is not supported.

  9. Rules for Tab and Window Lifecycle

    main

    Dyad manages tabs and windows with specific lifecycle behaviors:

    • Window Closing: Closing a window releases its subscriptions and presentation resources, but does not cancel main-owned work (like streams, image jobs, or checkouts). Users must explicitly use Cancel or Stop to terminate such work.
    • Tab Instances: A tab has a stable TabInstanceId and belongs to a WindowSessionId.
      • Moving a Tab: Dragging a tab is an acknowledged handoff. The system captures transferable state, adopts it in the destination, and then removes the source. If adoption fails, the source tab remains intact.
      • Duplication: Creating a new tab instance (e.g., "Open in New Window") creates a new instance that may reference the same entity, but they do not automatically share transient state like scroll position, selected files, or drafts.
    • App Shutdown: Main actors respond to the actual application-shutdown boundary, not just the number of open windows. Behavior on window close (whether the app quits) follows platform conventions (macOS vs Windows/Linux).
  10. How Dyad handles ignored pnpm build scripts

    main

    When installing packages with build scripts not in Dyad's curated allow-list (e.g., core-js), pnpm defaults to skipping these builds. Under pnpm 11's strictDepBuilds: true setting, a standard pnpm install will fail with ERR_PNPM_IGNORED_BUILDS (exit 1) if these builds are not explicitly handled.

    To prevent broken builds in exported repositories (Vercel, Netlify, CI) or during Dyad Rebuild operations, Dyad implements an Auto-Deny mechanism:

    1. Detection: Dyad reads .modules.yaml to identify packages that were implicitly ignored during the initial install.
    2. Recording: Dyad automatically records an explicit pkg: false decision in the pnpm-workspace.yaml file under the allowBuilds map. This entry is placed outside the Dyad-managed block and includes a Dyad marker.
    3. Result: This explicit denial silences both the ERR_PNPM_IGNORED_BUILDS error and the pnpm warning, ensuring that subsequent pnpm install commands (without special Dyad flags) succeed while maintaining the security posture of skipping unapproved build scripts.

    Note on Rebuilds: A standard pnpm install on an "already up to date" environment exits 0 and does not re-evaluate build scripts. To force a previously skipped build to run, you must use pnpm rebuild <pkg>.

    # Example of what Dyad records in pnpm-workspace.yaml
    allowBuilds:
      # dyad-managed-block-start
      # ... existing allowed builds ...
      # dyad-managed-block-end
    
      # dyad-auto-deny-marker
      core-js: false
  11. How the i18n namespace strategy works

    main

    Dyad uses a namespace strategy where each translation file represents a specific feature area (a namespace). This allows for manageable file sizes and lazy-loading of translations for specific routes.

    Common namespaces include:

    • common: Buttons, generic labels, navigation.
    • settings: Settings page sections.
    • chat: Chat UI elements.
    • home: Home page and app lists.
    • errors: Toast messages and error dialogs.
    • hub: Marketplace/library.
    • integrations: Connector-specific strings (GitHub, Supabase, etc.).
  12. Chat-stream status and error handling assumptions

    main

    The chat-stream implementation relies on the following settled assumptions (from G1a):

    • Authority: StreamState is the sole authority for streaming status.
    • Idle State: An idle state is defined by the absence of a controller or read-model entry.
    • Status Access: Status reads must use the G1a selectors and facade.
    • Error Handling: External errors must enter the machine as an event, following the bounded last-error behavior defined in G1a.