diff --git a/api/chat.php b/api/chat.php
new file mode 100644
index 0000000..a2b56ce
--- /dev/null
+++ b/api/chat.php
@@ -0,0 +1,58 @@
+ 'Message is required.']);
+ http_response_code(400);
+ exit;
+}
+
+$userMessage = trim($_POST['message']);
+$botReply = '';
+
+// Simple rule-based responses
+$lowerMessage = strtolower($userMessage);
+
+if (str_contains($lowerMessage, 'hello') || str_contains($lowerMessage, 'hi')) {
+ $botReply = 'Hi there! I am the EvolveX guide. Ask me about our categories like AI, coding, or wellness.';
+} elseif (str_contains($lowerMessage, 'money')) {
+ $botReply = 'Money management is key to financial freedom. Our tutorials cover budgeting, investing, and saving strategies.';
+} elseif (str_contains($lowerMessage, 'ai') || str_contains($lowerMessage, 'artificial intelligence')) {
+ $botReply = 'Artificial Intelligence is transforming the world. We have tutorials on machine learning, neural networks, and AI ethics.';
+} elseif (str_contains($lowerMessage, 'code') || str_contains($lowerMessage, 'coding')) {
+ $botReply = 'Our coding tutorials focus on future-relevant skills, including Python, JavaScript, and smart contract development.';
+} elseif (str_contains($lowerMessage, 'productivity')) {
+ $botReply = 'Boost your efficiency! Our productivity section covers tools, techniques, and workflows to help you achieve more.';
+} elseif (str_contains($lowerMessage, 'marketing')) {
+ $botReply = 'Digital marketing is always evolving. Learn about SEO, content marketing, and social media strategies with us.';
+} elseif (str_contains($lowerMessage, 'cybersecurity')) {
+ $botReply = 'Protecting digital assets is crucial. Our cybersecurity path covers network security, ethical hacking, and data protection.';
+} elseif (str_contains($lowerMessage, 'wellness') || str_contains($lowerMessage, 'skills')) {
+ $botReply = 'Invest in yourself. We cover everything from mindfulness and mental health to learning new practical skills for personal growth.';
+} elseif (str_contains($lowerMessage, 'entrepreneurship')) {
+ $botReply = 'Ready to build something new? Our entrepreneurship guides cover business planning, fundraising, and scaling your venture.';
+} else {
+ $botReply = 'That is a great question. While I am still in training, EvolveX offers a wide range of tutorials on AI, coding, wellness, and more. Which category interests you most?';
+}
+
+try {
+ $pdo = db_connect();
+
+ // Save user message
+ $stmt = $pdo->prepare("INSERT INTO messages (role, content) VALUES (?, ?)");
+ $stmt->execute(['user', $userMessage]);
+
+ // Save bot reply
+ $stmt = $pdo->prepare("INSERT INTO messages (role, content) VALUES (?, ?)");
+ $stmt->execute(['bot', $botReply]);
+
+} catch (PDOException $e) {
+ // In a real app, you would log this error. For this stub, we'll ignore it so the chat still works.
+ // http_response_code(500);
+ // echo json_encode(['error' => 'Database error.']);
+ // exit;
+}
+
+echo json_encode(['reply' => $botReply]);
diff --git a/assets/css/custom.css b/assets/css/custom.css
new file mode 100644
index 0000000..cdbb4ef
--- /dev/null
+++ b/assets/css/custom.css
@@ -0,0 +1,171 @@
+
+
diff --git a/assets/js/main.js b/assets/js/main.js
new file mode 100644
index 0000000..66f0df7
--- /dev/null
+++ b/assets/js/main.js
@@ -0,0 +1,64 @@
+document.addEventListener('DOMContentLoaded', () => {
+ const chatForm = document.getElementById('chat-form');
+ const messageInput = document.getElementById('message-input');
+ const messagesContainer = document.querySelector('.messages');
+
+ chatForm.addEventListener('submit', (e) => {
+ e.preventDefault();
+ const messageText = messageInput.value.trim();
+ if (messageText === '') return;
+
+ appendMessage('user', messageText);
+ messageInput.value = '';
+ showTypingIndicator();
+
+ fetch('/api/chat.php', {
+ method: 'POST',
+ headers: {
+ 'Content-Type': 'application/x-www-form-urlencoded',
+ },
+ body: `message=${encodeURIComponent(messageText)}`
+ })
+ .then(response => response.json())
+ .then(data => {
+ removeTypingIndicator();
+ if (data.reply) {
+ appendMessage('bot', data.reply);
+ }
+ })
+ .catch(error => {
+ removeTypingIndicator();
+ appendMessage('bot', 'Sorry, something went wrong. Please try again.');
+ console.error('Error:', error);
+ });
+ });
+
+ function appendMessage(role, text) {
+ const messageElement = document.createElement('div');
+ messageElement.classList.add('message', role);
+
+ const contentElement = document.createElement('div');
+ contentElement.classList.add('message-content');
+ contentElement.textContent = text;
+
+ messageElement.appendChild(contentElement);
+ messagesContainer.appendChild(messageElement);
+ messagesContainer.scrollTop = messagesContainer.scrollHeight;
+ }
+
+ function showTypingIndicator() {
+ const typingIndicator = document.createElement('div');
+ typingIndicator.id = 'typing-indicator';
+ typingIndicator.classList.add('message', 'typing');
+ typingIndicator.textContent = 'EvolveX is typing...';
+ messagesContainer.appendChild(typingIndicator);
+ messagesContainer.scrollTop = messagesContainer.scrollHeight;
+ }
+
+ function removeTypingIndicator() {
+ const typingIndicator = document.getElementById('typing-indicator');
+ if (typingIndicator) {
+ typingIndicator.remove();
+ }
+ }
+});
diff --git a/db/config.php b/db/config.php
index 62ed3b7..1b9684c 100644
--- a/db/config.php
+++ b/db/config.php
@@ -1,17 +1,43 @@
PDO::ERRMODE_EXCEPTION,
- PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
- ]);
- }
- return $pdo;
+ if ($pdoconn) {
+ return $pdoconn;
+ }
+
+ $config = [
+ 'host' => '127.0.0.1',
+ 'dbname' => 'app',
+ 'user' => 'app',
+ 'password' => 'app'
+ ];
+
+ $dsn = "mysql:host={$config['host']};dbname={$config['dbname']};charset=utf8mb4";
+ $options = [
+ PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
+ PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
+ PDO::ATTR_EMULATE_PREPARES => false,
+ ];
+
+ try {
+ $pdoconn = new PDO($dsn, $config['user'], $config['password'], $options);
+ return $pdoconn;
+ } catch (PDOException $e) {
+ // In a real app, you'd log this error and show a generic message
+ throw new PDOException($e->getMessage(), (int)$e->getCode());
+ }
+}
+
+function run_migrations() {
+ $pdo = db_connect();
+ $migrationsDir = __DIR__ . '/migrations';
+ $files = glob($migrationsDir . '/*.sql');
+ sort($files);
+ foreach ($files as $file) {
+ $sql = file_get_contents($file);
+ if ($sql) {
+ $pdo->exec($sql);
+ }
+ }
}
diff --git a/db/migrations/001_create_messages_table.sql b/db/migrations/001_create_messages_table.sql
new file mode 100644
index 0000000..fb9424b
--- /dev/null
+++ b/db/migrations/001_create_messages_table.sql
@@ -0,0 +1,6 @@
+CREATE TABLE IF NOT EXISTS messages (
+ id INT AUTO_INCREMENT PRIMARY KEY,
+ role VARCHAR(20) NOT NULL,
+ content TEXT NOT NULL,
+ created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
+);
\ No newline at end of file
diff --git a/index.php b/index.php
index 6f7ffab..c2ef28d 100644
--- a/index.php
+++ b/index.php
@@ -1,131 +1,62 @@
-
+
-
-
- New Style
-
-
-
-
+
+
+
+
+ EvolveX - AI Guide
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
Analyzing your requirements and generating your website…
-
- Loading…
-
-
= ($_SERVER['HTTP_HOST'] ?? '') === 'appwizzy.com' ? 'AppWiZZy' : 'Flatlogic' ?> AI is collecting your requirements and applying the first changes.
-
This page will update automatically as the plan is implemented.
-
Runtime: PHP = htmlspecialchars($phpVersion) ?> — UTC = htmlspecialchars($now) ?>
+
+
+
+
+
+
+
+ Hello! I'm the EvolveX guide. I can help you discover tutorials on money management, AI, coding, and more. What are you interested in learning today?
+
+
+
+
+
-
-
- Page updated: = htmlspecialchars($now) ?> (UTC)
-
+
+
+ Built with Flatlogic Generator
+
+
+
-
+