Skip to content

Add structured text output for AI model context #120

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

mathijso
Copy link

@mathijso mathijso commented Mar 11, 2025

Add structured text output for AI model context

Description

This PR adds automatic structured text output for AI models when using a .txt file extension:

When a filename with a .txt extension is provided, the package automatically generates a structured Markdown representation of the ER diagram that is specifically formatted to be used as context for AI models.

Why

When working with AI models like ChatGPT or Claude, providing structured context about database relationships can significantly improve the quality of generated code. This feature allows developers to easily generate documentation about their database structure that can be fed directly to AI assistants.

Changes

  • Added automatic detection of .txt file extension to generate structured output
  • Added generateStructuredTextRepresentation method to GraphBuilder class
  • Updated README with documentation for the new functionality
  • Added tests for the new functionality

Example Output

The structured output format looks like this:

# Entity Relationship Diagram

## Entities

### User (`App\Models\User`)

#### Attributes:
- `id` (integer)
- `name` (string)
- `email` (string)
...

## Relationships

### User Relationships
- **HasMany** `posts` to Post (Local Key: `id`, Foreign Key: `user_id`)
...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant