# Dynamic Website Conversion: System Analysis

## Current Architecture

- Laravel 11 / PHP 8.2 application with one database and one admin panel.
- The mobile client consumes public JSON routes in `routes/api.php`.
- Mobile home/catalog composition is centralized in `App\Services\HomeApiService`.
- The website uses Blade views in `resources/views/frontend`; the main pages are currently dominated by hardcoded product and banner markup.
- Admin catalog management already covers categories, products, section styles, section variants, tabs, groups, banners, coupons, testimonials, subscriptions, blogs, galleries/videos, customers, orders, stock, and settings.

## Core Database Map

| Domain | Tables | Important relationships and controls |
| --- | --- | --- |
| Categories | `categories`, `seo_settings` | Category has many sections; status, sort order, image, header color, SEO, platform visibility. |
| Products | `products`, `product_pricing`, `product_related`, `seo_settings` | Product belongs to group/subgroup, has pricing/stock rows, related products, sections/tabs, SEO, status, platform visibility. |
| Sections | `sections`, `section_products`, `section_product_pricing`, `section_tabs`, `section_tab_products`, `section_groups` | Category-owned reusable section builder with style, variants, products/groups/tabs, ordering, scheduling, status, platform visibility. |
| Section styles | `section_styles`, `section_style_variants`, `section_section_style_variant` | Controls the presentation/content mode selected by admin. |
| Banners | `banners`, `banner_sections` | Images, multiple images, type, per-category positions, section assignment, date range, status, platform visibility. |
| Cart and wishlist | `carts`, `cart_items`, `wishlists`, `guest_preferences` | Supports authenticated and guest state. |
| Orders | `orders`, `order_items`, `payment_gateway_histories` | Checkout, payment, fulfilment, reorder, and reporting data. |
| Coupons | `coupons`, `coupon_usages` | Eligibility, date, location, usage, and status rules. |
| Content | `testimonials`, `blogs`, `blogcategories`, `galleries`, `pages`, `legal_policies`, `settings` | Existing CMS data that can be bound to website sections. |
| Plans | Subscription-related admin views/controllers | Existing subscription workflow requires a dedicated schema/API audit before website binding. |
| Health / kitchen | `vk_products`, ingredient tables, salad tables | Separate dynamic health and salad product domains. |

## Existing API Map

| Endpoint family | Source | Purpose |
| --- | --- | --- |
| `/api/home/categories` | `HomeController` / `HomeApiService` | Mobile category cards. |
| `/api/categories` | `HomeController` / `HomeApiService` | Mobile grouped category navigation. |
| `/api/home/sections` | `HomeController` / `HomeApiService` | Ordered sections, banners, tabs, groups, products, personalization. |
| `/api/home/products` | `HomeController` / `HomeApiService` | Filtered product listing. |
| `/api/home/products/{id}` | `HomeController` / `HomeApiService` | Product detail and recommendations. |
| `/api/cart`, `/api/wishlist`, `/api/coupons` | Dedicated API controllers | Shared commerce state and rules. |
| `/api/web/catalog/*` | `WebCatalogController` / `HomeApiService` | Website-filtered categories, sections, products, and product details. |

## Display Logic

- Active records are selected using `status = active`.
- Categories and sections use explicit sort order followed by stable ID/name ordering.
- Products inside sections, tabs, and groups use pivot sort order.
- Section scheduling uses `scheduled_from` and `scheduled_to`.
- Banner scheduling uses `banner_sections.from_date` and `to_date`.
- Platform visibility uses `mobile`, `web`, or `both`; mobile and web share the same records.
- Product cards use active pricing, default pricing first, section overrides where configured, and stock fields from `product_pricing`.

## Identified Gaps

- Frontend Blade pages contain large repeated static card blocks and are not yet componentized.
- YouTube/gallery, testimonials, subscriptions/plans, brands, blogs, and promotional content do not share one generic homepage section contract.
- Category routes do not currently identify a category by slug or ID.
- Product detail routes do not currently identify a product by slug or ID.
- Automated frontend visual regression coverage is absent.
