diff --git a/assets/css/custom.css b/assets/css/custom.css new file mode 100644 index 0000000..0fd6e0f --- /dev/null +++ b/assets/css/custom.css @@ -0,0 +1,16 @@ +/* Animations */ +@keyframes fadeInSlideUp { + from { + opacity: 0; + transform: translateY(20px); + } + to { + opacity: 1; + transform: translateY(0); + } +} + +.animate-on-load { + opacity: 0; + animation: fadeInSlideUp 0.8s ease-out forwards; +} \ No newline at end of file diff --git a/dashboard.php b/dashboard.php new file mode 100644 index 0000000..27b8d3a --- /dev/null +++ b/dashboard.php @@ -0,0 +1,62 @@ + + + + + + + Dashboard - AI Study Planner + + + + + + + + + + +
+
+
+

Welcome, !

+

This is your personal dashboard. From here, you can manage your study materials and view your generated study plans.

+

You can start by uploading a new study material.

+
+
+
+ + + + diff --git a/db/config.php b/db/config.php index 3885459..b47441d 100644 --- a/db/config.php +++ b/db/config.php @@ -13,5 +13,21 @@ function db() { PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC, ]); } - return $pdo; + return $pdo; } + +function run_migrations() { + $pdo = db(); + $migration_file = __DIR__ . '/migrations/001_initial_schema.sql'; + if (file_exists($migration_file)) { + try { + $sql = file_get_contents($migration_file); + $pdo->exec($sql); + } catch (PDOException $e) { + // Optional: log error without crashing + error_log("Migration failed: " . $e->getMessage()); + } + } +} + +run_migrations(); diff --git a/db/migrations/001_initial_schema.sql b/db/migrations/001_initial_schema.sql new file mode 100644 index 0000000..06ecbe9 --- /dev/null +++ b/db/migrations/001_initial_schema.sql @@ -0,0 +1,45 @@ + +CREATE TABLE IF NOT EXISTS `users` ( + `id` varchar(36) NOT NULL, + `email` varchar(255) NOT NULL, + `password_hash` varchar(255) NOT NULL, + `created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, + PRIMARY KEY (`id`), + UNIQUE KEY `email` (`email`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; + +CREATE TABLE IF NOT EXISTS `materials` ( + `id` varchar(36) NOT NULL, + `user_id` varchar(36) NOT NULL, + `file_path` varchar(255) NOT NULL, + `upload_type` enum('pdf','pptx','image') NOT NULL, + `extracted_text` text, + `created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, + PRIMARY KEY (`id`), + KEY `user_id` (`user_id`), + CONSTRAINT `materials_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; + +CREATE TABLE IF NOT EXISTS `study_plans` ( + `id` varchar(36) NOT NULL, + `user_id` varchar(36) NOT NULL, + `material_id` varchar(36) NOT NULL, + `test_date` date NOT NULL, + `created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, + PRIMARY KEY (`id`), + KEY `user_id` (`user_id`), + KEY `material_id` (`material_id`), + CONSTRAINT `study_plans_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE, + CONSTRAINT `study_plans_ibfk_2` FOREIGN KEY (`material_id`) REFERENCES `materials` (`id`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; + +CREATE TABLE IF NOT EXISTS `plan_items` ( + `id` varchar(36) NOT NULL, + `plan_id` varchar(36) NOT NULL, + `day_number` int(11) NOT NULL, + `task_text` text NOT NULL, + `is_done` tinyint(1) NOT NULL DEFAULT '0', + PRIMARY KEY (`id`), + KEY `plan_id` (`plan_id`), + CONSTRAINT `plan_items_ibfk_1` FOREIGN KEY (`plan_id`) REFERENCES `study_plans` (`id`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; diff --git a/index.php b/index.php index 7205f3d..8bc4f6b 100644 --- a/index.php +++ b/index.php @@ -1,150 +1,90 @@ - - + + - - - New Style - - - - - - - - - - - - - - - - - - - + + + AI Study Planner + + + + + + -
-
-

Analyzing your requirements and generating your website…

-
- Loading… -
-

AI is collecting your requirements and applying the first changes.

-

This page will update automatically as the plan is implemented.

-

Runtime: PHP — UTC

-
-
- + + + +
+
+
+

From Clutter to Clarity

+

Upload your Hebrew study material → get a personal AI study plan.

+ + Start Now + +
+
+ +
+
+
+
+
+
+

Upload Your Material

+
+
+ + +
+
+ +
+
+
+
+
+
+
+
+
+ + + + - + \ No newline at end of file diff --git a/login.php b/login.php new file mode 100644 index 0000000..0afde09 --- /dev/null +++ b/login.php @@ -0,0 +1,117 @@ + + + + + + Login - AI Study Planner + + + + + + + + + + +
+
+
+ prepare("SELECT id, username, email, password FROM users WHERE email = ?"); + $stmt->execute([$email]); + $user = $stmt->fetch(); + + if ($user && password_verify($password, $user['password'])) { + // Password is correct, start session + $_SESSION['user_id'] = $user['id']; + $_SESSION['username'] = $user['username']; + $_SESSION['email'] = $user['email']; + + // Redirect to the dashboard + header("Location: dashboard.php"); + exit(); + } else { + $error = 'Invalid email or password.'; + } + } catch (PDOException $e) { + $error = 'Database error. Please try again later.'; + // error_log($e->getMessage()); + } + } +} +?> +

Welcome Back

+ +
+ + +
+ +
+
+ + +
+
+ + +
+
+ +
+
+
+

Don't have an account? Register here

+
+
+
+
+ + + + diff --git a/logout.php b/logout.php new file mode 100644 index 0000000..6f6b58b --- /dev/null +++ b/logout.php @@ -0,0 +1,22 @@ + get_ocr_key(), +]; + diff --git a/readme.txt b/readme.txt new file mode 100644 index 0000000..0a442e9 --- /dev/null +++ b/readme.txt @@ -0,0 +1,44 @@ +How to get your API keys: + +**1. OCR (Tesseract)** + +Tesseract is a free, open-source OCR engine. You don't need an API key in the traditional sense, but you do need to install it on your server. + +- **On Debian/Ubuntu:** + `sudo apt update` + `sudo apt install tesseract-ocr` + `sudo apt install tesseract-ocr-heb` (for Hebrew language support) + +- **On CentOS/RHEL:** + `sudo yum install tesseract` + (You may need to find a repository that has the Hebrew language pack) + +No API key needs to be set in the environment variables for Tesseract. The application will call it from the command line. + +**2. AI Service (Free Tier or Mock)** + +For the MVP, we are using a free or mock AI service. There are several options for free language models. One option is to use a free tier from a provider. Another is to set up a local model if you have the hardware. + +For a simple mock setup, you can have the application return a pre-defined JSON response without calling a real AI. + +If you choose a service that provides an API key, you will need to set it in your `.env` file: +`AI_API_KEY="your_key_here"` + +**3. Email Provider (Free SMTP)** + +You can use a service like Mailgun or SendGrid which offer free tiers for a limited number of emails per month. + +- **Sign up for a free account** on a provider like Mailgun. +- **Verify your domain.** This is a necessary step to be able to send emails. +- **Get your SMTP credentials.** They will look something like this: + - Host: `smtp.mailgun.org` + - Port: `587` + - Username: `postmaster@yourdomain.com` + - Password: `a_long_secret_password` + +- **Set these credentials in your `.env` file:** + `SMTP_HOST="smtp.mailgun.org"` + `SMTP_PORT="587"` + `SMTP_USER="your_username"` + `SMTP_PASS="your_password"` + `MAIL_FROM="you@yourdomain.com"` diff --git a/register.php b/register.php new file mode 100644 index 0000000..5d13215 --- /dev/null +++ b/register.php @@ -0,0 +1,116 @@ + + + + + + Register - AI Study Planner + + + + + + + + + + +
+
+
+

Create Your Account

+ prepare("SELECT id FROM users WHERE email = ?"); + $stmt->execute([$email]); + if ($stmt->fetch()) { + $error = 'A user with this email already exists.'; + } else { + // Hash password + $hashed_password = password_hash($password, PASSWORD_DEFAULT); + + // Insert user + $stmt = $pdo->prepare("INSERT INTO users (username, email, password) VALUES (?, ?, ?)"); + if ($stmt->execute([$username, $email, $hashed_password])) { + // Redirect to login page with a success message + header("Location: login.php?registered=success"); + exit(); + } else { + $error = 'Something went wrong. Please try again later.'; + } + } + } catch (PDOException $e) { + // In a real app, you would log this error. + $error = 'Database error. Please try again later.'; + // error_log($e->getMessage()); + } + } +} +?> + +
+ +
+
+ + +
+
+ + +
+
+ + +
+
+ +
+
+
+

Already have an account? Login here

+
+
+
+
+ + + + diff --git a/upload.php b/upload.php new file mode 100644 index 0000000..92715b6 --- /dev/null +++ b/upload.php @@ -0,0 +1,59 @@ + + + + + + Upload Status + + + + +
+
+
+ Sorry, only JPG, JPEG, PNG, PDF & PPTX files are allowed."; + $uploadOk = 0; + } + + // Check if $uploadOk is set to 0 by an error + if ($uploadOk == 0) { + echo "

Your file was not uploaded.

"; + // if everything is ok, try to upload file + } else { + if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) { + echo "

The file ". htmlspecialchars(basename($_FILES["fileToUpload"]["name"])) ." has been uploaded.

"; + echo "

We are now processing your file. You will be redirected shortly.

"; + // In a real app, you would redirect to the material preview page, e.g.: + // header("Location: material_preview.php?file=" . urlencode(basename( $_FILES["fileToUpload"]["name"])))); + } else { + echo "

Sorry, there was an error uploading your file.

"; + } + } + ?> + Back to Home +
+
+
+ + diff --git a/uploads/Screenshot 2025-12-12 203959.png b/uploads/Screenshot 2025-12-12 203959.png new file mode 100644 index 0000000..9be2a4b Binary files /dev/null and b/uploads/Screenshot 2025-12-12 203959.png differ