### Install Dependencies Source: https://github.com/matserdam/prisma-neighbourhood/blob/main/sources/prisma-neighborhood/docs/development.md Install project dependencies using Bun. ```bash bun install ``` -------------------------------- ### Install Bun and Dependencies Source: https://github.com/matserdam/prisma-neighbourhood/blob/main/CONTRIBUTING.md Install the Bun JavaScript runtime and project dependencies using 'bun install'. ```bash # Install Bun if you haven't already curl -fsSL https://bun.sh/install | bash # Navigate to the package directory cd sources/prisma-neighbourhood # Install dependencies bun install ``` -------------------------------- ### Install Globally and Run Source: https://github.com/matserdam/prisma-neighbourhood/blob/main/sources/prisma-neighborhood/README.md Installs the package globally using npm and then runs the `prisma-hood` command. This allows using the short alias for the CLI. ```bash npm install -g @matserdam/prisma-neighborhood prisma-hood -s ./prisma/schema.prisma -m User ``` -------------------------------- ### Install globally Source: https://github.com/matserdam/prisma-neighbourhood/blob/main/README.md Install the prisma-neighbourhood CLI tool globally using npm. This makes the command available system-wide. ```bash npm install -g @matserdam/prisma-neighborhood ``` -------------------------------- ### Run without installing Source: https://github.com/matserdam/prisma-neighbourhood/blob/main/README.md Execute the prisma-neighbourhood CLI tool directly using 'bunx' without a global installation. This is the recommended way to use the tool. ```bash bunx @matserdam/prisma-neighborhood [options] ``` -------------------------------- ### Start from a View Source: https://github.com/matserdam/prisma-neighbourhood/blob/main/sources/prisma-neighborhood/README.md Generates an ERD starting from a view, traversing up to a specified depth. This includes related enums and models. ```bash bunx @matserdam/prisma-neighborhood -s ./prisma/schema.prisma -m UserSummary -d 2 ``` -------------------------------- ### Install PNG/PDF Export Dependencies on Linux Source: https://github.com/matserdam/prisma-neighbourhood/blob/main/docs/llm/prisma-neighbourhood.md Install necessary dependencies for PNG and PDF export on Debian/Ubuntu or Alpine Linux systems. ```bash # Debian/Ubuntu sudo apt-get install libnss3 libatk1.0-0 libatk-bridge2.0-0 libcups2 \ libdrm2 libxkbcommon0 libxcomposite1 libxdamage1 libxrandr2 libgbm1 \ libasound2 libpangocairo-1.0-0 libgtk-3-0 # Alpine apkg add chromium ``` -------------------------------- ### CI Workflow Configuration Source: https://github.com/matserdam/prisma-neighbourhood/blob/main/docs/ci-and-release.md This YAML file defines the continuous integration workflow, including triggers, setup steps, dependency installation, building, testing, and linting. ```yaml name: CI on: push: branches: [ main ] pull_request: branches: [ main ] jobs: build: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Setup Node.js and Bun uses: actions/setup-node@v4 with: node-version: '20' - run: curl -fsSL https://bun.sh/install | bash - name: Install dependencies run: |+ if [ -f "pnpm-lock.yaml" ]; then echo "Using pnpm" bun install --frozen-lockfile elif [ -f "bun.lockb" ]; then echo "Using bun" bun install --frozen-lockfile else echo "Using npm" npm install --prefer-offline fi - name: Build project run: bun run build - name: Run tests if: steps.install.outputs.package-manager == 'npm' || steps.install.outputs.package-manager == 'bun' || steps.install.outputs.package-manager == 'pnpm' run: bun run test - name: Run lint if: steps.install.outputs.package-manager == 'npm' || steps.install.outputs.package-manager == 'bun' || steps.install.outputs.package-manager == 'pnpm' run: bun run lint ``` -------------------------------- ### Local Development Build Command Source: https://github.com/matserdam/prisma-neighbourhood/blob/main/docs/ci-and-release.md Commands to install dependencies and build the project locally within the 'sources/prisma-neighbourhood' directory. ```bash cd sources/prisma-neighbourhood bun install bun run build ``` -------------------------------- ### Start from an Enum Source: https://github.com/matserdam/prisma-neighbourhood/blob/main/sources/prisma-neighborhood/README.md Generates an ERD starting from an enum, traversing to find all models/views that use it and their related entities, up to a specified depth. ```bash bunx @matserdam/prisma-neighborhood -s ./prisma/schema.prisma -m UserRole -d 2 ``` -------------------------------- ### Commit Message Type Example Source: https://github.com/matserdam/prisma-neighbourhood/blob/main/AGENT.md Provides an example of a commit message using the 'test' type and referencing an epic. ```git test(mermaid): add output format integration tests Covers Mermaid syntax generation for various relation types. Part of epic: CLI-MVP ``` -------------------------------- ### Plan Migration Order Source: https://github.com/matserdam/prisma-neighbourhood/blob/main/docs/llm/prisma-neighbourhood.md Use this command to plan the migration order based on a relationship graph, starting from a specified model and depth. ```bash bunx @matserdam/prisma-neighbourhood -s schema.prisma -m Inventory -d 2 -o migration-scope.png ``` -------------------------------- ### Run with Bun Source: https://github.com/matserdam/prisma-neighbourhood/blob/main/sources/prisma-neighborhood/README.md Generates a Mermaid ERD to standard output using Bun. Requires specifying the schema path and the starting model. ```bash bunx @matserdam/prisma-neighborhood -s ./prisma/schema.prisma -m User ``` -------------------------------- ### Commit Message Format Example Source: https://github.com/matserdam/prisma-neighbourhood/blob/main/AGENT.md Illustrates the conventional commit message format with type, scope, subject, and optional body/footer. ```git feat(traversal): add depth-limited model traversal Implements BFS traversal from a starting model with configurable max depth. Tracks visited models to prevent cycles. Closes #12 ``` -------------------------------- ### Rendered View Example Source: https://github.com/matserdam/prisma-neighbourhood/blob/main/llms.txt How a Prisma view like 'UserSummary' is rendered in the ERD diagram, indicating its type and fields. ```plaintext " [view] UserSummary" { Int id UK String email UserRole role } ``` -------------------------------- ### Mermaid ER Diagram Example Source: https://github.com/matserdam/prisma-neighbourhood/blob/main/README.md This is an example of an ERD generated in Mermaid syntax. It shows the 'User' model, the '[enum] UserRole', and the '[view] UserSummary', along with their relationships. ```mermaid erDiagram User { Int id PK String email UK String name UserRole role } "[enum] UserRole" { UserRole ADMIN UserRole USER } "[view] UserSummary" { Int id UK String email UserRole role } User }o--|| "[enum] UserRole" : "role" "[view] UserSummary" }o--|| "[enum] UserRole" : "role" ``` -------------------------------- ### Prisma Model Definition Example Source: https://github.com/matserdam/prisma-neighbourhood/blob/main/docs/llm/prisma-neighbourhood.md Example of Prisma model definitions. Model names are case-sensitive and should be used exactly as defined in schema.prisma. ```prisma model User { ... } model OrderItem { } ``` -------------------------------- ### Prisma View Definition Source: https://github.com/matserdam/prisma-neighbourhood/blob/main/llms.txt Example of a Prisma view definition for 'UserSummary', including its fields and relation to 'UserRole'. ```prisma view UserSummary { id Int @unique email String role UserRole } ``` -------------------------------- ### Rendered Enum Example Source: https://github.com/matserdam/prisma-neighbourhood/blob/main/llms.txt How a Prisma enum like 'UserRole' is rendered in the ERD diagram, showing its values. ```plaintext " [enum] UserRole" { UserRole ADMIN UserRole USER UserRole GUEST } ``` -------------------------------- ### Verify CLI Shebang Source: https://github.com/matserdam/prisma-neighbourhood/blob/main/docs/ci-and-release.md Checks the first line of the compiled CLI JavaScript file to ensure it starts with the correct shebang for execution. ```bash head -1 dist/cli.js # Should output: #!/usr/bin/env node ``` -------------------------------- ### Prisma Enum Definition Source: https://github.com/matserdam/prisma-neighbourhood/blob/main/llms.txt Example of a Prisma enum definition for 'UserRole', listing its possible values. ```prisma enum UserRole { ADMIN USER GUEST } ``` -------------------------------- ### Auto-Regenerate ERD on Schema Changes (Linux) Source: https://github.com/matserdam/prisma-neighbourhood/blob/main/llms.txt Bash script using inotifywait to automatically regenerate an ERD when the Prisma schema file changes. Requires inotify-tools to be installed. ```bash #!/bin/bash # watch-schema-linux.sh - Auto-regenerate AnalyticsEvent ERD on schema changes SCHEMA_PATH="./prisma/schema.prisma" MODEL="AnalyticsEvent" DEPTH=1 OUTPUT="./docs/analytics-event-erd.svg" regenerate() { echo "[$(date '+%H:%M:%S')] Schema changed, regenerating $MODEL ERD..." bunx @matserdam/prisma-neighborhood -s "$SCHEMA_PATH" -m "$MODEL" -d "$DEPTH" -o "$OUTPUT" echo "[$(date '+%H:%M:%S')] Done: $OUTPUT" } # Generate initial diagram regenerate # Watch for changes (Linux - install with: apt install inotify-tools) echo "Watching $SCHEMA_PATH for changes..." while inotifywait -e modify,close_write "$SCHEMA_PATH" 2>/dev/null; do regenerate done ``` -------------------------------- ### Auto-Regenerate ERD on Schema Changes (macOS) Source: https://github.com/matserdam/prisma-neighbourhood/blob/main/llms.txt Bash script using fswatch to automatically regenerate an ERD when the Prisma schema file changes. Requires fswatch to be installed. ```bash #!/bin/bash # watch-schema.sh - Auto-regenerate AnalyticsEvent ERD on schema changes SCHEMA_PATH="./prisma/schema.prisma" MODEL="AnalyticsEvent" DEPTH=1 OUTPUT="./docs/analytics-event-erd.svg" regenerate() { echo "[$(date '+%H:%M:%S')] Schema changed, regenerating $MODEL ERD..." bunx @matserdam/prisma-neighborhood -s "$SCHEMA_PATH" -m "$MODEL" -d "$DEPTH" -o "$OUTPUT" echo "[$(date '+%H:%M:%S')] Done: $OUTPUT" } # Generate initial diagram regenerate # Watch for changes (macOS - install with: brew install fswatch) echo "Watching $SCHEMA_PATH for changes..." fswatch -o "$SCHEMA_PATH" | while read -r; do regenerate done ``` -------------------------------- ### Auto-Regenerate ERD on Schema Changes (entr) Source: https://github.com/matserdam/prisma-neighbourhood/blob/main/llms.txt Bash script using entr for a cross-platform solution to automatically regenerate an ERD when the Prisma schema file changes. Requires entr to be installed. ```bash #!/bin/bash # watch-schema-entr.sh - Auto-regenerate AnalyticsEvent ERD on schema changes SCHEMA_PATH="./prisma/schema.prisma" MODEL="AnalyticsEvent" DEPTH=1 OUTPUT="./docs/analytics-event-erd.svg" # Install entr: brew install entr (macOS) or apt install entr (Linux) echo "Watching $SCHEMA_PATH for changes... (Ctrl+C to stop)" echo "$SCHEMA_PATH" | entr -c bunx @matserdam/prisma-neighborhood \ -s "$SCHEMA_PATH" \ -m "$MODEL" \ -d "$DEPTH" \ -o "$OUTPUT" ``` -------------------------------- ### Shell Script for Schema Watching Source: https://github.com/matserdam/prisma-neighbourhood/blob/main/llms.txt This script monitors a Prisma schema file for modifications and regenerates ERDs. It uses stat to get the modification time and polls at a specified interval. ```shell # Get initial modification time get_mtime() { stat -c %Y "$SCHEMA_PATH" 2>/dev/null || stat -f %m "$SCHEMA_PATH" 2>/dev/null } LAST_MTIME=$(get_mtime) regenerate # Initial generation echo "Watching $SCHEMA_PATH (polling every ${POLL_INTERVAL}s)..." while true; do sleep "$POLL_INTERVAL" CURRENT_MTIME=$(get_mtime) if [ "$CURRENT_MTIME" != "$LAST_MTIME" ]; then LAST_MTIME="$CURRENT_MTIME" regenerate fi done ``` -------------------------------- ### Build Project Source: https://github.com/matserdam/prisma-neighbourhood/blob/main/CONTRIBUTING.md Build the project to generate distributable files including CLI entry points and type declarations. ```bash bun run build ``` -------------------------------- ### Visualize Product table dependencies Source: https://github.com/matserdam/prisma-neighbourhood/blob/main/docs/llm/prisma-neighbourhood.md Generate a diagram showing all tables that cascade from the 'Product' table. This is useful for planning database migrations. ```bash bunx @matserdam/prisma-neighborhood -s schema.prisma -m Product -d 3 ``` -------------------------------- ### Clone the Repository Source: https://github.com/matserdam/prisma-neighbourhood/blob/main/CONTRIBUTING.md Clone your forked repository locally to begin development. ```bash git clone https://github.com/YOUR_USERNAME/erd-cli.git cd erd-cli ``` -------------------------------- ### Onboarding: Authentication domain Source: https://github.com/matserdam/prisma-neighbourhood/blob/main/llms.txt Generate an SVG diagram for the authentication domain, focusing on the 'User' model and its neighborhood up to depth 2. ```bash bunx @matserdam/prisma-neighborhood -s schema.prisma -m User -d 2 -o docs/auth-domain.svg ``` -------------------------------- ### Run Tests Source: https://github.com/matserdam/prisma-neighbourhood/blob/main/sources/prisma-neighborhood/docs/development.md Execute all project tests using Bun. ```bash bun test ``` -------------------------------- ### Run CLI Locally Source: https://github.com/matserdam/prisma-neighbourhood/blob/main/CONTRIBUTING.md Execute the CLI directly from source or after building. Use the '-s' flag for the schema path and '-m' for the model. ```bash # Run directly from source bun run dev -- -s ./examples/blog.prisma -m User # Or build first bun run build ./dist/cli.js -s ./examples/blog.prisma -m User ``` -------------------------------- ### Local CLI Test Command Source: https://github.com/matserdam/prisma-neighbourhood/blob/main/docs/ci-and-release.md Demonstrates how to run the CLI tool locally, either directly using 'bun run dev' or after building the project using the generated 'dist/cli.js' file. ```bash # Run directly bun run dev -- --schema ./examples/blog.prisma --model Post --depth 2 # Or after build ./dist/cli.js --schema ./examples/blog.prisma --model Post --depth 2 ``` -------------------------------- ### List Renderers Source: https://github.com/matserdam/prisma-neighbourhood/blob/main/sources/prisma-neighborhood/README.md Lists all available renderers and indicates which ones support PNG/PDF export. ```bash bunx @matserdam/prisma-neighborhood --list-renderers ``` -------------------------------- ### Determine models for User service Source: https://github.com/matserdam/prisma-neighbourhood/blob/main/docs/llm/prisma-neighbourhood.md Generate a PNG diagram showing models within 3 hops of 'User'. This aids in defining the scope of the User microservice. ```bash bunx @matserdam/prisma-neighborhood -s schema.prisma -m User -d 3 -o services/user-service.png ``` -------------------------------- ### Local Package Creation Source: https://github.com/matserdam/prisma-neighbourhood/blob/main/docs/ci-and-release.md Command to create a local .tgz archive of the npm package, useful for testing before publishing. ```bash npm pack # Creates matserdam-prisma-neighborhood-x.x.x.tgz ``` -------------------------------- ### Export ERD to PDF (Blog) Source: https://github.com/matserdam/prisma-neighbourhood/blob/main/sources/prisma-neighborhood/examples/README.md Generates a full ERD for the blog schema, focusing on the User model with a maximum depth of 5, and exports it as a PDF file. ```bash # Full blog ERD bun src/index.ts -s examples/blog.prisma -m User -d 5 -o examples/blog-erd.pdf ``` -------------------------------- ### Onboarding: Order processing domain Source: https://github.com/matserdam/prisma-neighbourhood/blob/main/llms.txt Generate an SVG diagram for the order processing domain, focusing on the 'Order' model and its neighborhood up to depth 2. ```bash bunx @matserdam/prisma-neighborhood -s schema.prisma -m Order -d 2 -o docs/orders-domain.svg ``` -------------------------------- ### Run Specific Test File Source: https://github.com/matserdam/prisma-neighbourhood/blob/main/sources/prisma-neighborhood/docs/development.md Execute a specific test file using Bun. ```bash bun test src/_tests_/parser.test.ts ``` -------------------------------- ### Export as SVG Source: https://github.com/matserdam/prisma-neighbourhood/blob/main/llms.txt Generate a diagram for the 'User' model and export it as an SVG file, recommended for highest quality. ```bash bunx @matserdam/prisma-neighborhood -s ./prisma/schema.prisma -m User -o docs/erd.svg ``` -------------------------------- ### Generate authentication domain diagram Source: https://github.com/matserdam/prisma-neighbourhood/blob/main/docs/llm/prisma-neighbourhood.md Create a diagram focusing on the authentication domain by visualizing relationships around the 'User' model up to depth 2. This helps isolate specific functional areas. ```bash bunx @matserdam/prisma-neighborhood -s schema.prisma -m User -d 2 -o docs/auth-domain.png ``` -------------------------------- ### Determine models for Order service Source: https://github.com/matserdam/prisma-neighbourhood/blob/main/docs/llm/prisma-neighbourhood.md Generate a PNG diagram showing models within 3 hops of 'Order'. This helps identify which models should belong to the Order microservice. ```bash bunx @matserdam/prisma-neighborhood -s schema.prisma -m Order -d 3 -o services/order-service.png ``` -------------------------------- ### Run Tests Source: https://github.com/matserdam/prisma-neighbourhood/blob/main/CONTRIBUTING.md Execute all tests once or use watch mode for continuous testing during development. ```bash # Run all tests once bun run test # Run tests in watch mode during development bun run test:watch ``` -------------------------------- ### Documentation Directory Structure Source: https://github.com/matserdam/prisma-neighbourhood/blob/main/AGENT.md Specifies the directory structure for documentation files. ```bash docs/ ├── specs/ # Specifications and requirements ├── adr/ # Architecture Decision Records └── guides/ # Usage guides and tutorials ``` -------------------------------- ### Project Structure Directory Source: https://github.com/matserdam/prisma-neighbourhood/blob/main/AGENT.md Defines the directory structure for the CLI application and documentation. ```bash sources/prisma-subgraph-cli/ # CLI application (schema parsing, traversal, rendering) ├── src/ │ ├── _tests_/ # Test files │ ├── index.ts # Entry point │ └── ... ├── package.json └── tsconfig.json ``` -------------------------------- ### npm Scripts for ERD Generation and Watching Source: https://github.com/matserdam/prisma-neighbourhood/blob/main/llms.txt Integrate ERD generation and watching into your package.json scripts for convenient command-line access. Supports direct generation and watching via fswatch or inotifywait. ```json { "scripts": { "erd:generate": "bunx @matserdam/prisma-neighborhood -s ./prisma/schema.prisma -m AnalyticsEvent -d 1 -o ./docs/analytics-event-erd.svg", "erd:watch": "fswatch -o ./prisma/schema.prisma | xargs -n1 -I{} npm run erd:generate", "erd:watch:linux": "while inotifywait -e modify ./prisma/schema.prisma; do npm run erd:generate; done" } } ``` -------------------------------- ### Export ERD to PNG (Blog) Source: https://github.com/matserdam/prisma-neighbourhood/blob/main/sources/prisma-neighborhood/examples/README.md Generates an ERD for the blog schema, focusing on the User model with a depth of 3, and exports it as a PNG image. ```bash # Blog ERD as PNG bun src/index.ts -s examples/blog.prisma -m User -d 3 -o examples/blog-erd.png ``` -------------------------------- ### Generate customer model diagram as PDF Source: https://github.com/matserdam/prisma-neighbourhood/blob/main/docs/llm/prisma-neighbourhood.md Produce a PDF document visualizing the 'Customer' model's relationships up to depth 2. This format is useful for formal documentation and printing. ```bash bunx @matserdam/prisma-neighborhood -s prisma/schema.prisma -m Customer -d 2 -o slides/customer-model.pdf ``` -------------------------------- ### Generate product model diagram for stakeholders Source: https://github.com/matserdam/prisma-neighbourhood/blob/main/docs/llm/prisma-neighbourhood.md Create a PNG diagram of the 'Product' model's neighborhood up to depth 2. This is suitable for communicating model structure to non-technical stakeholders. ```bash bunx @matserdam/prisma-neighborhood -s prisma/schema.prisma -m Product -d 2 -o slides/product-model.png ``` -------------------------------- ### Package JSON Build Script Source: https://github.com/matserdam/prisma-neighbourhood/blob/main/docs/ci-and-release.md Defines the build process for the npm package, including generating TypeScript declarations and bundling the CLI and library entry points using Bun. ```bash tsc --emitDeclarationOnly && \ bun build src/cli.ts --outfile dist/cli.js --target node && \ bun build src/index.ts --outfile dist/index.js --target node ``` -------------------------------- ### Package JSON Prepack Hook Source: https://github.com/matserdam/prisma-neighbourhood/blob/main/docs/ci-and-release.md The 'prepack' script automatically runs the build process before 'npm pack' or 'npm publish' to ensure the package is up-to-date. ```json "prepack": "bun run build" ``` -------------------------------- ### Generate ERD to Mermaid file (Blog) Source: https://github.com/matserdam/prisma-neighbourhood/blob/main/sources/prisma-neighborhood/examples/README.md Generates an ERD for the blog schema, focusing on the Post model, and saves it to a Mermaid file. ```bash # Blog schema bun src/index.ts -s examples/blog.prisma -m Post -o examples/blog-erd.mmd ``` -------------------------------- ### Visualize Order neighborhood before coupling change Source: https://github.com/matserdam/prisma-neighbourhood/blob/main/docs/llm/prisma-neighbourhood.md Generate an MMD diagram of the 'Order' model's neighborhood up to depth 2 before a relationship change. This serves as a baseline for coupling analysis. ```bash bunx @matserdam/prisma-neighborhood -s schema.prisma -m Order -d 2 -o before.mmd ``` -------------------------------- ### Export ERD to PNG (SaaS) Source: https://github.com/matserdam/prisma-neighbourhood/blob/main/sources/prisma-neighborhood/examples/README.md Generates an ERD for the SaaS schema, focusing on the Project model with a depth of 2, and exports it as a PNG image. ```bash # SaaS ERD as PNG bun src/index.ts -s examples/saas.prisma -m Project -d 2 -o examples/saas-erd.png ``` -------------------------------- ### Watch Tests Source: https://github.com/matserdam/prisma-neighbourhood/blob/main/sources/prisma-neighborhood/docs/development.md Run tests in watch mode using Bun for continuous feedback. ```bash bun test:watch ``` -------------------------------- ### Visualize models for microservice decomposition Source: https://github.com/matserdam/prisma-neighbourhood/blob/main/llms.txt Determine which models belong to a specific microservice by visualizing their clustered relationships. This aids in defining service boundaries. ```bash bunx @matserdam/prisma-neighborhood -s schema.prisma -m Order -d 3 -o services/order-service.svg ``` ```bash bunx @matserdam/prisma-neighborhood -s schema.prisma -m User -d 3 -o services/user-service.svg ``` -------------------------------- ### Visualize PR context for Order model Source: https://github.com/matserdam/prisma-neighbourhood/blob/main/docs/llm/prisma-neighbourhood.md Generate a PNG diagram showing models within 1 hop of the 'Order' model. This helps understand the scope of changes related to a Pull Request. ```bash bunx @matserdam/prisma-neighborhood -s schema.prisma -m Order -d 1 -o pr-context.png ``` -------------------------------- ### Identify Product aggregate root boundaries Source: https://github.com/matserdam/prisma-neighbourhood/blob/main/docs/llm/prisma-neighbourhood.md Generate an MMD diagram showing the neighborhood of the 'Product' aggregate root up to depth 3, useful for DDD bounded context analysis. ```bash bunx @matserdam/prisma-neighborhood -s schema.prisma -m Product -d 3 -o contexts/product-aggregate.mmd ``` -------------------------------- ### Generate ERD to stdout (Blog) Source: https://github.com/matserdam/prisma-neighbourhood/blob/main/sources/prisma-neighborhood/examples/README.md Generates an ERD for the blog schema, focusing on the User model with a depth of 2. Outputs directly to the console. ```bash # Blog: User and related models (depth 2) bun src/index.ts -s examples/blog.prisma -m User -d 2 ``` -------------------------------- ### Generate order processing domain diagram Source: https://github.com/matserdam/prisma-neighbourhood/blob/main/docs/llm/prisma-neighbourhood.md Visualize the order processing domain by generating a diagram centered on the 'Order' model with a depth of 2. This is useful for onboarding new developers to specific service areas. ```bash bunx @matserdam/prisma-neighborhood -s schema.prisma -m Order -d 2 -o docs/orders-domain.png ``` -------------------------------- ### Type Check Project Source: https://github.com/matserdam/prisma-neighbourhood/blob/main/sources/prisma-neighborhood/docs/development.md Perform a type check on the entire project using Bun. ```bash bun run typecheck ``` -------------------------------- ### Visualize Order neighborhood after coupling change Source: https://github.com/matserdam/prisma-neighbourhood/blob/main/docs/llm/prisma-neighbourhood.md Generate an MMD diagram of the 'Order' model's neighborhood up to depth 2 after a relationship change. This helps to check for unwanted dependencies introduced. ```bash bunx @matserdam/prisma-neighborhood -s schema.prisma -m Order -d 2 -o after.mmd ``` -------------------------------- ### Visualize aggregate root neighborhood for DDD Source: https://github.com/matserdam/prisma-neighbourhood/blob/main/llms.txt Identify bounded context boundaries in Domain-Driven Design by visualizing the neighborhood around each aggregate root. This helps in understanding the scope of each aggregate. ```bash bunx @matserdam/prisma-neighborhood -s schema.prisma -m Order -d 3 -o contexts/order-aggregate.mmd ``` ```bash bunx @matserdam/prisma-neighborhood -s schema.prisma -m User -d 3 -o contexts/user-aggregate.mmd ``` ```bash bunx @matserdam/prisma-neighborhood -s schema.prisma -m Product -d 3 -o contexts/product-aggregate.mmd ``` -------------------------------- ### Generate ERD to stdout (SaaS) Source: https://github.com/matserdam/prisma-neighbourhood/blob/main/sources/prisma-neighborhood/examples/README.md Generates an ERD for the SaaS schema, focusing on the Organization model with a depth of 2. Outputs directly to the console. ```bash # SaaS: Organization structure bun src/index.ts -s examples/saas.prisma -m Organization -d 2 ``` -------------------------------- ### Generate ERD to Mermaid file (E-commerce) Source: https://github.com/matserdam/prisma-neighbourhood/blob/main/sources/prisma-neighborhood/examples/README.md Generates an ERD for the e-commerce schema, focusing on the Product model, and saves it to a Mermaid file. ```bash # E-commerce schema bun src/index.ts -s examples/ecommerce.prisma -m Product -o examples/ecommerce-erd.mmd ``` -------------------------------- ### Automated ERD Generation in CI/CD Source: https://github.com/matserdam/prisma-neighbourhood/blob/main/docs/llm/prisma-neighbourhood.md Automate the generation of ERD documentation within a GitHub Actions workflow. Ensure the correct depth and output paths are specified. ```yaml # In GitHub Actions workflow - name: Generate ERD documentation run: | bunx @matserdam/prisma-neighborhood -s prisma/schema.prisma -m User -d 3 -o docs/generated/user-erd.png bunx @matserdam/prisma-neighborhood -s prisma/schema.schema.prisma -m Order -d 3 -o docs/generated/order-erd.png ``` -------------------------------- ### Package JSON Files Configuration Source: https://github.com/matserdam/prisma-neighbourhood/blob/main/docs/ci-and-release.md Specifies which files are included in the published npm package. Only the 'dist' directory, README, and LICENSE are included. ```json "files": ["dist", "README.md", "LICENSE"] ``` -------------------------------- ### Sync with Upstream and Create Branch Source: https://github.com/matserdam/prisma-neighbourhood/blob/main/CONTRIBUTING.md Before submitting changes, sync your local repository with the upstream main branch and create a new feature branch. ```bash git fetch upstream git rebase upstream/main ``` ```bash git checkout -b feature/your-feature-name ``` -------------------------------- ### Makefile Integration for ERD Generation and Watching Source: https://github.com/matserdam/prisma-neighbourhood/blob/main/llms.txt Add ERD generation and watching capabilities to your Makefile. Provides targets for single generation ('erd') and continuous watching ('erd-watch'). ```makefile SCHEMA := ./prisma/schema.prisma DOCS_DIR := ./docs .PHONY: erd erd-watch # Generate AnalyticsEvent ERD (depth 1) erd: @mkdir -p $(DOCS_DIR) bunx @matserdam/prisma-neighborhood -s $(SCHEMA) -m AnalyticsEvent -d 1 -o $(DOCS_DIR)/analytics-event-erd.svg @echo "Generated $(DOCS_DIR)/analytics-event-erd.svg" # Watch schema and auto-regenerate erd-watch: @echo "Watching $(SCHEMA) for changes..." @fswatch -o $(SCHEMA) | xargs -n1 -I{} make erd ``` -------------------------------- ### Identify Order aggregate root boundaries Source: https://github.com/matserdam/prisma-neighbourhood/blob/main/docs/llm/prisma-neighbourhood.md Visualize the neighborhood around the 'Order' aggregate root with a depth of 3. This aids in identifying bounded context boundaries in Domain-Driven Design. ```bash bunx @matserdam/prisma-neighborhood -s schema.prisma -m Order -d 3 -o contexts/order-aggregate.mmd ``` -------------------------------- ### Create Git Tag for Release Source: https://github.com/matserdam/prisma-neighbourhood/blob/main/docs/ci-and-release.md This command is used to create a new Git tag for a semantic version, which triggers the release workflow. ```bash git tag v1.0.0 git push origin v1.0.0 ``` -------------------------------- ### Release Workflow Configuration Source: https://github.com/matserdam/prisma-neighbourhood/blob/main/docs/ci-and-release.md This YAML file configures the automated release workflow, triggered by semantic version tags, which builds the package, creates GitHub releases, and handles npm publishing. ```yaml name: Release on: push: tags: - 'v*.*.* ' jobs: build: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Setup Node.js and Bun uses: actions/setup-node@v4 with: node-version: '20' - run: curl -fsSL https://bun.sh/install | bash - name: Install dependencies run: |+ if [ -f "pnpm-lock.yaml" ]; then echo "Using pnpm" bun install --frozen-lockfile elif [ -f "bun.lockb" ]; then echo "Using bun" bun install --frozen-lockfile else echo "Using npm" npm install --prefer-offline fi - name: Build project run: bun run build - name: Upload artifacts uses: actions/upload-artifact@v4 with: name: package path: dist/ github_release: needs: build runs-on: ubuntu-latest permissions: contents: write steps: - uses: actions/download-artifact@v4 with: name: package path: dist/ - name: Create GitHub Release uses: softprops/action-gh-release@v1 with: files: dist/* npm_publish: needs: build runs-on: ubuntu-latest steps: - uses: actions/download-artifact@v4 with: name: package path: dist/ - name: Publish to npm uses: JS-DevTools/npm-publish@v1 with: token: ${{ secrets.NPM_TOKEN }} package: dist/ ``` -------------------------------- ### Generate Mermaid Diagram for README Source: https://github.com/matserdam/prisma-neighbourhood/blob/main/docs/llm/prisma-neighbourhood.md Generate a Mermaid diagram for embedding in your README file, focusing on a specific model. ```bash bunx @matserdam/prisma-neighborhood -s prisma/schema.prisma -m Post -o README-diagram.mmd ``` -------------------------------- ### Push Tags for Release Source: https://github.com/matserdam/prisma-neighbourhood/blob/main/docs/ci-and-release.md Command to push the newly created Git tag to the remote repository, which triggers the release workflow. ```bash git tag vX.X.X git push origin main --tags ``` -------------------------------- ### Identify User aggregate root boundaries Source: https://github.com/matserdam/prisma-neighbourhood/blob/main/docs/llm/prisma-neighbourhood.md Visualize the neighborhood around the 'User' aggregate root with a depth of 3. This helps in defining bounded context boundaries for DDD. ```bash bunx @matserdam/prisma-neighborhood -s schema.prisma -m User -d 3 -o contexts/user-aggregate.mmd ``` -------------------------------- ### Type Checking and Linting Source: https://github.com/matserdam/prisma-neighbourhood/blob/main/CONTRIBUTING.md Perform type checking and linting using the provided commands. ```bash bun run typecheck ``` ```bash bun run lint ``` -------------------------------- ### Lint Code Source: https://github.com/matserdam/prisma-neighbourhood/blob/main/AGENT.md Run the linter to check for code style and potential errors. ```bash bun run lint ``` -------------------------------- ### Generate ERD to stdout (E-commerce) Source: https://github.com/matserdam/prisma-neighbourhood/blob/main/sources/prisma-neighborhood/examples/README.md Generates an ERD for the e-commerce schema, focusing on the Order model with a depth of 3. Outputs directly to the console. ```bash # E-commerce: Order flow bun src/index.ts -s examples/ecommerce.prisma -m Order -d 3 ``` -------------------------------- ### Polling-based ERD Watcher (Universal) Source: https://github.com/matserdam/prisma-neighbourhood/blob/main/llms.txt A universal bash script for watching Prisma schema changes and regenerating ERDs using a simple polling mechanism, requiring no external dependencies beyond bash. ```bash #!/bin/bash # watch-schema-poll.sh - Universal polling-based watcher SCHEMA_PATH="./prisma/schema.prisma" MODEL="AnalyticsEvent" DEPTH=1 OUTPUT="./docs/analytics-event-erd.svg" POLL_INTERVAL=2 regenerate() { bunx @matserdam/prisma-neighborhood -s "$SCHEMA_PATH" -m "$MODEL" -d "$DEPTH" -o "$OUTPUT" echo "[$(date '+%H:%M:%S')] Regenerated: $OUTPUT" } ``` -------------------------------- ### Export ERD to PNG (E-commerce) Source: https://github.com/matserdam/prisma-neighbourhood/blob/main/sources/prisma-neighborhood/examples/README.md Generates an ERD for the e-commerce schema, focusing on the Order model, and exports it as a PNG image. ```bash # E-commerce ERD as PNG bun src/index.ts -s examples/ecommerce.prisma -m Order -o examples/ecommerce-erd.png ``` -------------------------------- ### Implement Custom Diagram Renderer Source: https://github.com/matserdam/prisma-neighbourhood/blob/main/sources/prisma-neighborhood/docs/development.md Implement the DiagramRenderer interface to create a new custom renderer. This includes defining the renderer's name, description, rendering logic, and optionally export capabilities. ```typescript import type { DiagramRenderer, ExportFormat } from "./renderer/types"; import type { TraversedModel } from "./traversal/types"; export class MyRenderer implements DiagramRenderer { readonly name = "myrenderer"; readonly description = "My custom renderer"; render(models: readonly TraversedModel[]): string { // Generate diagram syntax from models return "..."; } supportsExport(): boolean { return false; // Set to true if you implement export() } // Optional: implement if supportsExport() returns true async export(content: string, outputPath: string, format: ExportFormat): Promise { // Render content to PNG/PDF file } } ``` -------------------------------- ### Visualize reporting view relationships Source: https://github.com/matserdam/prisma-neighbourhood/blob/main/llms.txt This command helps understand the connections of a specific reporting view within the schema. It visualizes the entities directly and indirectly related to the view. ```bash bunx @matserdam/prisma-neighborhood -s schema.prisma -m UserSummaryView -d 2 -o docs/summary-view.svg ``` -------------------------------- ### Generate Mermaid ERD syntax Source: https://github.com/matserdam/prisma-neighbourhood/blob/main/docs/llm/prisma-neighbourhood.md Produce ERD syntax in Mermaid format for a given schema, model, and depth. This output can be rendered by various tools. ```bash bunx @matserdam/prisma-neighborhood -s schema.prisma -m User -d 2 ``` -------------------------------- ### Add Upstream Remote Source: https://github.com/matserdam/prisma-neighbourhood/blob/main/CONTRIBUTING.md Add the original repository as an upstream remote to fetch updates. ```bash git remote add upstream https://github.com/ORIGINAL_OWNER/erd-cli.git ``` -------------------------------- ### Commit Changes for Release Source: https://github.com/matserdam/prisma-neighbourhood/blob/main/docs/ci-and-release.md Steps to commit version updates to the Git repository as part of the release process. ```bash git add . git commit -m "chore: bump version to x.x.x" ``` -------------------------------- ### Prisma schema with views preview feature Source: https://github.com/matserdam/prisma-neighbourhood/blob/main/llms.txt To ensure that views are recognized by prisma-neighborhood, enable the 'views' preview feature in your schema.prisma file within the generator client block. ```prisma generator client { provider = "prisma-client" previewFeatures = ["views"] } ``` -------------------------------- ### Analyze impact of Invoice model changes Source: https://github.com/matserdam/prisma-neighbourhood/blob/main/docs/llm/prisma-neighbourhood.md Generate a PNG diagram to analyze the impact radius of changes to the 'Invoice' model, showing relationships up to depth 2. ```bash bunx @matserdam/prisma-neighborhood -s schema.prisma -m Invoice -d 2 -o impact-analysis.png ``` -------------------------------- ### Export ERD to PDF Source: https://github.com/matserdam/prisma-neighbourhood/blob/main/sources/prisma-neighborhood/README.md Exports the generated ERD diagram to a PDF file. ```bash bunx @matserdam/prisma-neighborhood -s ./prisma/schema.prisma -m User -o erd.pdf ``` -------------------------------- ### Register New Renderer Source: https://github.com/matserdam/prisma-neighbourhood/blob/main/sources/prisma-neighborhood/docs/development.md Register a newly implemented custom renderer with the renderer registry. Ensure the renderer is not already registered before adding it. ```typescript import { rendererRegistry } from "./registry"; import { MyRenderer } from "./my-renderer"; // Register alongside existing renderers if (!rendererRegistry.has("myrenderer")) { rendererRegistry.register({ renderer: new MyRenderer(), }); } ``` -------------------------------- ### Find models using an enum Source: https://github.com/matserdam/prisma-neighbourhood/blob/main/llms.txt Use this command to find all models that utilize a specific enum. The depth parameter controls how many relationship levels are explored. ```bash bunx @matserdam/prisma-neighborhood -s schema.prisma -m OrderStatus -d 2 -o docs/order-status-usage.svg ``` -------------------------------- ### Find models using an enum Source: https://github.com/matserdam/prisma-neighbourhood/blob/main/llms.txt Use this command to find all models that utilize a specific enum. The depth parameter controls how many relationship levels are explored. ```bash bunx @matserdam/prisma-neighborhood -s schema.prisma -m UserRole -d 2 -o docs/role-usage.svg ``` -------------------------------- ### GitHub Actions Workflow for CI ERD Updates Source: https://github.com/matserdam/prisma-neighbourhood/blob/main/llms.txt Automate ERD regeneration within a GitHub Actions CI pipeline on pushes that modify the Prisma schema. Commits and pushes updated diagrams automatically. ```yaml # .github/workflows/update-erd.yml name: Update ERD Diagrams on: push: paths: - 'prisma/schema.prisma' jobs: update-erd: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: oven-sh/setup-bun@v1 - name: Regenerate AnalyticsEvent ERD run: | mkdir -p docs bunx @matserdam/prisma-neighborhood \ -s ./prisma/schema.prisma \ -m AnalyticsEvent \ -d 1 \ -o ./docs/analytics-event-erd.svg - name: Commit updated diagrams run: | git config user.name github-actions git config user.email github-actions@github.com git add docs/*.svg git diff --staged --quiet || git commit -m "chore: update ERD diagrams" git push ``` -------------------------------- ### Write Mermaid to File Source: https://github.com/matserdam/prisma-neighbourhood/blob/main/sources/prisma-neighborhood/README.md Writes the generated Mermaid ERD to a file. Use `.mmd` or `.md` extensions for Mermaid output. ```bash bunx @matserdam/prisma-neighborhood -s ./prisma/schema.prisma -m User -o erd.mmd ``` -------------------------------- ### Visualize models affected by a PR Source: https://github.com/matserdam/prisma-neighbourhood/blob/main/llms.txt When reviewing a Pull Request, use this to visualize the models that are touched by the changes, providing context for code review. ```bash bunx @matserdam/prisma-neighborhood -s schema.prisma -m Order -d 1 -o pr-context.svg ``` -------------------------------- ### Export ERD to PNG Source: https://github.com/matserdam/prisma-neighbourhood/blob/main/sources/prisma-neighborhood/README.md Exports the generated ERD diagram to a PNG image file. ```bash bunx @matserdam/prisma-neighborhood -s ./prisma/schema.prisma -m User -o erd.png ``` -------------------------------- ### Regenerate Multiple ERDs on Schema Changes Source: https://github.com/matserdam/prisma-neighbourhood/blob/main/llms.txt Bash script to regenerate ERDs for multiple specified models when the Prisma schema file changes. Uses fswatch for change detection. ```bash #!/bin/bash # watch-all-models.sh - Regenerate multiple ERDs on schema changes SCHEMA_PATH="./prisma/schema.prisma" OUTPUT_DIR="./docs" MODELS=("AnalyticsEvent" "User" "Order" "Product") regenerate_all() { mkdir -p "$OUTPUT_DIR" for model in "${MODELS[@]}"; do echo "Regenerating $model ERD (depth 1)..." bunx @matserdam/prisma-neighborhood \ -s "$SCHEMA_PATH" \ -m "$model" \ -d 1 \ -o "$OUTPUT_DIR/${model,,}-erd.svg" done echo "All diagrams regenerated at $(date '+%H:%M:%S')" } # Initial generation regenerate_all # Watch for changes echo "Watching $SCHEMA_PATH for changes..." fswatch -o "$SCHEMA_PATH" | while read -r; do regenerate_all done ``` -------------------------------- ### View Enum ERD Representation Source: https://github.com/matserdam/prisma-neighbourhood/blob/main/sources/prisma-neighborhood/README.md Shows how enums are rendered in the ERD, prefixed with '[enum]' and listing values with their type. ```plaintext "[enum] UserRole" { UserRole ADMIN UserRole USER UserRole GUEST } ``` -------------------------------- ### Git Pre-commit Hook for ERD Regeneration Source: https://github.com/matserdam/prisma-neighbourhood/blob/main/llms.txt Automatically regenerate and stage ERD diagrams before each commit if the Prisma schema has been modified. Ensures diagrams are up-to-date with schema changes. ```bash #!/bin/bash # .git/hooks/pre-commit - Regenerate ERDs before commit SCHEMA_PATH="./prisma/schema.prisma" # Check if schema was modified if git diff --cached --name-only | grep -q "schema.prisma"; then echo "Prisma schema changed, regenerating ERDs..." bunx @matserdam/prisma-neighborhood -s "$SCHEMA_PATH" -m AnalyticsEvent -d 1 -o ./docs/analytics-event-erd.svg # Stage regenerated files git add ./docs/*.svg echo "ERDs regenerated and staged." fi ``` -------------------------------- ### Basic ERD Regeneration Script Source: https://github.com/matserdam/prisma-neighbourhood/blob/main/llms.txt A reusable bash script to regenerate an ERD for a specific model. It takes schema path, model name, depth, and output directory as arguments. ```bash #!/bin/bash # regenerate-erd.sh - Regenerate ERD diagram for a specific model SCHEMA_PATH="${1:-./prisma/schema.prisma}" MODEL_NAME="${2:-User}" DEPTH="${3:-1}" OUTPUT_DIR="${4:-./docs}" mkdir -p "$OUTPUT_DIR" bunx @matserdam/prisma-neighborhood \ -s "$SCHEMA_PATH" \ -m "$MODEL_NAME" \ -d "$DEPTH" \ -o "$OUTPUT_DIR/${MODEL_NAME,,}-erd.svg" echo "Generated $OUTPUT_DIR/${MODEL_NAME,,}-erd.svg" ``` -------------------------------- ### Commit Changes Source: https://github.com/matserdam/prisma-neighbourhood/blob/main/CONTRIBUTING.md Commit your changes with clear, conventional commit messages indicating the type of change (feat, fix, docs). ```bash git commit -m "feat: add support for custom renderers" git commit -m "fix: handle self-referential relations" git commit -m "docs: update README with new options" ``` -------------------------------- ### View View ERD Representation Source: https://github.com/matserdam/prisma-neighbourhood/blob/main/sources/prisma-neighborhood/README.md Shows how views are rendered in the ERD, prefixed with '[view]' and listing fields with their type and constraints. ```plaintext "[view] UserSummary" { Int id UK String email } ``` -------------------------------- ### Analyze impact radius of changes Source: https://github.com/matserdam/prisma-neighbourhood/blob/main/llms.txt Check the impact radius of changes to a specific model by visualizing its related entities up to a certain depth. ```bash bunx @matserdam/prisma-neighborhood -s schema.prisma -m Invoice -d 2 -o impact-analysis.svg ``` -------------------------------- ### Reduce Diagram Scope with Depth Source: https://github.com/matserdam/prisma-neighbourhood/blob/main/docs/llm/prisma-neighbourhood.md If a diagram shows too many models, reduce the depth parameter to limit the scope to direct relations only. ```bash # Too much? Try depth 1 for direct relations only bunx @matserdam/prisma-neighborhood -s schema.prisma -m User -d 1 ``` -------------------------------- ### Parse Prisma Schema Source: https://github.com/matserdam/prisma-neighbourhood/blob/main/CONTRIBUTING.md Parses a Prisma schema file and extracts model information using TSDoc comments for documentation. ```typescript /** * Parses a Prisma schema file and extracts model information. * * @param options - Parser configuration options * @returns Parse result with schema or error */ export async function parseSchema(options: ParserOptions): Promise { // Step 1: Read the schema file const content = await readFile(options.schemaPath, "utf-8"); // Step 2: Parse using Prisma internals const dmmf = await getDMMF({ datamodel: content }); // Step 3: Transform to our internal representation return transformDMMF(dmmf); } ``` -------------------------------- ### Limit impact analysis depth Source: https://github.com/matserdam/prisma-neighbourhood/blob/main/llms.txt When a diagram shows too many models, reduce the depth parameter to limit the scope to direct relations only, making the analysis more focused. ```bash bunx @matserdam/prisma-neighborhood -s schema.prisma -m User -d 1 ``` -------------------------------- ### Export ERD to SVG Source: https://github.com/matserdam/prisma-neighbourhood/blob/main/sources/prisma-neighborhood/README.md Exports the generated ERD diagram to an SVG file, recommended for very large diagrams. ```bash bunx @matserdam/prisma-neighborhood -s ./prisma/schema.prisma -m User -o erd.svg ``` -------------------------------- ### Regenerate focused ERDs for documentation Source: https://github.com/matserdam/prisma-neighbourhood/blob/main/llms.txt Keep Entity-Relationship Diagrams (ERDs) in sync with the actual schema by regenerating focused diagrams from the current schema file. ```bash bunx @matserdam/prisma-neighborhood -s prisma/schema.prisma -m User -o docs/user-erd.svg ``` ```bash bunx @matserdam/prisma-neighborhood -s prisma/schema.prisma -m Order -o docs/order-erd.svg ``` -------------------------------- ### Generate Focused ERDs Source: https://github.com/matserdam/prisma-neighbourhood/blob/main/docs/llm/prisma-neighbourhood.md Regenerate focused Entity Relationship Diagrams (ERDs) from your current Prisma schema for specific models. ```bash bunx @matserdam/prisma-neighborhood -s prisma/schema.prisma -m User -o docs/user-erd.png ``` ```bash bunx @matserdam/prisma-neighborhood -s prisma/schema.prisma -m Order -o docs/order-erd.png ``` -------------------------------- ### Limit to Direct Relationships Source: https://github.com/matserdam/prisma-neighbourhood/blob/main/sources/prisma-neighborhood/README.md Generates an ERD limited to direct relationships (depth 1) from a specified model. ```bash bunx @matserdam/prisma-neighborhood -s ./prisma/schema.prisma -m User -d 1 ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.