# THE LUXE FLAME - Complete Project Summary

## 1. PROJECT OVERVIEW

| Detail | Value |
|--------|-------|
| **Project Name** | The Luxe Flame |
| **Type** | Luxury Candle E-commerce Website |
| **Company** | Indian Company (INR Currency) |
| **Frontend** | React 19 + TypeScript + Vite + Tailwind CSS + shadcn/ui |
| **Backend** | PHP 7.4+ + MySQL 5.7+ |
| **Admin Panel** | PHP server-rendered pages with session auth |
| **Deployment** | Frontend: Static hosting / Backend: PHP server (cPanel/XAMPP) |

---

## 2. FOLDER STRUCTURE

```
/backend/
  /admin/           - Admin panel pages (14 PHP files)
  /api/             - REST API endpoints (16 PHP files)
  /uploads/         - Uploaded images (products, home, about, testimonials)
  database.sql      - Complete database schema + seed data

/frontend/ (app/dist/)
  index.html        - Main entry point (React SPA)
  /assets/          - JS + CSS bundles
  /images/          - 18 product/brand images
```

---

## 3. DATABASE TABLES (8 Tables)

| Table | Purpose |
|-------|---------|
| `admins` | Admin login (default: admin / admin123) |
| `categories` | 21 pre-seeded product categories |
| `products` | Product catalog |
| `product_flavors` | Flavor variants per product |
| `home_sections` | 11 homepage editable sections |
| `about_content` | About page editable sections |
| `contact_settings` | Contact info (phone, email, address) |
| `site_settings` | Site config (currency, shipping, tax) |
| `orders` | Customer orders |
| `contact_submissions` | Contact form messages |
| `newsletter_subscribers` | Email subscribers |
| `testimonials` | Customer reviews |
| `refund_policy` | Refund policy sections |

---

## 4. ALL API ENDPOINTS (16 Total)

### Base URL: `/backend/api/index.php/{endpoint}`

| # | Endpoint | Methods | Auth | Purpose |
|---|----------|---------|------|---------|
| 1 | `/products` | GET/POST/PUT/DELETE | No/Yes | Product CRUD |
| 2 | `/categories` | GET/POST/PUT/DELETE | No/Yes | Category CRUD |
| 3 | `/flavors` | GET/POST/PUT/DELETE | No/Yes | Flavor management |
| 4 | `/home-sections` | GET/POST/PUT/DELETE | No/Yes | Homepage content |
| 5 | `/about-content` | GET/POST/PUT/DELETE | No/Yes | About page content |
| 6 | `/contact-settings` | GET/POST/PUT | No/Yes | Contact info |
| 7 | `/site-settings` | GET/POST/PUT | No/Yes | Site configuration |
| 8 | `/orders` | GET/POST/PUT/DELETE | No/Yes | Order management |
| 9 | `/contact-submissions` | GET/POST/DELETE | Yes/No | Contact form data |
| 10 | `/newsletter` | GET/POST/DELETE | Yes/No | Email subscribers |
| 11 | `/testimonials` | GET/POST/PUT/DELETE | No/Yes | Customer reviews |
| 12 | `/refund-policy` | GET/POST/PUT/DELETE | No/Yes | Refund policy |
| 13 | `/upload` | POST | No | Image file upload |
| 14 | `/auth` | POST | No | Login/logout |

---

## 5. KEY API DETAILS

### 5.1 POST /orders - Create Order (Called from frontend checkout)

```
POST /backend/api/index.php/orders
Content-Type: multipart/form-data

Fields:
  customer_name       (required) - Full name
  customer_email      (required) - Email address
  customer_phone      (optional) - Phone number
  shipping_address    (required) - Full address
  city                (optional) - City
  state               (optional) - State
  pin_code            (optional) - PIN code
  items               (required) - JSON array of cart items
  subtotal            (optional) - Subtotal amount
  shipping_cost       (optional) - Shipping cost
  total_amount        (required) - Final total

Response:
  {
    "success": true,
    "data": {
      "id": 123,
      "order_number": "LF-20250115-A3B7"
    },
    "message": "Order placed successfully"
  }
```

### 5.2 PUT /orders/{id} - Update Order Status

```
PUT /backend/api/index.php/orders/123
Content-Type: application/x-www-form-urlencoded

Fields:
  status - pending / confirmed / shipped / delivered / cancelled
```

### 5.3 GET /orders - List All Orders (Admin)

```
GET /backend/api/index.php/orders?status=pending&page=1&per_page=20

Headers:
  X-Admin-Auth: required for admin data
```

### 5.4 POST /upload - Upload Image

```
POST /backend/api/index.php/upload?subdir=products
Content-Type: multipart/form-data

Fields:
  file - Image file (jpg, png, gif, webp)

Response:
  {
    "success": true,
    "data": "products/filename_1234567890.jpg",
    "message": "Upload successful"
  }
```

### 5.5 POST /auth - Admin Login

```
POST /backend/api/index.php/auth
Content-Type: multipart/form-data

Fields:
  action   - login / logout
  username - admin
  password - admin123

Response:
  {
    "success": true,
    "data": { "username": "admin", "role": "admin" }
  }
```

---

## 6. CART DATA FORMAT (Sent to Orders API)

```json
[
  {
    "productId": "pumpkin-mocha-bliss",
    "product": {
      "id": "pumpkin-mocha-bliss",
      "name": "Pumpkin Mocha Bliss",
      "price": 2999,
      "mainImage": "images/product_pumpkin_mocha.jpg"
    },
    "flavorId": "vanilla-cinnamon",
    "flavorName": "Vanilla Cinnamon",
    "quantity": 2
  }
]
```

