# Prompt for the Coding AI

You are working inside an existing Laravel e-commerce repository for Tabriz Soghat.

Your job is to improve the existing application, not rewrite it from scratch.

Read all `*-SPEC.md` files in this directory before coding.

## Mandatory first step

Before changing code:
1. inspect repository structure
2. identify Laravel version
3. identify frontend stack
4. identify database engine
5. inspect relevant models/migrations
6. inspect routes
7. inspect admin implementation
8. search Git history for existing blog implementation
9. search for existing menu/navigation implementation
10. inspect product/category/cart/checkout services
11. inspect existing SEO implementation
12. run the app and record existing errors

Then create a concise implementation plan based on the actual codebase.

Do not ask the user to redesign the whole application unless the current architecture makes a feature impossible.

## Implementation order

1. baseline bugs / blockers
2. category hierarchy
3. blog recovery/implementation
4. menu builder
5. wholesale carton rules
6. SEO improvements
7. regression testing
8. cleanup and documentation

Some phases may be parallelized only when there is no dependency conflict.

## Important business behavior

Wholesale carton rule:
- category-level configuration
- configurable minimum DISTINCT products
- product quantity does not count as product diversity
- server-side checkout validation
- multiple categories validate independently
- clear Persian UI progress/error

## SEO requirements

Implement the separate SEO spec, including:
- canonical
- metadata
- structured data
- sitemap
- robots
- breadcrumbs
- category/product SEO
- blog SEO
- internal linking capability
- redirect compatibility
- crawl control

Do not invent SEO data.

## Blog requirement

There may already be an unfinished blog in Git history. Find it first.

If found:
- recover
- adapt
- migrate only what is needed

If not found:
- implement the Blog spec.

## Code quality

Use:
- Form Requests for complex validation
- Policies/Gates for authorization
- Services/actions for business rules
- Transactions for multi-step writes where required
- eager loading
- indexes
- typed code where supported by project version
- existing conventions

Avoid:
- business rules inside Blade
- duplicated cart calculations
- duplicated SEO logic
- giant controllers
- direct DB queries scattered across views/controllers

## Tests

Every new business behavior needs tests.

At minimum:
- category tree validation
- menu tree validation
- wholesale rule calculation
- checkout blocking
- blog publication
- SEO metadata/schema/sitemap
- redirects

## Output after implementation

Return:
### Changed files
List exact paths.

### Migrations
List migration names and what they do.

### Routes
List new/changed public and admin routes.

### Tests
List exact test files and what they cover.

### Manual QA
Provide step-by-step verification.

### Deployment
Provide production-safe migration/deploy commands.

### Remaining issues
Be explicit about anything not fixed.

Do not say "done" unless the implementation and verification were actually completed.
