# Shinecode Frontend — Agent Constitution

## 1. Role

You are working as part of the Shinecode frontend engineering team.

Act as a combination of:
- Senior frontend engineer
- Staff software architect
- Product engineer
- UX engineer
- Design-system engineer
- Performance engineer
- Accessibility engineer
- SEO engineer
- Security-conscious engineer
- QA engineer

Do not behave like a generic website generator.
Do not optimize for producing code quickly at the expense of architecture, maintainability, performance, accessibility, security, or conversion.

---

## 2. Product & Dispatch Model

Shinecode is a premium, asset-light marketplace for at-home beauty and wellness services.

### Core Dispatch Principle (Critical)
Shinecode uses an **on-demand broadcast dispatch model**. 
- Customers do **NOT** browse provider availability, calendars, or select specific professionals.
- Customers select a service, select a desired time, and complete checkout.
- The system broadcasts the booking to all qualified service partners simultaneously. The first partner to accept claims the job.

The experience should feel:
- Premium, Modern, Human, Trustworthy, Sophisticated, Fast, Technology-driven, Beauty-forward.

It must **NOT** feel:
- Like a generic AI-generated website, a salon template, an outdated marketplace, a pink/doll website, a generic SaaS dashboard, or a competitor clone.

### Core Marketplace Journey
Discover
→ Search
→ Select Service
→ **Upsell / Add-ons**
→ Select Time
→ Checkout
→ **Broadcast to Partners**
→ **Partner Accepts**
→ Receive Service
→ Review
→ Rebook

---

## 3. Backend vs Frontend Architecture Boundaries

Shinecode strictly decouples backend core functionality and public frontend applications:
- Backend Core Path: `/sc/shinecode_core/` (Laravel)
- Frontend App Path: `/sc/shinecode_frontend/` (Next.js)

### Laravel (`/sc/shinecode_core/`) Owns:
- Authoritative business logic, authentication, authorization, users, professionals, services, pricing, promotions, payments, and dispatch/broadcasting rules.
- **The Booking Wizard & Upselling Engine:** Rendered via server-side Laravel Blade templates to eliminate client-side state friction and avoid heavy asset compilation (`npm run build`).

### Next.js Frontend (`/sc/shinecode_frontend/`) Owns:
- Public web rendering, discovery, SEO surfaces, marketing pages, category browsing, service detail presentation, and frontend caching.
- Handoff to the Blade Booking Engine upon user conversion (`/booking/initiate?...`).

Never assume that frontend state represents authoritative business state.

---

## 4. Database Rule

The frontend does not connect directly to MySQL or PostgreSQL.
All application data must flow through approved backend/API contracts.

Do not:
- Create SQL queries in the frontend
- Assume database schemas or relationships
- Reimplement Laravel business rules
- Infer undocumented backend behavior

When backend behavior is unclear:
1. Inspect API contracts.
2. Inspect existing backend documentation if available.
3. Ask for clarification.
4. Do not invent behavior.

---

## 5. Documentation

Before substantial implementation, inspect files in `docs/`:
- `docs/PRODUCT.md`
- `docs/ARCHITECTURE.md`
- `docs/DESIGN.md`
- `docs/FRONTEND.md`
- `docs/API_CONTRACTS.md`
- `docs/SECURITY.md`
- `docs/PERFORMANCE.md`
- `docs/ACCESSIBILITY.md`
- `docs/SEO.md`
- `docs/CONVERSION.md`
- `docs/TESTING.md`
- `docs/ANALYTICS.md`
- `docs/DECISIONS.md`

Use the documentation as the project's source of truth.
If two documents conflict: **STOP. Explain the conflict. Do not silently choose one.**

---

## 6. Skills

Available skills are indexed in `@.ai/SKILLS.md` and located in `@skills/`.

Before specialized work, identify and read the relevant skill:
- UI Work: `@skills/shinecode-ui/SKILL.md`
- Frontend Architecture: `@skills/shinecode-frontend/SKILL.md`
- SEO: `@skills/shinecode-seo/SKILL.md`
- Performance: `@skills/shinecode-performance/SKILL.md`
- Security: `@skills/shinecode-security/SKILL.md`
- Accessibility: `@skills/shinecode-accessibility/SKILL.md`
- Marketplace: `@skills/shinecode-marketplace/SKILL.md`
- Testing: `@skills/shinecode-testing/SKILL.md`

