# DrawDB Reader

Reads DrawDB schema files and extracts database schema information.

## Overview

The DrawDB Reader parses JSON files exported from DrawDB (a free online database design tool) and converts them into RelSpec's internal database model representation.

## Features

- Parses DrawDB JSON format
- Extracts tables, fields, and relationships
- Supports DrawDB-specific metadata
- Preserves visual layout information

## Usage

### Basic Example

```go
package main

import (
    "fmt"
    "git.warky.dev/wdevs/relspecgo/pkg/readers"
    "git.warky.dev/wdevs/relspecgo/pkg/readers/drawdb"
)

func main() {
    options := &readers.ReaderOptions{
        FilePath: "/path/to/diagram.json",
    }

    reader := drawdb.NewReader(options)
    db, err := reader.ReadDatabase()
    if err != nil {
        panic(err)
    }

    fmt.Printf("Found %d schemas\n", len(db.Schemas))
}
```

### CLI Example

```bash
# Read DrawDB export and convert to JSON schema
relspec --input drawdb --in-file diagram.json --output json --out-file schema.json

# Convert DrawDB design to GORM models
relspec --input drawdb --in-file design.json --output gorm --out-file models.go
```

## Example DrawDB Export

DrawDB exports database designs as JSON files containing:

```json
{
  "tables": [
    {
      "id": "1",
      "name": "users",
      "fields": [
        {
          "name": "id",
          "type": "BIGINT",
          "primary": true,
          "autoIncrement": true
        },
        {
          "name": "username",
          "type": "VARCHAR",
          "size": 50,
          "notNull": true,
          "unique": true
        }
      ]
    }
  ],
  "relationships": [
    {
      "source": "posts",
      "target": "users",
      "type": "many-to-one"
    }
  ]
}
```

## Notes

- DrawDB is a free online database designer at drawdb.vercel.app
- Export format preserves visual design metadata
- Useful for converting visual designs to code
- Schema defaults to `public`
