### Install Dependencies with Bun Source: https://github.com/macintushar/draw/blob/main/README.md Install all project dependencies using Bun. This command should be run after cloning the repository. ```bash bun install ``` -------------------------------- ### Build the App with Bun Source: https://github.com/macintushar/draw/blob/main/README.md Use this command to build the application for deployment. Ensure Bun is installed. ```bash bun run build ``` -------------------------------- ### Set Up Environment Variables Source: https://github.com/macintushar/draw/blob/main/README.md Copy the example environment file to create your own. This file should contain your Supabase and Sentry credentials. ```bash cp .env.example .env ``` -------------------------------- ### Run the Development Server Source: https://github.com/macintushar/draw/blob/main/README.md Start the development server to run the application locally. The app will be accessible at http://localhost:5173. ```bash bun run dev ``` -------------------------------- ### Rename Environment File Source: https://github.com/macintushar/draw/blob/main/docs/docker.md Rename the example environment file to .env to configure your Draw instance. ```bash mv .env.example .env ``` -------------------------------- ### Start Draw with Docker Compose Source: https://github.com/macintushar/draw/blob/main/docs/docker.md This command starts the Draw application in detached mode using Docker Compose. ```bash docker-compose up -d ``` -------------------------------- ### Retrieve User Profile Source: https://context7.com/macintushar/draw/llms.txt Fetches current user profile or session data. Includes an example of integration with TanStack Query. ```typescript // src/db/auth.ts export async function getUser() { const { data, error } = await supabase.auth.getUser(); return { data, error }; } export async function getLocalUser() { const { data, error } = await supabase.auth.getSession(); return { data, error }; } // Usage with TanStack Query: import { useQuery } from "@tanstack/react-query"; import { getUser } from "@/db/auth"; const { data, isLoading } = useQuery({ queryKey: ["user"], queryFn: getUser, refetchOnMount: true, refetchOnWindowFocus: true, }); // Access user data: const userName = data?.data?.user?.user_metadata.name; const userEmail = data?.data?.user?.email; ``` -------------------------------- ### Convert Mermaid Syntax to Excalidraw Elements Source: https://context7.com/macintushar/draw/llms.txt Converts Mermaid diagram syntax into Excalidraw elements. Ensure Excalidraw and the mermaid-to-excalidraw library are installed. The function parses the syntax and updates the Excalidraw scene. ```typescript // src/views/Mermaid.tsx import { parseMermaidToExcalidraw } from "@excalidraw/mermaid-to-excalidraw"; import { convertToExcalidrawElements, Excalidraw } from "@excalidraw/excalidraw"; import { ExcalidrawImperativeAPI } from "@excalidraw/excalidraw/types"; import { createNewPage } from "@/db/draw"; import { useState } from "react"; export default function Mermaid() { const [mermaidSyntax, setMermaidSyntax] = useState(""); const [excalidrawAPI, setExcalidrawAPI] = useState(); async function generateExcalidraw() { if (mermaidSyntax.length > 0) { try { const { elements, files } = await parseMermaidToExcalidraw(mermaidSyntax); const convertedElements = convertToExcalidrawElements(elements); excalidrawAPI?.updateScene({ elements: convertedElements, appState: { fileHandle: files }, }); } catch (e) { console.error("Conversion error:", e); } } } async function handleSaveAsNewPage() { const elements = excalidrawAPI?.getSceneElements(); const files = excalidrawAPI?.getFiles(); const result = await createNewPage(elements, files); if (result.data?.[0]?.page_id) { // Navigate to new page } } return (