A comprehensive full-stack web application for creating, editing, and managing logic gate schematics using AI-assisted text-based input and visual canvas rendering. This project combines multiple technologies to provide an interactive platform for digital circuit design and education.
The above image shows the Homepage of the application where users will enter their text or prompt to start building their personalized schematic.
- Text-to-Schematic Conversion: Convert plain text descriptions into visual logic gate schematics
- AI-Powered Generation: Google Gemini AI integration for intelligent circuit suggestions
- Real-time Rendering: Dynamic canvas updates with automatic wire positioning and connections
- Project Management: Save, load, and manage multiple circuit projects
- User Authentication: Secure login/registration system with JWT tokens
- Multiple Gate Types: Support for AND, OR, NOT, NAND gates with customizable inputs/outputs
- Netlist Generation: Export circuit descriptions in standard netlist format
- Responsive Design: Mobile-friendly interface with Bootstrap styling
- Export Capabilities: Download schematics as text files and generate visual representations
- Gemini API: Google's AI model for intelligent circuit interpretation
- Natural Language Processing: Understands human-readable circuit descriptions
- Smart Gate Placement: AI suggests optimal gate positioning and connections
- Circuit Optimization: Intelligent suggestions for circuit improvements
This project follows a microservices architecture with multiple backend services:
┌─────────────────┐ ┌──────────────────┐ ┌──────────────────────┐
│ React Frontend│ │ Spring Boot API │ │ Playwright Service │
│ (Vite + Konva)│◄──►│ (Java 17) │◄──►│ (JavaScript) │
└─────────────────┘ └──────────────────┘ └──────────────────────┘
│ │ \ │
│ │ \ │
▼ ▼ \ ▼
┌─────────────────┐ ┌──────────────────┐ \ ┌─────────────────┐
│ Firebase │ │ PostgreSQL │ ▶ │ Gemini AI │
│ Hosting │ │ Database │ │ API │
└─────────────────┘ └──────────────────┘ └─────────────────┘
Logic-Gate-Schematic-Web-App/
├── logic-gates-app/ # React Frontend (Vite)
│ ├── src/
│ │ ├── components/ # UI Components
│ │ │ ├── header.jsx # Navigation header
│ │ │ ├── login.jsx # User authentication
│ │ │ ├── register.jsx # User registration
│ │ │ ├── landing-page.jsx # Welcome screen
│ │ │ ├── how-to-use.jsx # User guide
│ │ │ ├── chatbox.jsx # AI interaction
│ │ │ └── verify-page.jsx # Circuit verification
│ │ ├── konvaLogicGates/ # Canvas Components
│ │ │ ├── andGate.jsx # AND gate rendering
│ │ │ ├── orGate.jsx # OR gate rendering
│ │ │ ├── notGate.jsx # NOT gate rendering
│ │ │ ├── nandGate.jsx # NAND gate rendering
│ │ │ └── functions/ # Canvas utilities
│ │ ├── pages/
│ │ │ └── home.jsx # Main application page
│ │ ├── context/ # React Context providers
│ │ ├── utils/ # Utility functions
│ │ └── services/ # API service layer
│ ├── public/ # Static assets
│ └── package.json # Frontend dependencies
│
├── LogicGates-backend/ # Spring Boot Backend (Java)
│ └── LogicGates-backend/
│ ├── src/main/java/FYP/LogicGates/
│ │ ├── controller/ # REST API endpoints
│ │ ├── service/ # Business logic layer
│ │ ├── repository/ # Data access layer
│ │ ├── entity/ # JPA entities
│ │ ├── dto/ # Data transfer objects
│ │ ├── mapper/ # Object mappers
│ │ ├── config/ # Configuration classes
│ │ └── exception/ # Custom exceptions
│ ├── src/main/resources/ # Configuration files
│ └── pom.xml # Maven dependencies
│
├── gemini-API.js # Google Gemini AI integration
├── playwright-script.js # 3rd Party App Integration
├── Dockerfile # Container configuration
├── firebase.json # Firebase hosting config
└── package.json # Root dependencies
- React 18 - Modern React with hooks and context
- Vite - Fast build tool and dev server
- React Konva - Canvas-based graphics library
- Bootstrap 5 - Responsive CSS framework
- FontAwesome - Icon library
- Axios - HTTP client for API calls
- Spring Boot 3.4.3 - Java-based REST API
- PostgreSQL - Primary database
- Hibernate ORM - Object-relational mapping
- Spring Security - Authentication and authorization
- JWT - JSON Web Token authentication
- Google Gemini AI - AI-powered circuit generation
- Playwright - 3rd Party App Integration
- Node.js - Runtime for automation scripts
- Docker - Containerization
- Firebase Hosting - Frontend deployment
- GitHub Actions - CI/CD pipeline
- Node.js (v18+ recommended)
- Java JDK 17 or higher
- PostgreSQL 12+
- Maven 3.6+
- Git
git clone <repository-url>
cd Logic-Gate-Schematic-Web-Appcd logic-gates-app
npm installcd ../LogicGates-backend/LogicGates-backend
mvn clean installCreate .env files in respective directories:
Frontend (.env)
VITE_BACKEND_URL=http://localhost:8080
VITE_FRONTEND_URL=http://localhost:3000Backend (application-dev.properties)
spring.datasource.url=jdbc:postgresql://localhost:5432/logicgates
spring.datasource.username=your_username
spring.datasource.password=your_passwordAI Service
GEMINI_API_KEY=your_gemini_api_key# Ensure PostgreSQL is running on port 5432cd LogicGates-backend/LogicGates-backend
mvn spring-boot:run
# Backend will run on http://localhost:8080cd logic-gates-app
npm run dev
# Frontend will run on http://localhost:3000-
Text Input Format:
name: Gate1; type: AND; input: A, B; output: C; level: 1; -
Supported Gate Types:
AND- Logical AND gateOR- Logical OR gateNOT- Logical NOT gateNAND- Logical NAND gate
- Click the AI button in the interface
- Describe your circuit in natural language
- The Gemini AI will generate optimized gate configurations
- Review and modify the generated circuit as needed
- Save Projects: Use the sidebar to save current circuits
- Load Projects: Browse and load previously saved projects
- Export: Download netlists or visual representations
- Share: Export projects for collaboration
- Drag & Drop: Move gates around the canvas
- Wire Connections: Automatic wire positioning and routing
- Grid System: Snap-to-grid for precise positioning
- Zoom & Pan: Navigate large circuit diagrams
- Create new component in
konvaLogicGates/ - Update gate type validation
- Add rendering logic for inputs/outputs
- Update AI prompt templates
Spring Boot Backend:
POST /api/auth/login- User authenticationPOST /api/auth/register- User registrationGET /api/projects- List user projectsPOST /api/projects- Save new projectGET /api/projects/{id}- Get project by ID
# Build the Docker image
docker build -t logic-gates-app .
# Run the container
docker run -p 8080:8080 logic-gates-appversion: '3.8'
services:
app:
build: .
ports:
- "8080:8080"
environment:
- SPRING_PROFILES_ACTIVE=docker
depends_on:
- postgres
postgres:
image: postgres:13
environment:
POSTGRES_DB: logicgates
POSTGRES_USER: user
POSTGRES_PASSWORD: password
volumes:
- postgres_data:/var/lib/postgresql/data
volumes:
postgres_data:- JWT Authentication - Secure token-based authentication
- Password Hashing - Bcrypt password encryption
- CORS Configuration - Controlled cross-origin requests
- Input Validation - Sanitized user inputs
- SQL Injection Protection - Parameterized queries
- Lazy Loading - Components load on demand
- Canvas Optimization - Efficient rendering with React Konva
- Database Indexing - Optimized PostgreSQL queries
- Caching - Redis integration for session management
- CDN Integration - Firebase hosting with global CDN
Port Conflicts
# Check port usage
netstat -ano | findstr :8080 # Windows
lsof -i :8080 # Mac/LinuxDatabase Connection
# Verify PostgreSQL is running
pg_isready -h localhost -p 5432CORS Issues
- Ensure backend allows requests from frontend origin
- Check
@CrossOriginannotations in Spring controllers
AI Service Errors
- Verify Gemini API key is valid
- Check API quota limits
- Ensure proper input format
# Frontend debug
cd logic-gates-app
npm run dev -- --debug
# Backend debug
cd LogicGates-backend/LogicGates-backend
mvn spring-boot:run -Dspring-boot.run.jvmArguments="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005"- 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
This project is licensed under the MIT License - see the LICENSE file for details.
Samuel Yew Han Sen
- LinkedIn: https://www.linkedin.com/in/samuelyew/
- GitHub: @samuelyew
- Google Gemini AI for intelligent circuit generation
- React Konva team for excellent canvas library
- Spring Boot community for robust backend framework
Note: This is a Final Year Project (FYP) demonstrating advanced web development concepts, AI integration, and full-stack architecture. For production use, additional security measures and testing should be implemented.