# Installation Guide ## Prerequisites - PHP 7.4 or higher - MySQL 5.7 or higher (or MariaDB 10.3+) - Apache/Nginx web server - cURL extension for PHP (for AI API calls) - PDO MySQL extension ## Step-by-Step Installation ### 1. Database Setup ```bash # Create database and import schema mysql -u root -p < database/schema.sql # (Optional) Import sample data for testing mysql -u root -p < database/sample_data.sql ``` ### 2. Configuration Edit `config/config.php`: ```php // Set your base URL define('BASE_URL', 'http://localhost/newengine'); // Configure AI provider define('AI_PROVIDER', 'openai'); // or 'anthropic' or 'local' define('AI_MODEL', 'gpt-4'); define('AI_API_KEY', 'your-api-key-here'); ``` Edit `config/database.php`: ```php return [ 'host' => 'localhost', 'database' => 'pc_builder', 'username' => 'root', 'password' => 'your-password', // ... ]; ``` ### 3. Web Server Configuration #### Apache Ensure mod_rewrite is enabled and `.htaccess` is being read. #### Nginx Add to your server block: ```nginx location /newengine { try_files $uri $uri/ /newengine/index.php?$query_string; } ``` ### 4. File Permissions ```bash # Ensure PHP can write to cache (if using file-based caching) chmod -R 755 . chmod -R 777 cache/ # if cache directory exists ``` ### 5. Test Installation 1. Visit `http://localhost/newengine/admin/index.php` 2. You should see the admin panel 3. Try adding a component 4. Visit `http://localhost/newengine/builder/index.php` 5. Test the builder interface ## AI Provider Setup ### OpenAI 1. Get API key from https://platform.openai.com/api-keys 2. Set `AI_API_KEY` in config 3. Set `AI_PROVIDER` to `'openai'` ### Anthropic (Claude) 1. Get API key from https://console.anthropic.com/ 2. Set `AI_API_KEY` in config 3. Set `AI_PROVIDER` to `'anthropic'` ### Local LLM 1. Set up Ollama, LM Studio, or similar 2. Configure API endpoint in `AIAnalyzer.php` 3. Set `AI_PROVIDER` to `'local'` ## Troubleshooting ### Database Connection Error - Check database credentials in `config/database.php` - Ensure MySQL service is running - Verify database exists: `SHOW DATABASES;` ### API Not Working - Check PHP error logs - Verify cURL is enabled: `php -m | grep curl` - Test API endpoint directly: `curl http://localhost/newengine/api/components.php?category=cpu` ### AI Analysis Not Working - Verify API key is set correctly - Check API provider status - Review error logs for API call failures - Test with default response (disable AI temporarily) ### Components Not Showing - Check database has components: `SELECT COUNT(*) FROM components;` - Verify component status is 'active' - Check API response in browser console ## Next Steps 1. Add components via admin panel 2. Configure compatibility rules 3. Test AI analysis with sample input 4. Customize UI styling as needed 5. Set up authentication for admin panel ## Security Notes - **Important**: Add authentication to admin panel before production use - Use environment variables for sensitive config (API keys, DB passwords) - Enable HTTPS in production - Regularly update dependencies - Sanitize all user inputs (already implemented in code)