# Catalog Service

> Polymorphic product management for multi-vertical commerce platform.

## Overview

Catalog Service manages products across multiple business verticals (Retail, F&B, Services) with a unified data model using JSONB for type-specific attributes.

### Key Features

- **Polymorphic Products** - Single product table supporting Physical, Service, and PreparedFood types
- **JSONB Attributes** - Dynamic attributes per product type (Weight, Duration, Toppings...)
- **Multi-tenant** - Shop-scoped product catalogs
- **Category Management** - Hierarchical product categories

## Architecture Context

```mermaid
graph LR
    POS["POS / Web"] --> CATALOG["📦 Catalog Service"]
    CATALOG --> MERCHANT["🏪 Merchant Service"]
    ORDER["📝 Order Service"] --> CATALOG
    
    style CATALOG fill:#4a90d9,stroke:#2d5986,color:#fff
```

## Prerequisites

| Requirement | Version |
|-------------|---------|
| .NET SDK | 10.0.101+ |
| Docker | 24.0+ |
| PostgreSQL | 15+ |

## Quick Start

```bash
cd services/catalog-service-net
cp .env.example .env
dotnet restore
dotnet run --project src/CatalogService.API
```

## Project Structure

```
catalog-service-net/
├── src/
│   ├── CatalogService.API/          # Controllers, CQRS
│   ├── CatalogService.Domain/       # Aggregates, Entities
│   └── CatalogService.Infrastructure/ # EF Core, Repositories
├── tests/
│   ├── CatalogService.UnitTests/
│   └── CatalogService.FunctionalTests/
└── docs/
```

## API Endpoints

| Method | Endpoint | Description |
|--------|----------|-------------|
| `GET` | `/api/v1/products` | List products by shop |
| `GET` | `/api/v1/products/{id}` | Get product details |
| `POST` | `/api/v1/products` | Create product |
| `PUT` | `/api/v1/products/{id}` | Update product |
| `DELETE` | `/api/v1/products/{id}` | Delete product |
| `GET` | `/api/v1/categories` | List categories |
| `POST` | `/api/v1/categories` | Create category |

## Domain Model

### Product Types

| Type | Attributes | Example |
|------|------------|---------|
| `Physical` | Weight, Dimensions, SKU | T-shirt, Phone |
| `Service` | Duration, Staff Required | Haircut, Massage |
| `PreparedFood` | Recipe, Toppings, Station | Coffee, Pizza |

### Product Entity (JSONB Attributes)

```csharp
public class Product : Entity, IAggregateRoot
{
    public Guid ShopId { get; private set; }
    public string Name { get; private set; }
    public decimal Price { get; private set; }
    public ProductType Type { get; private set; }
    public JsonDocument? Attributes { get; private set; } // Type-specific
}
```

## Related Services

- [Order Service](../../order-service-net/docs/en/README.md) - Consumes product data
- [Merchant Service](../../merchant-service-net/docs/en/README.md) - Shop configuration
- [Inventory Service](../../inventory-service-net/docs/en/README.md) - Stock for Physical products

## Resources

- [Multi-vertical Architecture](../../../../docs/en/architecture/multi-vertical-architecture.md)
- [DDD with .NET](https://docs.microsoft.com/en-us/dotnet/architecture/microservices/microservice-ddd-cqrs-patterns/)

## License

Proprietary - GoodGo Platform
