Eflow is a high-fidelity, web-native Entity Relationship Diagram (ERD) modeling platform designed for database architects who demand precision, speed, and aesthetics. Built with Next.js and React Flow, it bridges the gap between complex enterprise tools and intuitive browser-based design.
Eflow provides a sophisticated workspace for designing, visualizing, and exporting database schemas. It features a smart relationship engine that automates the tedious parts of modeling—like Foreign Key assignment and cardinality notation—while maintaining a premium, responsive user interface.
Traditional browser-based ERD tools often suffer from:
- Fragile Relationship Logic: Most tools assign FKs based on the order of user clicks (Source -> Target), which often contradicts actual database dependency rules.
- Visual State Loss: Canvas objects like "Groups" often lose their dimensions or nested child nodes upon page refresh.
- Rendering Race Conditions: Dynamic addition of columns and relationships often leads to "Missing Handle" errors in React Flow because the UI hasn't finished mounting the handles when the edge is created.
- Smart Dependency Engine: Automate FK assignments based on semantic naming and existing schema structure rather than interaction order.
- Deep Persistence: Ensure every visual detail—from group dimensions to nesting hierarchy—is preserved across reloads.
- High-Fidelity Aesthetics: Deliver a premium UX that follows modern design systems (Shadcn UI, Radix) and provides immediate visual feedback.
- Seamless Integration: Support for DBML and SQL imports to allow architects to bring existing schemas to life instantly.
- Framework: Next.js 14+ (App Router)
- Canvas Engine: React Flow / XYFlow
- Database / ORM: PostgreSQL (Neon) & Prisma
- Styling: Tailwind CSS & Vanilla CSS for premium micro-animations
- UI Components: Shadcn UI & Radix UI
- State Management: Zustand
- Relational Engine Refactor: We moved away from simple connection events to a centralized
detectRelationshipDependencyalgorithm. This "brain" analyzes table names and column patterns to ensure the "Many" side always holds the Foreign Key. - Schema-First Persistence: Updated the database schema to support recursive
parentIdrelations, enabling stable node nesting within Group nodes. - Atomic Component Design: Built the UI using a feature-based atomic structure, separating atoms (Relationship Markers) from organisms (Table Nodes, Group Nodes).
- Synchronization Layer: Implemented a custom debounced sync hook that captures canvas changes and persists them to the PostgreSQL backend without impacting UI performance.
- The "Handle 008" Error: Encountered race conditions where edges were created before React Flow handles were rendered. Solution: Implemented a deferred state update strategy to ensure DOM readiness before edge instantiation.
- Group Clipping: Resizer handles were being cut off by parent containers. Solution: Refactored the
GroupNodeComponentto remove restrictiveovEflow-hiddenproperties and standardized on the React FlowNodeResizer. - TypeScript Nullability: Managing
string | undefinedvsstring | nullin React Flow's strict handle system. Solution: Enforced anullish coalescingstrategy in the canvas store to maintain runtime stability.
A robust, industry-standard modeling environment where:
- Relationships just work: Connecting
userstopostsautomatically placesuser_idin thepoststable with the correct cardinality. - Groups are stable: Complex organizational groups maintain their size and containment across sessions.
- UX is premium: Smooth transitions, clear iconography, and a responsive layout that scales with complex schemas.
- Architecture over Event-Handling: Designing a declarative relationship engine is significantly more scalable than handling individual click events.
- Schema Integrity: In canvas applications, the database schema must strictly reflect the visual hierarchy (e.g.,
parentId) to ensure the "Source of Truth" remains consistent between the DB and the DOM. - Atomic Thinking: Even in complex canvases, keeping components atomic (e.g., separating the Entity Action Box from the Table Card) makes debugging and styling significantly easier.
- Bun (Recommended) or Node.js
- PostgreSQL instance (Neon.tech recommended)
- Clone the repository
- Install dependencies:
bun install
- Set up your environment variables:
cp .env.example .env
- Run Prisma migrations:
bunx prisma migrate dev
- Start the development server:
bun --bun next dev
Follow the rules in .agents/rules/*.md for code quality, naming conventions, and project structure. Always ensure TypeScript strict mode is satisfied.