Skip to content
Back to skills

Ecommerce Patterns

ASecurity

Общие паттерны магазинов монорепо: корзина, варианты товара, заказы, платежи, гостевая корзина через Better Auth anonymous. Загружай ДО правки моделей Cart/Order/OrderItem и actions корзины и когда гость теряет корзину при входе, оформленный заказ меняется вслед за каталогом, удаление товара ломает историю заказов, сумма в копейках падает «out of range for type integer».

  • 6 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added October 20, 2026
developmenttypescript

Security analysis

A100/100

Pro scans all 7 files and shows the line behind each finding

Scanned October 20, 2026

npx -y skills add kamiletar/letar --skill ecommerce-patterns --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Ecommerce Patterns?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Ecommerce Patterns
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/kamiletar-ecommerce-patterns/badge)](https://www.skillsdirectory.com/skills/kamiletar-ecommerce-patterns)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: ecommerce-patterns
description: |
  Общие паттерны магазинов монорепо: корзина, варианты товара, заказы, платежи, гостевая корзина через Better Auth anonymous. Загружай ДО правки моделей Cart/Order/OrderItem и actions корзины и когда гость теряет корзину при входе, оформленный заказ меняется вслед за каталогом, удаление товара ломает историю заказов, сумма в копейках падает «out of range for type integer».
---

# E-commerce Patterns

Общие паттерны для магазинов монорепо: корзина, варианты товара, заказы, платежи. Не привязаны
к конкретному приложению — примеры ниже условные, конкретная реализация каждого магазина может
отличаться в деталях.

> Модель корзины/заказа с вариантами товара, снэпшотами и правилом «снять с продажи, а не
> удалить» — подробно и с обоснованием каждого решения: [ecommerce-cart-orders.md](/.claude/docs/ecommerce-cart-orders.md).

## ⚠️ Ловушки (разборы в доках)

- [ecommerce-cart-orders](/.claude/docs/ecommerce-cart-orders.md) — снэпшоты в `OrderItem`, слияние анонимной корзины, «снять с продажи» вместо удаления, anonymous-сессии
- [zenstack-int4-overflow-money-fields](/.claude/docs/zenstack-int4-overflow-money-fields.md) — сумма в копейках в `Int` падает за ≈21,47 млн ₽

## Когда использовать

- Работа с корзиной покупок
- Создание/изменение заказов
- Интеграция платёжных систем
- Управление скидками и промокодами

## Основные сущности

```zmodel
model Cart {
  id        String     @id @default(cuid())
  userId    String     @unique
  user      User       @relation(...)
  items     CartItem[]
  updatedAt DateTime   @updatedAt
}

model Order {
  id          String      @id @default(cuid())
  userId      String
  status      OrderStatus @default(PENDING)
  items       OrderItem[]
  total       BigInt      // в копейках (BigInt: Int4 переполняется на ≈21,47 млн ₽)
  payment     Payment?
  createdAt   DateTime    @default(now())
}
```

## Статусы заказа

```typescript
enum OrderStatus {
  PENDING     // Ожидает оплаты
  PAID        // Оплачен
  PROCESSING  // В обработке
  SHIPPED     // Отправлен
  DELIVERED   // Доставлен
  CANCELLED   // Отменён
}
```

## Критичные правила

- **MUST** хранить цены в копейках целым числом (не Float); суммы заказов, платежей и итоги — `BigInt`, цену за единицу — `Int`, см. [zenstack-int4-overflow-money-fields](/.claude/docs/zenstack-int4-overflow-money-fields.md)
- **MUST** валидировать наличие товара перед оформлением
- **SHOULD** использовать транзакции для критичных операций
- **NEVER** хранить данные карт в БД

## Reference файлы

- `reference/cart-patterns.md` — работа с корзиной
- `reference/order-workflow.md` — жизненный цикл заказа
- `reference/payment-integration.md` — интеграция платежей
- `reference/inventory.md` — управление наличием
- `reference/pricing-discounts.md` — цены и скидки
- `reference/checkout-flow.md` — процесс оформления

Files in this skill

  • SKILL.md4 KB
  • reference/cart-patterns.md8.8 KB
  • reference/checkout-flow.md15.7 KB
  • reference/inventory.md11 KB
  • reference/order-workflow.md11 KB
  • reference/payment-integration.md10.5 KB
  • reference/pricing-discounts.md12.7 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.