# Sinsay Upstream Inventory

## Known Hosts

| Role | Host | Our Prefix |
|------|------|------------|
| Main site (Next.js SSR) | `www.sinsay.com` | `/` (root) |
| Product/category images | `media.sinsay.com` | `/_cdn/media/` |
| Static product images/assets | `static.sinsay.com` | `/_cdn/static/` |
| Cart gRPC-web backend | `fastend.sinsay.com` | `/cart_hamster.cart.CartService/*` |

## How to Verify Cart/Checkout API Endpoints

Open Chrome DevTools → Network tab → Filter by "Fetch/XHR" on https://www.sinsay.com/pl/pl,
then add a product to cart and proceed to checkout. Record every POST/GET request.

### Verified cart/checkout endpoints (2026-05-18)

The current Sinsay frontend does **not** use `/api/cart` or `/api/basket`.
It uses gRPC-web over XHR:

| Action | Verified URL |
|--------|--------------|
| Get cart | `POST https://fastend.sinsay.com/cart_hamster.cart.CartService/Get` |
| Add product | `POST https://fastend.sinsay.com/cart_hamster.cart.CartService/AddProduct` |
| Change qty | `POST https://fastend.sinsay.com/cart_hamster.cart.CartService/ChangeProductQty` |
| Remove product | `POST https://fastend.sinsay.com/cart_hamster.cart.CartService/RemoveProduct` |
| Remove cart | `POST https://fastend.sinsay.com/cart_hamster.cart.CartService/RemoveCart` |
| Remove by product id | `POST https://fastend.sinsay.com/cart_hamster.cart.CartService/RemoveByProductId` |
| Remove by quote id | `POST https://fastend.sinsay.com/cart_hamster.cart.CartService/RemoveByQuoteId` |
| Add coupon | `POST https://fastend.sinsay.com/cart_hamster.cart.CartService/AddCoupon` |
| Remove coupon | `POST https://fastend.sinsay.com/cart_hamster.cart.CartService/RemoveCoupon` |
| Cart page | `GET https://www.sinsay.com/pl/pl/checkout/cart/` |
| Checkout target | `GET https://www.sinsay.com/pl/pl/checkout/order/` |
| Logged-out checkout redirect | `GET /pl/pl/customer/account/login/referer/<base64-checkout-order>/` |

The JS bundle defining these methods is currently:

- `https://www.sinsay.com/pl/pl/skin/frontend/6.460.0/narch/quick-shop/js/sinsay.js`
- `https://www.sinsay.com/pl/pl/skin/frontend/6.460.0/narch/product-card-next/product-card-app.js`

### Legacy/fallback LPP API patterns

| Action | Likely Path |
|--------|-------------|
| Get basket | `GET /api/v1/basket` or `GET /api/basket` |
| Add item | `POST /api/v1/basket/items` |
| Update quantity | `PUT /api/v1/basket/items/{id}` |
| Remove item | `DELETE /api/v1/basket/items/{id}` |
| Checkout page | `GET /pl/pl/checkout` |
| Submit order | `POST /api/v1/orders` |

### Cart response format mock (update `src/intercept/cart.ts` to match real format):

```json
{
  "id": "basket-uuid",
  "items": [
    {
      "id": "item-uuid",
      "productId": "123abc",
      "name": "Koszulka basic",
      "price": 29.99,
      "currency": "PLN",
      "quantity": 1,
      "size": "M",
      "imageUrl": "https://media.sinsay.com/..."
    }
  ],
  "totalPrice": 29.99,
  "totalItems": 1,
  "currency": "PLN"
}
```

### GraphQL (if used):
If Sinsay uses GraphQL at `/graphql`, set `CART_GRAPHQL=true` in `.env` and
implement the mutation intercept in `src/intercept/cart.ts`.

## Next.js Data Fetching Paths
- `/_next/data/<build-id>/pl/pl/*.json` — server-side page data, needs URL rewriting
- `/_next/static/` — static JS/CSS bundles, forwarded to upstream as-is
- `/api/` — API routes, some intercepted, rest forwarded

## Additional CDN Domains (check Network tab for 3rd-party assets):
- Possible: `lppstatic.com`, `res.cloudinary.com`, GTM scripts, etc.
  Add any found to `src/config.ts → upstream.extra[]` and handle in `src/proxy/upstream.ts`.
