+
Skip to content

tobiager/Erdus

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Erdus

Universal ER Diagram Converter

Also available in SpanishDemoDocsContributingRoadmap

One IR to map them all. Erdus is the open-source universal converter for ER diagrams and database schemas.

It unifies ERDPlus, SQL DDL, Prisma, TypeORM, JSON Schema and more under a strict Intermediate Representation (IR).

Build once, convert everywhere.

erdus.v1.mp4
  • 100% client side (privacy): files never leave the browser.
  • Input: .erdplus or .json files (format detected automatically).
  • Output: file with the extension matching the desired target format (e.g., name-old.erdplus, schema.sql, schema.prisma).
  • Relationships: draws a single link for each FK (including composites) and anchors it to the actual child columns.

Available modules

  • ERDPlus Old ⇄ New (bundled)
  • SQL (PostgreSQL DDL)
  • Prisma
  • TypeORM (IR → entity models)
  • DBML (for dbdiagram.io)
  • Mermaid ER (for documentation)

Project structure

Erdus/
├──  src/                    # Core application source
│   ├──  converters/         # Format conversion modules
│   ├──  components/         # React UI components  
│   ├──  pages/              # Application pages
│   ├──  utils/              # Utility functions
│   ├──  types/              # TypeScript definitions
│   └──  docs/               # In-app documentation
├──  examples/               # Example schemas & conversions
│   ├──  blog/               # Blog system example
│   ├──  ecommerce/          # E-commerce schema
│   └──  school/             # Educational system
├──  tests/                  # Comprehensive test suite
├──  docs/                   # Documentation website (Docusaurus)
├──  public/                 # Static assets
└──  assets/                 # README images & media

Supported Formats

Input Formats → Intermediate Representation → Output Formats

graph LR
    subgraph "Input"
        A[ERDPlus Old]
        B[ERDPlus New] 
        C[SQL DDL]
        D[Prisma]
        E[TypeORM]
    end
    
    subgraph "Core"
        IR[Intermediate<br/>Representation]
    end
    
    subgraph "Output"
        F[SQL DDL]
        G[Prisma]
        H[TypeORM]
        I[DBML]
        J[Mermaid]
    end
    
    A --> IR
    B --> IR
    C --> IR
    D --> IR
    E --> IR
    
    IR --> F
    IR --> G
    IR --> H
    IR --> I
    IR --> J
Loading
Format Input Output Use Case
ERDPlus Educational projects, visual design
SQL DDL Database creation, migrations
Prisma Modern Node.js development
TypeORM Enterprise TypeScript apps
DBML Documentation with dbdiagram.io
Mermaid README files, technical docs

Demo

Tip

In ERDPlus (new version) choose Menu → Restore → Upload to open the converted file. Positions, types, constraints and connections remain intact.


ERDPlus module features

  • Automatic detection of the input format (old or new).
  • Old → New: tables → nodes, attributes → columns, simple or composite FKs → a single grouped edge with stable foreignKeyGroupId.
  • New → Old: edges → FK attributes and connectors with fkSubIndex to preserve order.
  • Deterministic IDs for columns in NEW (c-<tableId>-<attrId>) allowing ERDPlus to anchor lines and tag columns as (FK).
  • Private by design: all processing happens locally; there is no backend or file upload.
  • Works on Windows, macOS and Linux. Vite's dev server provides instant HMR.
## ERDPlus module: how it works

Old → New (identical visuals)

  1. Reads shapes[] tables and creates nodes with id = t-<id> and columns id = c-<tableId>-<attrId>.
  2. Reconstructs FKs prioritizing connectors[] (source of truth in Old).
    • Groups by (child → parent), orders by fkSubIndex and generates a single edge per composite FK.
    • Uses the real child column ID in foreignKeyProps.columns[].id; ERDPlus draws the line and labels (FK).
  3. Assigns a stable foreignKeyGroupId based on the child, parent and ordered set of attributes.

New → Old (equivalent structure)

  1. Converts nodes and columns to tables and attributes preserving PK, UNIQUE, NULL and types.
  2. From each edge creates FK attributes in the child table with references pointing to the parent's PK and fkSubIndex following the edge column order.
  3. Creates connectors per FK column so that legacy viewers can draw the connections.

Guarantees

  • Round-trip old → new → old without loss: structure, keys, order and positions are preserved.
  • Round-trip new → old → new: nodes, edges and FK columns are preserved.
  • The “new” JSON may differ in internal invisible IDs but is visually and semantically equivalent.

SQL module features

  • Auto-detects PostgreSQL CREATE TABLE scripts.
  • IR ⇔ SQL: converts the canonical IR to PostgreSQL DDL and parses SQL back to IR.
  • Preserves PK, FK and unique constraints.
## SQL module: how it works

SQL → IR

  1. Scans CREATE TABLE statements and builds tables and columns.
  2. Reads FOREIGN KEY clauses to reconstruct relationships.

IR → SQL

  1. Iterates tables and columns to output CREATE TABLE definitions.
  2. Emits ALTER TABLE for composite FKs and indexes.

Prisma module features

  • Auto-detects Prisma schema files.
  • IR ⇔ Prisma: generates Prisma models from IR and parses schemas back.
  • Maps SQL types to Prisma scalars and relations.
## Prisma module: how it works

Prisma → IR

  1. Parses model blocks extracting fields, types and relations.

IR → Prisma

  1. Generates model blocks with @id, @unique and @relation attributes.

