Skip to content

12asascoder/TURING-MACHINE

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

TuringMind - AI-Enhanced Turing Machine Platform

TuringMind Logo

A comprehensive platform for creating, visualizing, and simulating Turing Machines with AI-powered optimization and natural language understanding.

πŸš€ Features

πŸ€– AI-Powered Problem Solving

  • Natural Language Processing: Convert natural language descriptions into Turing Machine definitions
  • Intelligent Problem Analysis: AI analyzes problems and generates appropriate machine configurations
  • Smart State Generation: Automatically creates optimal states and transitions for specific operations
  • Operation Recognition: Supports binary arithmetic, string operations, pattern matching, and more

πŸ–₯️ Interactive Java GUI

  • Real-time Visualization: Step-by-step execution with visual tape representation
  • Multiple Operations: Support for addition, multiplication, subtraction, palindrome checking, string reversal, and pattern matching
  • User-Friendly Interface: Intuitive Swing-based GUI with operation selection and input fields
  • Detailed Execution Log: Complete step-by-step solution with tape content and state transitions
  • Auto-Solve Mode: Automatic execution with comprehensive logging

🌐 Multi-Service Architecture

  • Frontend: Next.js React application with modern UI
  • Middleware: Express.js server handling API routing and WebSocket connections
  • Java Backend: Core Turing Machine simulation engine with HTTP server
  • AI Service: TypeScript-based AI service for natural language processing

πŸ”§ Advanced Simulation Engine

  • Tape Management: Dynamic tape with configurable alphabet and blank symbols
  • State Machine: Complete state management with transitions and halting conditions
  • Step-by-Step Execution: Detailed simulation with transition logging
  • Error Handling: Comprehensive validation and error reporting

πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Frontend      β”‚    β”‚   Middleware    β”‚    β”‚  Java Backend   β”‚    β”‚   AI Service    β”‚
β”‚   (Next.js)     │◄──►│   (Express)     │◄──►│   (HttpServer)  │◄──►│  (TypeScript)   β”‚
β”‚   Port: 3000    β”‚    β”‚   Port: 5001    β”‚    β”‚   Port: 8080    β”‚    β”‚   Port: 3001    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ› οΈ Installation & Setup

Prerequisites

  • Node.js (v18+)
  • Java JDK 17+
  • Maven 3.6+
  • Git

Quick Start

  1. Clone the repository

    git clone https://github.com/12asascoder/TURING-MACHINE.git
    cd TURING-MACHINE
  2. Start all services

    ./start.sh
  3. Access the application

Manual Setup

  1. Install dependencies

    # Frontend
    cd frontend && npm install
    
    # Middleware
    cd server && npm install
    
    # AI Service
    cd ai-service && npm install
    
    # Java Backend
    cd backend-java && mvn clean compile
  2. Start services individually

    # Terminal 1 - Java Backend
    cd backend-java && mvn exec:java -Dexec.mainClass=com.turingmind.Main
    
    # Terminal 2 - AI Service
    cd ai-service && npm run dev
    
    # Terminal 3 - Middleware
    cd server && npm run dev
    
    # Terminal 4 - Frontend
    cd frontend && npm run dev

πŸ“– Usage

AI Assistant Workflow

  1. Open the application at http://localhost:3000
  2. Click "AI Assistant" to access the problem-solving interface
  3. Enter a problem in natural language, such as:
    • "Multiply 101 by 110"
    • "Check if 10101 is a palindrome"
    • "Reverse the string 'hello'"
    • "Find pattern 101 in 110101"
  4. Click "Generate Machine" to create the Turing Machine
  5. Java GUI opens automatically with the generated machine
  6. Select operation type and enter input in the GUI
  7. Execute step-by-step or use auto-solve mode

Supported Operations

  • Binary Arithmetic: Addition, multiplication, subtraction
  • String Operations: Reversal, palindrome checking
  • Pattern Matching: Finding patterns in strings
  • Custom Operations: Extensible for new problem types

API Endpoints

Middleware (Port 5001)

  • POST /solveProblem - Generate Turing Machine from natural language
  • POST /showGUI - Open Java GUI with machine
  • GET /health - Health check

Java Backend (Port 8080)

  • POST /simulate - Run Turing Machine simulation
  • POST /analyze - Analyze machine properties
  • POST /validate - Validate machine definition
  • POST /showGUI - Launch GUI window
  • GET /health - Health check

AI Service (Port 3001)

  • POST /solveProblem - AI problem analysis and machine generation
  • GET /health - Health check

πŸ”§ Configuration

Environment Variables

Create .env files in respective directories:

server/.env

PORT=5001
CORS_ORIGIN=http://localhost:3000
JAVA_BACKEND_URL=http://localhost:8080
AI_SERVICE_URL=http://localhost:3001

