ERAI is a web application that transforms converts English descriptions of database schemas into Entity-Relationship Diagrams (ERDs). Simply describe your tables and relationships in plain English, and ERAI will generate a clean, downloadable SVG diagram for you.
- Natural Language Processing: Leverages Gemini AI to understand your database descriptions.
- DBML Generation: Converts your text into a valid Database Markup Language (DBML) schema.
- SVG Diagram Rendering: Automatically generates a clear and professional SVG diagram from the DBML.
- Downloadable Assets: Allows you to download the generated SVG diagram for use in documentation, presentations, or other projects.
- Simple & Fast: A streamlined interface for quick diagram generation without complex tools.
The application follows a secure, server-centric architecture to process user requests:
- Frontend (React): The user enters description into the text area and submits the form.
- Backend API Call #1 (Node.js/Express): The frontend sends the user's text to a custom backend endpoint (
/api/generate-dbml-from-text). - Secure LLM Call: The backend server securely calls the Google Gemini API with the user's text and a specialized prompt. The server uses an API key stored safely in an
.envfile. - DBML Response: The Gemini API returns the generated DBML code as a string back to the backend server.
- Backend API Call #2 (Node.js/Express): The frontend receives the DBML string and immediately sends it to a second backend endpoint (
/api/render-dbml). - SVG Generation: The backend saves the DBML to a temporary file and uses the
@softwaretechnik/dbml-renderercommand-line tool to generate an SVG file on the server. - SVG URL Response: The backend returns the public URL of the newly created SVG file to the frontend.
- Display Diagram: The React frontend receives the SVG URL and displays the diagram to the user.
- Frontend:
- React
- Backend:
- Node.js
- Express
- APIs & Tools:
- Google Gemini API: For natural language to DBML conversion.
- @softwaretechnik/dbml-renderer: For DBML to SVG rendering.
- Node.js and npm (or yarn) installed.
- A Google Gemini API Key.
-
Navigate to the backend directory:
cd backend -
Install dependencies:
npm install
-
Create an environment file: Create a file named
.envin thebackenddirectory.touch .env
-
Add your API Key: Add your Google Gemini API key to the
.envfile.# backend/.env GEMINI_API_KEY="YOUR_GEMINI_API_KEY_HERE" -
Run the backend server:
node index.js
The server should now be running on
http://localhost:4000.
-
Navigate to the frontend directory:
cd ../frontend -
Install dependencies:
npm install
-
Run the frontend development server:
npm run dev # or if using Create React App # npm start
The React app should now be running on
http://localhost:3000.
Once both servers are running, open your browser and navigate to the frontend URL (e.g., http://localhost:5173).
- Type a description of your database schema into the text area.
- Click the "Generate Diagram" button.
- The loading indicator will appear while the request is processed.
- The generated ER diagram will be displayed on the screen.
- Click the "Download SVG" button to save the diagram to your computer.
- Export as PNG: Add a feature to convert the SVG to a PNG format on the client-side using a canvas.
- DBML Preview & Edit: Show the generated DBML in a syntax-highlighted editor and allow the user to make manual edits before rendering the final diagram.
- Enhanced Error Handling: Provide more specific error messages to the user if the DBML is invalid or the LLM fails.