TypeORM module features

  • Auto-detects TypeORM entity classes.
  • IR ⇔ TypeORM: generates entity models and parses them back to IR.
  • Maps SQL types to TypeScript types and decorators, preserving relations and indexes.
## TypeORM module: how it works

TypeORM → IR

  1. Parses @Entity classes to extract columns and relations.
  2. Reconstructs @ManyToOne/@OneToMany links via @JoinColumn, marking optional fields.

IR → TypeORM

  1. Emits @Entity classes with @Column, @PrimaryColumn and @PrimaryGeneratedColumn decorators.
  2. Generates @ManyToOne/@OneToMany relations and @Index declarations.
  3. Maps SQL types to TypeORM types and adds nullable/unique options.

Open source & scalable

  • MIT-licensed with a lightweight, modular core.
  • New converters or exporters can plug in as simple modules.
  • Ships a CLI and minimal API so it fits CI/CD pipelines, serverless functions or container clusters.

Quick Start

Web Interface (Recommended)

Get started in seconds with our web interface:

  1. Visit erdus-inky.vercel.app
  2. Upload your ER diagram or schema file
  3. Select your desired output format
  4. Download the converted result

Local Installation

For development or offline use:

# Clone and install
git clone https://github.com/tobiager/Erdus.git
cd Erdus
npm install --legacy-peer-deps

# Start development server
npm run dev
# → Open http://localhost:5173

Programmatic Usage

import { erdplusToIR, irToSQL, irToPrisma } from 'erdus';

// Convert ERDPlus to SQL
const erdplusData = JSON.parse(fileContent);
const schema = erdplusToIR(erdplusData);
const sqlScript = irToSQL(schema);

// Or convert to Prisma
const prismaSchema = irToPrisma(schema);

Development Resources


Testing the conversion

  1. Open the local app at http://localhost:5173.
  2. Drag or select a .erdplus file (old or new) and press Convert.
  3. *-new.erdplus or *-old.erdplus will download automatically as appropriate.
  4. In ERDPlus new: Restore → Upload to verify the diagram is identical.

On Windows/PowerShell, if peer dependency conflicts appear, pin ESLint 8.57:

npm i -D eslint@8.57.0
npm i

Deploy on Vercel

  1. Import the repository (Framework: Vite).
  2. Build: npm run build
  3. Output directory: dist/

vercel.json already points to dist/.


Privacy & security

  • Processing happens entirely in your browser.
  • No files are sent to any server, not even Vercel.
  • You can use it offline with npm run build followed by npm run preview.

Known limitations

  • ERDPlus (new version) may route lines differently (curves) but connections and cardinalities are correct.
  • If your NEW file comes from another tool with proprietary IDs, the converter will not clone those IDs. They are invisible and do not affect rendering.

Roadmap — Universal Converter

Phase 0 – What exists today (base)

  • ERDPlus old ⇄ new
  • ✅ Full support for PK, FK, unique groups
  • ✅ Lossless round-trip
  • Audience: students, teachers, university exercises

Phase 1 – “Useful + viral” MVP

Goal: anyone can use it online and get value right away

  • Canonical IR (v1) → core
  • ✅ IR → PostgreSQL DDL → generate real CREATE TABLE
  • ✅ IR → Prisma schema → connect with Next.js/TypeScript
  • ✅ Web demo (Vercel) → drag & drop, result tabs, loss report
  • ✅ Simple CLI (erdus convert ...)
  • Attracts: fullstack devs, indie hackers, students → first stars

Phase 2 – Import & documentation

Goal: import existing models and document them

  • ✅ PostgreSQL DDL → IR (robust parser)
  • ✅ IR → dbml → use in dbdiagram.io
  • ✅ IR → Mermaid ER → document in Markdown/repos
  • ✅ Complete examples (blog, e‑commerce, school)
  • Attracts: devs who document, OSS maintainers → visibility on GitHub

Phase 3 – Developer ecosystem

Goal: be useful in pipelines and serious projects

  • IR → JSON Schema (APIs, validation)
  • ✅ IR → TypeORM models
  • IR → Sequelize models
  • IR → Supabase schema (+ optional RLS policies)
  • Diff/Migration plan: compare two IR → SQL ALTER script
  • Attracts: startups, SaaS projects → stars from productive folks

Phase 4 – Advanced / killer features

Goal: expand to NoSQL and modern APIs

  • IR ↔ Mongoose schemas (MongoDB)
  • IR ↔ OpenAPI schemas
  • IR ↔ GraphQL SDL
  • Visualizer: basic web editor with interactive ERD view
  • Attracts: modern devs, API/GraphQL community
  • This is where ERDUS could become the OSS standard

Recommended release order

  1. Phase 1 (MVP): Postgres + Prisma + web demo (fast value, viral)
  2. Phase 2: Documentation (dbml/Mermaid) → virality on GitHub/Reddit
  3. Phase 3: JSON Schema + Supabase + Diff → serious devs
  4. Phase 4: MongoDB + GraphQL + Visualizer → universal suite consolidation

Growth strategy

  • Each phase = a release with changelog and post on Reddit/HN/Twitter
  • README with short GIFs (drag & drop, instant output)
  • CI badges + online demo → trust
  • “Good first issues” to invite PRs → community

Contributing

Contribute

Please read the Contributing Guide before getting started.

  1. Fork and create a feat/my-improvement branch.
  2. Run npm i and npm run dev.
  3. Include an example .erdplus file when relevant.
  4. Open a PR — contributions are welcome!

Top Contributors

Thanks to everyone who contributes to the growth of this project. Your contribution can also be included here!


License

MIT — see LICENSE.

点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载