ai-service/.env

PORT=3001

frontend/.env.local

NEXT_PUBLIC_API_URL=http://localhost:5001
NEXT_PUBLIC_WS_URL=ws://localhost:5001

πŸ§ͺ Testing

Test the Complete Workflow

  1. Start all services using ./start.sh
  2. Open browser to http://localhost:3000
  3. Test AI Assistant:
    • Enter: "multiply 101 by 110"
    • Click "Generate Machine"
    • Verify Java GUI opens
    • Test step-by-step execution
  4. Test different operations:
    • Binary addition: "add 101 and 110"
    • Palindrome: "check if 10101 is palindrome"
    • String reversal: "reverse abc"

Health Checks

# Check all services
curl http://localhost:3000  # Frontend
curl http://localhost:5001/health  # Middleware
curl http://localhost:8080/health  # Java Backend
curl http://localhost:3001/health  # AI Service

πŸ“ Project Structure

TURING-MACHINE/
β”œβ”€β”€ frontend/                 # Next.js React application
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ components/      # React components
β”‚   β”‚   β”œβ”€β”€ services/        # API and WebSocket services
β”‚   β”‚   └── pages/           # Next.js pages
β”‚   └── package.json
β”œβ”€β”€ server/                   # Express.js middleware
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ controllers/     # API controllers
β”‚   β”‚   β”œβ”€β”€ services/        # Backend services
β”‚   β”‚   β”œβ”€β”€ middleware/      # Express middleware
β”‚   β”‚   └── types/           # TypeScript types
β”‚   └── package.json
β”œβ”€β”€ ai-service/              # AI processing service
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ services/        # AI services
β”‚   β”‚   β”œβ”€β”€ types/           # TypeScript types
β”‚   β”‚   └── index.ts         # Service entry point
β”‚   └── package.json
β”œβ”€β”€ backend-java/            # Java simulation engine
β”‚   β”œβ”€β”€ src/main/java/com/turingmind/
β”‚   β”‚   β”œβ”€β”€ Main.java        # HTTP server
β”‚   β”‚   β”œβ”€β”€ TuringMachine.java
β”‚   β”‚   β”œβ”€β”€ Simulator.java
β”‚   β”‚   β”œβ”€β”€ TuringMachineGUI.java
β”‚   β”‚   └── ...              # Other Java classes
β”‚   └── pom.xml
β”œβ”€β”€ start.sh                 # Platform startup script
└── README.md

🎯 Key Components

Frontend Components

  • AIAssistant: Main interface for problem input and machine generation
  • TuringMachineVisualizer: Visual representation of machines
  • SimulationControls: Execution controls and step-by-step simulation

Java Classes

  • Main: HTTP server with REST API endpoints
  • TuringMachine: Core machine definition and validation
  • Simulator: Step-by-step execution engine
  • TuringMachineGUI: Swing-based visualization interface
  • Tape: Dynamic tape management with snapshots

AI Services

  • ProblemSolvingService: Natural language to machine conversion
  • OptimizationService: Machine optimization algorithms
  • AnalysisService: Machine property analysis

πŸš€ Advanced Features

WebSocket Support

  • Real-time simulation updates
  • Live tape visualization
  • Step-by-step execution streaming

Machine Optimization

  • State reduction algorithms
  • Transition optimization
  • Performance analysis

Extensible Architecture

  • Plugin system for new operations
  • Custom machine types
  • API for third-party integrations

πŸ› Troubleshooting

Common Issues

  1. Port conflicts: Kill existing processes with pkill -9 -f "turingmind"
  2. Java backend not starting: Ensure JDK 17+ is installed and Maven dependencies are resolved
  3. GUI not opening: Check Java backend is running on port 8080
  4. AI service errors: Verify TypeScript compilation and dependencies

Debug Commands

# Check running processes
ps aux | grep -E "(turingmind|java|node)"

# Check port usage
lsof -i :3000  # Frontend
lsof -i :5001  # Middleware
lsof -i :8080  # Java Backend
lsof -i :3001  # AI Service

# View logs
tail -f server/logs/app.log

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature-name
  3. Commit changes: git commit -m "Add feature"
  4. Push to branch: git push origin feature-name
  5. Submit a pull request

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ™ Acknowledgments

  • Built with modern web technologies and Java
  • AI-powered problem solving capabilities
  • Comprehensive Turing Machine simulation engine
  • Real-time visualization and interaction

πŸ“ž Support

For issues and questions:

  • Create an issue on GitHub
  • Check the troubleshooting section
  • Review the API documentation

TuringMind - Where AI meets Turing Machine theory! πŸ§ πŸ€–

About

A java implementation of an ai based Turing machine with futuristic approach

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages