# FULL PROJECT POLISH + SECURITY + MODULAR ARCHITECTURE + SEO INFRASTRUCTURE PRD (STRICT TOKEN EFFICIENCY MODE)

## ROLE
You are a precision development assistant working ONLY within the existing project structure.

# PRIMARY OBJECTIVE
Polish, debug, optimize, secure, modularize, and enhance the existing wellness/fitness affiliate website with MINIMUM token usage while preserving current branding and core structure.

---

# MASTER PRIORITIES
1. Fix bugs
2. Improve main site stability
3. Build admin portal enhancements
4. Improve maintainability with modular architecture
5. Strengthen backend security
6. Reduce scraping risks
7. Improve SEO visibility
8. Add sitemap/indexing structure
9. Improve speed/performance
10. Remove redundancy

---

# NON-NEGOTIABLE EXECUTION RULES
1. ONLY improve the current project.
2. DO NOT rebuild from scratch.
3. DO NOT redesign unnecessarily.
4. DO NOT inspect unrelated files.
5. DO NOT create unnecessary files.
6. DO NOT expose sensitive logic in frontend.
7. DO NOT store secure logic client-side if backend protection is possible.
8. DO NOT over-engineer beyond requested scope.
9. FIRST audit, THEN plan, THEN approval.
10. Use modular structure for maintainability.
11. Use minimum tokens by focusing only on requested sections.
12. Security-first implementation.
13. Performance-first optimization.

---

# PHASE 1 — FULL LIMITED-SCOPE AUDIT

## AUDIT ONLY:
### MAIN SITE:
- Homepage
- Discover page
- Supplement pages
- Equipment pages
- Routing/navigation
- Product rendering
- SEO pages

### ADMIN:
- Product management
- Dashboard
- Product CRUD
- Publish logic
- Page controls

### TOOLS:
- Fitness planner
- Nutritional meal planner

### ARCHITECTURE:
- File structure
- Redundant files
- Duplicate logic
- Tight coupling
- Reusable modules
- Backend/frontend separation

### SECURITY:
- API exposure
- Public keys
- Admin route vulnerabilities
- Scraping vulnerabilities
- Rate limiting needs
- Sensitive logic exposure
- SEO indexing controls

---

# REQUIRED AUDIT OUTPUT
1. Files inspected
2. Bugs/errors
3. Broken routes
4. Structural issues
5. Security vulnerabilities
6. Scraping risks
7. Performance issues
8. Redundant files
9. Modularization opportunities
10. Wait for approval

---

# PHASE 2 — MODULAR FILE STRUCTURE (MAINTAINABILITY FIRST)

## GOAL:
Restructure ONLY where necessary into maintainable modular architecture.

---

## TARGET STRUCTURE:
### FRONTEND:
- pages/
- components/
- layouts/
- hooks/
- services/
- utils/

### BACKEND:
- routes/
- controllers/
- middleware/
- services/
- models/
- security/

### SEO:
- sitemap
- robots
- metadata utilities

---

# REQUIREMENTS:
1. Separate frontend UI from backend logic
2. Move sensitive technical logic server-side
3. Centralize product management logic
4. Centralize SEO generation
5. Centralize security middleware
6. Reduce code duplication
7. Preserve existing functionality

---

# PHASE 3 — SECURITY HARDENING

## REQUIRED:
### BACKEND SECURITY:
- Protect admin routes
- Role-based admin access
- Hide sensitive configs
- Validate inputs
- Sanitize forms
- Secure affiliate links where possible
- Rate limiting
- API request protection
- Environment variable cleanup
- Error handling without exposing system details

---

## SCRAPING + BOT PROTECTION:
### IMPLEMENT:
- robots.txt
- Basic anti-bot measures
- Rate limiting
- Request throttling
- Header hardening
- Metadata control
- Prevent unnecessary public data dumps
- Secure product/API endpoints where possible

---

## IMPORTANT:
No system can fully stop scraping, but significantly reduce:
- Automated abuse
- Basic scraping
- Vulnerability exposure

---

# PHASE 4 — SEO + GOOGLE + AI SEARCH INFRASTRUCTURE

## REQUIRED:
### SITEMAP:
- Dynamic or static sitemap.xml
- Include:
  - Homepage
  - Discover
  - Supplements pages
  - Equipment pages
  - Product pages
  - Blog/SEO pages

---

### ROBOTS:
- Proper crawl permissions
- Protect admin/private sections
- Allow public SEO pages

---

### METADATA:
- Product SEO titles
- Descriptions
- Schema-friendly structure
- AI-search discoverability
- Internal linking

---

# GOAL:
Make site visible to:
- Google
- Search engines
- AI search systems
- Organic discovery

---

# PHASE 5 — ADMIN PORTAL ENHANCEMENT
## PRODUCT MANAGEMENT:
### REQUIRED FIELDS:
1. Product Name
2. Affiliate Link
3. Product Image
4. SEO Description
5. AI SEO Generator
6. Category
7. Page Number
8. Publish Status

---

# PHASE 6 — MAIN SITE BUG FIXES
## FIX:
- Discover page
- Supplement pages
- Equipment pages
- Routing
- Broken links
- Rendering issues
- Product visibility logic

---

# PHASE 7 — FITNESS + NUTRITION PLANNER
## FIX:
- Logic bugs
- Stability
- UX
- Responsiveness
- Output reliability

---

# PHASE 8 — PERFORMANCE OPTIMIZATION
## REMOVE:
- Dead files
- Duplicate code
- Redundant assets
- Unused dependencies

## OPTIMIZE:
- Speed
- Rendering
- DB queries
- Lazy loading where necessary
- Site responsiveness

---

# DELIVERABLE FORMAT BEFORE CODING

## SECTION A — AUDIT
- Files
- Bugs
- Main site
- Admin
- Security
- SEO
- Redundancy
- Structure

## SECTION B — MODULAR PLAN
- File structure improvements
- Security improvements
- SEO infrastructure
- Performance plan

## SECTION C — IMPLEMENTATION PLAN
- Phase-by-phase edits
- Wait for approval

---

# STRICT CAUTION
DO NOT:
- Break live features
- Rebrand
- Overcomplicate
- Expand scope
- Add unnecessary dependencies
- Expose backend logic

---

# MASTER COMMAND
Polish and optimize ONLY the current project with minimum token usage while implementing:
- Main site bug fixes
- Discover/Supplement/Equipment fixes
- Admin portal improvements
- AI SEO product descriptions
- Product controls
- Modular maintainable architecture
- Backend security
- Anti-scraping protections
- Sitemap + robots + indexing
- Fitness planner fixes
- Meal planner fixes
- Performance optimization
- Redundant file cleanup

Do EXACTLY what is requested and nothing beyond scope.