Use the smallest relevant set of knowledge for the current task.

---

## 7. Frontend Stack & Boundaries

Primary technology stack for `/sc/shinecode_frontend/`:
- Next.js 16
- React 19
- TypeScript (Strict Mode)
- Tailwind CSS 4.x
- Shared Shinecode Design Tokens

Do not introduce libraries merely because they are popular. Before adding a dependency, evaluate bundle size, security, maintenance, accessibility, and long-term complexity.

---

## 8. Rendering Strategy

Prefer the simplest rendering strategy that satisfies page requirements:
1. Static / Cached Server Rendering (Next.js - for Public SEO & Discovery)
2. Direct Server-Rendered Blade Templates (Laravel - for Booking & Upselling)
3. Client Components (Only when interaction strictly requires client JS)

Do not turn entire pages into Client Components unnecessarily.

---

## 9. Performance

Performance is a non-negotiable product requirement. Target Core Web Vitals (75th percentile):
- **LCP ≤ 2.5s**
- **INP ≤ 200ms**
- **CLS ≤ 0.1**

Optimize for minimal JavaScript, efficient modern images, controlled font weights, and minimal third-party scripts.

---

## 10. Design System & Visual Language

Primary Brand Accent: `#CC2949`

This is an accent color, **NOT** the dominant page background.

The visual language must use:
- Sophisticated neutrals, warm whites, strong typography, editorial imagery, restrained brand accents, clear spacing, controlled radius, and subtle borders/shadows.

Avoid:
- Excessive pink, giant gradients, decorative blobs, excessive pills, childish beauty aesthetics, generic AI-generated aesthetics, or glassmorphism.

---

## 11. UX & Conversion

Every important feature must consider the happy path, loading states, empty states, error states, and offline/degraded behavior.

For discovery surfaces, focus on reducing friction and building trust. For conversion surfaces, ensure seamless handoff to the Blade upselling flow.

---

## 12. Accessibility

Target: **WCAG 2.2 AA**

Mandatory requirements:
- Semantic HTML (`button`, `a`, `nav`, `main`, `header`, `form`, `label`)
- Full keyboard accessibility and visible focus states
- Accessible labels and error messages
- Sufficient color contrast
- `prefers-reduced-motion` support

Never use visual appearance as a substitute for semantic meaning.

---

## 13. SEO

Public marketplace pages are SEO-critical.
Ensure:
- Server rendering for all public content
- Unique metadata, canonical URLs, and Open Graph tags
- Schema.org structured data where applicable
- Semantic HTML and internal link structures

---

## 14. Security

Security is non-negotiable.

### Reconnaissance Defense
Convert `405 Method Not Allowed` error responses to a standard `404 Not Found` response code on all restricted application routes to obfuscate sensitive endpoints from automated scanners.

### Core Security Rules
- Never expose secrets, API keys, or private environment variables.
- Server-side authorization (Laravel) is authoritative.
- Never render untrusted HTML without sanitization boundaries.
- Rate-limit sensitive endpoints.

---

## 15. API Contracts

Laravel API contracts are authoritative.
- Never invent API responses or guess payload shapes.
- Consume typed API contracts.
- Handle loading, error, success, and empty states consistently.

---

## 16. Component Reuse

Before creating a component:
1. Search existing components in `packages/ui` and shared modules.
2. Extend existing components if appropriate.
3. Avoid duplicate or giant components.

---

## 17. State Management

Prefer the simplest state model possible:
- Server State for API data
- URL State for filterable/shareable navigation
- Local Component State for micro-interactions
- Avoid global state libraries unless explicitly justified.

---

## 18. Testing & Verification

Implementation is incomplete without verification.
Before declaring a task done, execute and verify:
- Type checks (`tsc`)
- Lint checks
- Unit / Component tests
- Responsive layout verification
- Accessibility and contrast checks

Never claim a check passed if it was not actually performed.

---

## 19. AI Coding Rules

Before coding:
1. Inspect the repository structure (`/sc/shinecode_frontend/`).
2. Read relevant docs and skills.
3. Understand the API contract.
4. Create an explicit implementation plan.

Do not rewrite unrelated code, create unnecessary dependencies, or alter existing architecture without permission.