├── .editorconfig ├── .gitignore ├── .husky └── pre-commit ├── .prettierrc ├── LICENSE ├── README.md ├── index.html ├── package.json ├── pnpm-lock.yaml ├── postcss.config.js ├── public └── favicon.svg ├── src ├── App.css ├── App.tsx ├── components │ ├── Editor.tsx │ ├── Header.tsx │ ├── Panels.tsx │ ├── Preferences.tsx │ ├── Renderer │ │ ├── CustomEdge.tsx │ │ ├── CustomHandle.tsx │ │ ├── ModelNode.tsx │ │ ├── Renderer.tsx │ │ ├── RendererWrapper.tsx │ │ └── index.ts │ ├── Share.tsx │ └── Sidebar.tsx ├── edge-segment-cache.ts ├── examples.ts ├── hooks │ ├── useDebounced.ts │ ├── useFullscreen.ts │ ├── useIsMobile.ts │ └── useMediaQuery.ts ├── index.css ├── lib │ └── parser │ │ ├── ModelParser.test.ts │ │ ├── ModelParser.ts │ │ ├── Parser.test.ts │ │ └── Parser.ts ├── main.tsx ├── monaco-vim.d.ts ├── reactflow.css ├── stores │ ├── documents.ts │ ├── graph.ts │ └── user-options.ts ├── themes │ ├── index.ts │ ├── solarized-dark.json │ ├── solarized-light.json │ ├── vs-dark.json │ └── vs-light.json ├── types.ts ├── utils │ └── svg-export.ts └── vite-env.d.ts ├── tailwind.config.js ├── tsconfig.json ├── tsconfig.node.json └── vite.config.ts /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | charset = utf-8 5 | end_of_line = lf 6 | insert_final_newline = true 7 | indent_style = space 8 | indent_size = 2 9 | trim_trailing_whitespace = true 10 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | pnpm-debug.log* 8 | lerna-debug.log* 9 | 10 | node_modules 11 | dist 12 | dist-ssr 13 | *.local 14 | 15 | # Editor directories and files 16 | .vscode/* 17 | !.vscode/extensions.json 18 | .idea 19 | .DS_Store 20 | *.suo 21 | *.ntvs* 22 | *.njsproj 23 | *.sln 24 | *.sw? 25 | 26 | stats.html 27 | coverage 28 | -------------------------------------------------------------------------------- /.husky/pre-commit: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | . "$(dirname -- "$0")/_/husky.sh" 3 | 4 | npx vitest run 5 | npx lint-staged 6 | -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "trailingComma": "es5", 3 | "tabWidth": 2, 4 | "semi": true, 5 | "singleQuote": false, 6 | "printWidth": 110, 7 | "quoteProps": "as-needed", 8 | "bracketSpacing": true, 9 | "bracketSameLine": false, 10 | "arrowParens": "always", 11 | "useTabs": false 12 | } 13 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # TSDiagram 2 | 3 | **TSDiagram** is an online tool that helps you draft diagrams quickly by using TypeScript. 4 | \ 5 | :point_right: https://tsdiagram.com 6 | 7 | ### **Features** 8 | 9 | - Lets you define your data models through **top-level type aliases**, **interfaces**, and **classes**. 10 | - Automatically layouts the nodes in an efficient way. 11 | - ...but if you move one of the nodes manually, it will only auto-layout the other ones. 12 | - Persists the document state in the URL and localStorage. 13 | - Export your diagrams as SVG. 14 | 15 | ### **Roadmap** 16 | 17 | - Function call representation 18 | - Customizable TypeScript context (lib, etc.) 19 | - Bring your own storage (different vendors) 20 | 21 | --- 22 | 23 | > This project is not just a diagramming tool, but also the foundation for a greater code visualization project. 24 | > Imagine flagging types and functions in your code editor and see how they are connected, and how data flows through them. 25 | > That's the end goal, so we'll swap the TS compiler with Tree-sitter in the process. 26 | 27 | --- 28 | 29 |  30 | 31 | ### Test links 32 | 33 | - [Default example](https://tsdiagram.com/#/N4IgJg9gxgrgtgUwHYBcDOIBcBtUBLMLEACwBsBrAIQEFi4AFAKwEMBGAJwGEEAzU2AO6UAqiAA0IFHhSkERAOoJ+EROJBoIMdlDmYQeVAnY9mOgAQA5CGARngAHSRmzBTGbQp2BgOYBuR84ADswoxG4eXkh+Ae6a2gjhnj7+TmbeCChmiC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Sy1SkIHkYh8kwgYDwZDwKSwAEYAOwABgATAA2AAszA1Ro1AA4DXrgodpLB1OpkCgttB4M7lIRMCRyNR6Ew2Fw+EJRBJgkA) 35 | - [Type aliases](https://tsdiagram.com/#/N4IgJg9gxgrgtgUwHYBcDOIBcBtUBLMLEACwCYB2AJQC0BPAMQGYJTSBpALwHEEB1AQ14BRAI4BOEABoQKPCgA2CIgBVaABwQACAILy8-NAgzS0EGACcoSzDPVbtmgLyah58xHOaAZJuAAdJE0gzUMANwRzOVpMTT8QAHd+cyQ8JABzOM0AH1iQCPdzTJy4gDN+FH55OIBuAIBfAJQ7TQAhJx1apEbmgGF2-0Dg-hjtTuDNACMYlrHg8wQoDzAYygWlgB40FEj0yU0AEQA+eoDujQP2rZ206qkQeQMUAFkIMDwSvARCTABGcgAGUgANgALGJSGJyGJGD86gBdaSwNzIFD7aDwFEASW+JAoNAYzFYnB4AmE4hAdSAA) 36 | - [Interfaces and classes extends & implements](https://tsdiagram.com/#/N4IgJg9gxgrgtgUwHYBcDOIBcBtUBLMLEAKQFYBJAIwBEAOAOQC8ANAfSloFkAVAZgCsAwlABijAIwgANCBR4UAGwREAogA8UyMGgAEAMh144AByWJUGGWggwATlGWYQUBQEM0ugII7gOgGYQEJg6aCi2eEgA5gDcOgC+ADpILu66AEI+OpSutgAUAJTBoeFRmSgAFrYQAO46SAi1KrZVefmxcfFJKR46gjoIGlpehiZmyOg6Gb7ZrZm2CCh2SDoJINmMq+2dSEkRmrZ+rg46zD5JOhf+gUVhETFJiUh7CAdHCDoAmmfLlzM3JfckI9nq9jgAtfqDJDaE5ST7fS5ZVyMf53aIPaQgNyhTgQMB4Px4BCETDiADsAAYAEwANgALABOXhUqmkcQ0uIAXRksGa42o0Hg43IJJIFBoDBY7C4fCEogkIDiQA) 37 | 38 | ### Special thanks <3 39 | 40 | - [TypeScript](https://www.typescriptlang.org/) 41 | - [React Flow](https://reactflow.dev) 42 | - [Monaco](https://github.com/microsoft/monaco-editor) 43 | - [elkjs](https://github.com/kieler/elkjs) 44 | - [dom-to-svg](https://github.com/felixfbecker/dom-to-svg) 45 | -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 | 6 | 7 | 8 | 9 |