---

## 7. FRONTEND PAGES

| Page | Route | File |
|------|-------|------|
| Home | `/` | index.html |
| Products | `/#/products` | Products.tsx |
| Product Detail | `/#/product/:id` | ProductDetail.tsx |
| About | `/#/about` | About.tsx |
| Contact | `/#/contact` | Contact.tsx |
| Refund Policy | `/#/refund` | RefundPolicy.tsx |
| Checkout | `/#/checkout` | Checkout.tsx |
| Cart | Drawer (overlay) | CartDrawer.tsx |

---

## 8. INR CONFIGURATION

| Setting | Value |
|---------|-------|
| Currency Symbol | Rs (&#x20b9;) |
| Free Shipping Threshold | Rs 5,000 |
| Shipping Cost | Rs 499 |
| Tax (GST) | 0% (managed manually by admin) |
| Country | India |
| Phone | +91 98765 43210 |
| Email | hello@theluxeflame.in |
| Address | 42, Fragrance Lane, Koramangala, Bangalore 560034 |

---

## 9. ADMIN PANEL PAGES (12 Pages)

| URL | Purpose |
|-----|---------|
| `/backend/admin/` | Login page |
| `/backend/admin/dashboard.php` | Dashboard with sales stats |
| `/backend/admin/products.php` | Product management |
| `/backend/admin/categories.php` | Category management |
| `/backend/admin/orders.php` | Order management |
| `/backend/admin/home-sections.php` | Homepage content |
| `/backend/admin/about-sections.php` | About page content |
| `/backend/admin/contact-settings.php` | Contact info |
| `/backend/admin/contact-submissions.php` | Contact form messages |
| `/backend/admin/newsletter-subscribers.php` | Email subscribers |
| `/backend/admin/testimonials.php` | Customer reviews |
| `/backend/admin/refund-policy.php` | Refund policy |
| `/backend/admin/site-settings.php` | Site configuration |

---

## 10. PAYMENT GATEWAY INTEGRATION GUIDE

### Where to Add Payment Code:

**File:** `backend/api/orders.php`
**Location:** Inside the `case 'POST':` block, before saving the order.

### Flow:

```
1. Customer clicks "Place Order" on frontend
2. Frontend POSTs to /orders with customer + cart data
3. Backend receives data in orders.php
4. [ADD PAYMENT HERE] Process payment with Razorpay/PayU/Stripe
5. If payment successful: save order, return success
6. If payment failed: return error, don't save order
```

### Example Integration (Razorpay):

```php
// In backend/api/orders.php, inside POST case:

// 1. Create Razorpay order
$razorpayOrder = createRazorpayOrder($data['total_amount']);

// 2. Return payment ID to frontend
jsonResponse(true, [
    'razorpay_order_id' => $razorpayOrder->id,
    'amount' => $data['total_amount'] * 100, // paise
    'key' => RAZORPAY_KEY_ID
], 'Payment initiated');

// 3. Frontend opens Razorpay checkout
// 4. After payment, frontend calls verify endpoint
// 5. Save order only after payment verification
```

### Recommended Payment Gateways for India:

| Gateway | Website | Best For |
|---------|---------|----------|
| **Razorpay** | razorpay.com | Indian businesses |
| **PayU** | payu.in | High volume |
| **Stripe** | stripe.com | International |
| **PhonePe** | phonepe.com | UPI payments |
| **CCAvenue** | ccavenue.com | Enterprise |

---

## 11. SETUP INSTRUCTIONS

### Step 1: Database
```sql
- Create database: luxeflame
- Import: database.sql
```

### Step 2: Backend Config
```php
// Edit: backend/api/config.php
define('DB_HOST', 'localhost');
define('DB_NAME', 'luxeflame');
define('DB_USER', 'your_db_username');
define('DB_PASS', 'your_db_password');
define('BASE_URL', 'https://yourdomain.com/backend');
```

### Step 3: Upload
```
- Upload /backend/ folder to web root
- Make /backend/uploads/ writable (chmod 755)
- Upload /frontend/ (app/dist/) contents to web root
```

### Step 4: Access
```
- Website: https://yourdomain.com
- Admin: https://yourdomain.com/backend/admin/
- Default login: admin / admin123
- Change password immediately after first login
```

---

## 12. TECHNOLOGIES USED

| Layer | Technology |
|-------|------------|
| **Frontend Framework** | React 19 + TypeScript |
| **Build Tool** | Vite |
| **Styling** | Tailwind CSS 3.4 |
| **UI Components** | shadcn/ui |
| **Routing** | HashRouter (react-router-dom) |
| **State Management** | React Context API (Cart) |
| **Backend Language** | PHP 7.4+ |
| **Database** | MySQL 5.7+ |
| **API Format** | REST JSON |
| **Authentication** | PHP Sessions |
| **Image Upload** | PHP move_uploaded_file |

---

## 13. CONTACT FOR DEVELOPER

If your developer has questions, the full source code is in:
- `backend/api/` - All API files with inline comments
- `backend/admin/` - All admin pages
- `backend/database.sql` - Complete database

---

**Project Status: 100% COMPLETE**
- Frontend: Ready to deploy
- Backend: Ready to deploy
- Admin Panel: 12 management pages
- API: 16 endpoints
- Currency: INR (Rs)
- Tax: Manual (GST not auto-calculated)
- Payment Gateway: Ready for integration
