# PC Builder System A professional PC Builder system with AI-powered guidance for component selection. The system helps users build PCs by providing intelligent recommendations, compatibility checking, and budget management, while respecting platform preferences and constraints. ## Features - **AI-Powered Analysis**: Analyzes user input and generates structured guidance JSON - **Component Management**: Admin panel for managing components, specs, and prices - **Automatic Image Fetching**: Automatically search and fetch component images from the web - **Compatibility Engine**: Automatic compatibility checking between components - **Budget Management**: Respects budget constraints and provides warnings - **Platform Support**: Intel, AMD, or platform-agnostic builds - **Real-time Validation**: Validates builds as components are selected - **Split-Screen Builder UI**: Easy-to-use interface for component selection ## System Architecture ### Backend (PHP) - **Database Layer**: MySQL database with components, specs, compatibility rules - **API Endpoints**: RESTful API for analysis, components, build management, and image fetching - **Compatibility Engine**: Validates component compatibility - **AI Analyzer**: Processes user input and generates guidance (supports OpenAI, Anthropic, or local LLMs) - **Image Search**: Fetches component images from Unsplash, Pexels, or web search ### Frontend - **Admin Panel**: Component management interface with automatic image fetching - **Builder UI**: User-facing component selection interface with AI guidance ## Installation 1. **Database Setup** ```bash mysql -u root -p < database/schema.sql ``` 2. **Configuration** - Edit `config/config.php` and set your database credentials - Set `AI_API_KEY` in `config/config.php` or environment variables - Configure `AI_PROVIDER` (openai, anthropic, or local) - (Optional) Set `UNSPLASH_API_KEY` or `PEXELS_API_KEY` for better image search results 3. **Web Server** - Point your web server document root to the project directory - Ensure PHP 7.4+ with PDO MySQL extension - Enable mod_rewrite if using URL rewriting ## API Endpoints ### POST /api/analyze.php Analyzes user input and returns AI guidance JSON. **Request:** ```json { "user_input": "I want a gaming PC for 1080p FPS, budget $900, Intel", "budget_min": 800, "budget_max": 1000, "platform_choice": "Intel", "country": "USA" } ``` **Response:** ```json { "success": true, "analysis": { "usage_type": "gaming", "primary_tasks": ["FPS gaming"], "performance_priority": {...}, "budget_profile": {...}, "platform_preference": "intel", "predicted_mistakes": [...], "selection_guidance": {...}, "ai_notes": [...], "confidence_score": 0.95 } } ``` ### GET /api/components.php Returns filtered list of components. **Query Parameters:** - `category`: Component category (cpu, gpu, motherboard, etc.) - `platform`: Filter by platform (intel, amd, any) - `budget_min`: Minimum price filter - `budget_max`: Maximum price filter - `status`: Component status (active, inactive, discontinued) ### GET /api/fetch_image.php Searches for component images online. **Query Parameters:** - `query`: Search query (component name) - `brand`: Component brand (optional) - `model`: Component model (optional) - `category`: Component category (optional) **Response:** ```json { "success": true, "query": "Intel Core i5-12400F", "count": 5, "images": [ { "url": "https://...", "thumbnail": "https://...", "source": "Unsplash", "width": 1920, "height": 1080 } ] } ``` ### GET /api/build.php Retrieves user's current build. **Query Parameters:** - `session_id`: User session identifier ### POST /api/build.php Adds a component to the build. **Request:** ```json { "session_id": "session_123", "component_id": 45, "build_name": "My Gaming PC", "ai_analysis": {...} } ``` ### DELETE /api/build.php Removes a component from the build. **Query Parameters:** - `session_id`: User session identifier - `component_id`: Component ID to remove ## Image Fetching The admin panel includes automatic image fetching functionality: 1. **Click "Fetch Image"** button next to the Image URL field 2. **System searches** for images based on component name, brand, and model 3. **Select an image** from the results to auto-fill the Image URL field ### Image Sources (in order of priority): 1. **Unsplash API** (requires free API key - 50 requests/hour) 2. **Pexels API** (requires free API key - 200 requests/hour) 3. **Web Search** (no API key needed, fallback method) ### Setting up Image APIs (Optional but Recommended): 1. **Unsplash**: - Sign up at https://unsplash.com/developers - Create an application - Copy your Access Key - Add to `config/config.php`: `define('UNSPLASH_API_KEY', 'your-key');` 2. **Pexels**: - Sign up at https://www.pexels.com/api/ - Get your API key - Add to `config/config.php`: `define('PEXELS_API_KEY', 'your-key');` **Note**: The system works without API keys using web search, but API keys provide better, more reliable results. ## AI Configuration The system supports multiple AI providers: 1. **OpenAI**: Set `AI_PROVIDER=openai` and provide `AI_API_KEY` 2. **Anthropic**: Set `AI_PROVIDER=anthropic` and provide `AI_API_KEY` 3. **Local LLM**: Set `AI_PROVIDER=local` and configure your local LLM server ## Database Schema - `components`: Stores all PC components - `component_specs`: Technical specifications for components - `compatibility_rules`: Compatibility constraints between components - `user_builds`: User's component selections - `build_components`: Links components to builds - `quotations`: Finalized quotations - `ai_analysis_cache`: Cached AI analysis results ## Usage 1. **Admin Panel** (`/admin/index.php`): - Add/edit/delete components - Use "Fetch Image" to automatically find component images - Manage component specifications - View all components 2. **Builder UI** (`/builder/index.php`): - User describes their needs - AI provides guidance and warnings - User selects components from filtered list - System validates compatibility in real-time - Build summary with total price ## Component Specifications Common spec keys: - `platform`: intel, amd - `tdp`: Thermal Design Power (watts) - `wattage`: Power supply wattage - `socket`: CPU socket type - `form_factor`: Motherboard form factor - `ddr_version`: RAM DDR version - `capacity`: Storage/RAM capacity ## Compatibility Rules The compatibility engine checks: - Platform compatibility (Intel vs AMD) - Power supply requirements - Socket compatibility - Form factor constraints - Component-specific rules defined in `compatibility_rules` table ## License This is a professional PC Builder system. Customize as needed for your use case.