An interactive web-based tool designed to teach and test Theory of Computation (TOC) concepts through visualization and simulation. This modern platform bridges the gap between abstract theoretical models and practical understanding.
- Automata Design & Simulation: Create and simulate DFA, NFA, and finite automata with intuitive drag-and-drop interface
- Step-by-Step Execution: Trace input processing with pause, play, and rewind controls for better understanding
- Interactive Visualization: Real-time state highlighting and transition visualization using ReactFlow
- Model Validation: Real-time syntax checking and automata correctness validation
- Cloud Storage: Save and share projects via Firebase Firestore integration
- Modern UI/UX: Clean, responsive design with light/dark theme support
- Keyboard Shortcuts: Efficient workflow with comprehensive keyboard shortcuts
- Error Detection: Real-time validation with detailed error feedback
- Export/Import: Save automata as JSON files for sharing and backup
- Context Menus: Right-click context menus for quick actions
- Auto-Layout: Automatic graph layout using Dagre algorithm
- Frontend: Next.js 15 with Turbopack, React 18, TypeScript
- Visualization: ReactFlow for interactive graph editing
- Styling: Tailwind CSS with custom animations
- UI Components: Radix UI primitives with custom styling
- Backend: Firebase (Firestore for data storage)
- Animation: Framer Motion for smooth transitions
- Icons: Lucide React icon library
- Deployment: Vercel with automatic CI/CD
- Node.js 18+
- npm or yarn
- Firebase project (for full functionality)
- Clone the repository:
git clone https://github.com/SifatAli008/TOC-Simulator.git
cd TOC-Simulator- Install dependencies:
npm install --legacy-peer-deps-
Set up Firebase environment variables (optional for basic functionality): Create a
.env.localfile in the root directory:NEXT_PUBLIC_FIREBASE_API_KEY=your_api_key NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN=your_project.firebaseapp.com NEXT_PUBLIC_FIREBASE_PROJECT_ID=your_project_id NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET=your_project.firebasestorage.app NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID=your_sender_id NEXT_PUBLIC_FIREBASE_APP_ID=your_app_id NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID=G-your_measurement_id
-
Start the development server:
npm run dev- Open http://localhost:3000 in your browser.
- Navigate to the Simulator page from the dashboard
- Click on the canvas to add states (nodes)
- Right-click on states to set as initial or final states
- Click "Add Transition" button to enter transition mode
- Click and drag between states to create transitions
- Double-click transitions to edit their symbols
- Enter an input string in the input field
- Click "Simulate" to run the automaton simulation
- Use the simulation controls (play, pause, step) to control execution
- View real-time state highlighting and step-by-step results
- Check the final result (Accept/Reject) and execution trace
- Ctrl/Cmd + N: Add new state
- Ctrl/Cmd + T: Toggle transition mode
- Ctrl/Cmd + S: Save automaton
- Delete: Remove selected elements
- Escape: Cancel current operation
- Use Save button to store automata in Firebase
- Load previously saved automata from your collection
- Export automata as JSON files for backup
- Import JSON files to restore automata
src/
โโโ app/ # Next.js app directory
โ โโโ dashboard/ # Dashboard page
โ โโโ simulator/ # Main simulator page
โ โโโ globals.css # Global styles
โ โโโ layout.tsx # Root layout
โ โโโ page.tsx # Home page (redirects to dashboard)
โ โโโ not-found.tsx # 404 page
โโโ components/ # React components
โ โโโ automata/ # Automata-specific components
โ โ โโโ nodes/ # ReactFlow node components
โ โ โโโ edges/ # ReactFlow edge components
โ โ โโโ *.tsx # Editor, viewer, and control components
โ โโโ layout/ # Layout components (Header, Footer)
โ โโโ ui/ # Reusable UI components (6 essential components)
โ โโโ ErrorBoundary.tsx # Error boundary component
โโโ contexts/ # React contexts
โ โโโ ThemeContext.tsx # Theme management
โโโ lib/ # Utility libraries
โ โโโ firebase.ts # Firebase configuration
โ โโโ firebase-operations.ts # Firebase CRUD operations
โ โโโ simulation.ts # Core simulation engine
โ โโโ validation.ts # Automata validation logic
โ โโโ utils.ts # Utility functions
โโโ types/ # TypeScript type definitions
โโโ automata.ts # Automata type definitions
npm run dev- Start development server with Turbopacknpm run build- Build for production with Turbopacknpm run start- Start production servernpm run lint- Run ESLintnpm run lint:fix- Run ESLint with auto-fixnpm run type-check- Run TypeScript type checkingnpm run deploy- Deploy to Vercel
- AutomataEditor: Main editor interface with drag-and-drop functionality and state management
- AutomataFlow: ReactFlow-based interactive graph editor with custom nodes and edges
- SimulationViewer: Step-by-step simulation visualization with playback controls
- SimulationEngine: Core simulation logic for DFA/NFA execution and validation
- StateNode: Custom ReactFlow node component for automata states
- TransitionEdge: Custom ReactFlow edge component for transitions
- ThemeProvider: Dark/light mode theme management with system preference detection
- Interactive DFA/NFA editor with ReactFlow
- Step-by-step simulation with playback controls
- Modern responsive UI with light/dark themes
- Firebase integration for cloud storage
- Real-time validation and error detection
- Keyboard shortcuts and accessibility features
- Auto-layout with Dagre algorithm
- Context menus and intuitive UX
- NFA to DFA conversion algorithm with visualization
- Regular expression parsing and conversion to automata
- Enhanced simulation analytics and statistics
- Undo/Redo functionality
- Automata templates and examples library
- Pushdown Automata (PDA) support
- Context-Free Grammar simulation
- Turing Machine implementation
- Multi-user real-time collaboration
- Mobile-responsive design improvements
- API for external integrations
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
Please ensure your code follows the existing style and includes appropriate tests.
The application is automatically deployed to Vercel with the following configuration:
Set these in your Vercel dashboard or deployment platform:
NEXT_PUBLIC_FIREBASE_API_KEY
NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN
NEXT_PUBLIC_FIREBASE_PROJECT_ID
NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET
NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID
NEXT_PUBLIC_FIREBASE_APP_ID
NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID
- Framework: Next.js
- Build Command:
npm run build - Output Directory:
.next - Node Version: 18.x
This project is licensed under the MIT License - see the LICENSE file for details.
- Inspired by JFLAP and other educational automata tools
- Built with modern React and Next.js ecosystem
- UI components based on Radix UI primitives
- Graph visualization powered by ReactFlow
- Designed with accessibility and usability in mind
- ๐ Issues: GitHub Issues
- ๐ฌ Discussions: GitHub Discussions
- ๐ Documentation: Check the code comments and component documentation
TOC Simulator - Making Theory of Computation accessible through interactive visualization and modern web technologies.