An interactive web-based simulator for Deterministic Finite Automata (DFA). This project allows users to visualize, create, and test finite automata with an intuitive graphical interface.
🔗 Live Demo: https://dfa-simulator67.netlify.app/
- Visual DFA Editor: Create and edit DFA diagrams with an interactive node-and-edge interface
- State Management: Add, remove, and configure states with support for final states
- Transition Definition: Create transitions between states with labeled inputs
- Self-Loop Support: Handle self-referencing transitions on individual states
- Simulation Mode: Test your DFA by providing input strings and stepping through execution
- Context Menu: Right-click menus for quick actions on nodes and edges
- Responsive Design: Clean, user-friendly interface built with React
- Frontend Framework: React 19.2.3
- Graph Visualization: @xyflow/react 12.10.0
- Routing: React Router DOM 6.30.2
- Build Tool: Create React App (react-scripts 5.0.1)
- Testing: React Testing Library 16.3.1
- Node.js (v14 or higher)
- npm or yarn
-
Clone the repository:
git clone <repository-url> cd dfa-simulator
-
Install dependencies:
npm install
Start the development server:
npm startThe application will open in your default browser at http://localhost:3000.
Create an optimized production build:
npm run builddfa-simulator/
├── src/
│ ├── App.js # Main app component with routing
│ ├── App.css # Application styles
│ ├── Simulator.js # Core DFA simulator component
│ ├── LandingPage.js # Welcome/landing page
│ ├── CircularNode.js # Custom node component for states
│ ├── SelfLoopEdge.js # Custom edge component for self-loops
│ ├── AdjustableBezierEdge.js # Custom edge component for transitions
│ ├── ContextMenu.js # Right-click context menu
│ ├── index.js # React entry point
│ └── index.css # Global styles
├── public/ # Static files
│ ├── index.html
│ ├── manifest.json
│ └── robots.txt
├── package.json # Project dependencies and scripts
└── README.md # This file
- Start on Landing Page: The application opens with a welcome page introducing the DFA simulator
- Access Simulator: Click to navigate to the simulator interface
- Create States: Click in the canvas to add new states (nodes)
- Mark Final States: Double-click a state to mark it as a final/accepting state
- Add Transitions: Click and drag from one state to another to create transitions, or to itself for self-loops
- Label Transitions: Input the symbol for each transition
- Test Your DFA: Switch to simulation mode and provide input strings to verify your automaton
npm start- Runs the app in development modenpm build- Builds the app for productionnpm test- Launches the test runnernpm eject- Ejects from Create React App (irreversible)
Contributions are welcome! Feel free to open issues or submit pull requests for improvements.
This project is open source and available under the MIT License.
- Self-loop transitions are rendered with special curvature to avoid overlapping with the state
- The simulator uses @xyflow/react for robust graph handling and visualization
- All transitions can be labeled with alphabet symbols