The Catalog service is the product database for Shop Microservers. It serves a read-only product listing to anonymous users and exposes a stock-decrement endpoint that the orders service calls internally during checkout. Product data is persisted in PostgreSQL and includes category, pricing, stock count, and an image URL. On first boot the service automatically seeds 12 sample products across five categories so the storefront is immediately populated without any manual setup.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/astrxnomo/shop-microservers/llms.txt
Use this file to discover all available pages before exploring further.
Overview
Runtime
Express on port 3001 inside Docker. Gateway prefix:
/api/catalog/.Database
PostgreSQL — database name
catalog_db. Schema managed by Prisma.Authentication
No authentication required for read endpoints. The stock-update endpoint is called only by the orders service internally.
Auto-seeding
12 products are seeded idempotently on first startup via
src/lib/seed.ts.Endpoints
| Method | Path | Auth | Description |
|---|---|---|---|
| GET | /products | None | List all products |
| GET | /products/:id | None | Get a single product by ID |
| PATCH | /products/:id/stock | None* | Decrement the stock count for a product |
* The
PATCH /products/:id/stock endpoint has no authentication middleware, but it is not publicly advertised to end users. It is called exclusively by the orders service over Docker’s internal network during the checkout flow. Exposing it to the public gateway is intentional for service-to-service simplicity in this architecture — production deployments should restrict it to internal traffic only.Data Model
Auto-Seeding
On first boot,seedIfEmpty() in src/lib/seed.ts checks whether any products already exist. If the table is empty, it inserts all 12 products in a single createMany call:
| Category | Products |
|---|---|
| Electrónica | Auriculares Inalámbricos Pro, Teclado Mecánico RGB, Hub USB-C 7 en 1, Reloj Inteligente Serie 5, Base de Carga Inalámbrica |
| Calzado | Zapatillas de Correr X200 |
| Accesorios | Billetera de Cuero Slim, Mochila 30L Impermeable |
| Hogar y Cocina | Botella Térmica Acero Inox, Molino de Café Eléctrico, Lámpara LED de Escritorio |
| Deportes | Tapete de Yoga Antideslizante |
Stock Management
ThePATCH /products/:id/stock endpoint accepts a decrement integer and reduces the stock field by that amount. The request body is validated with Zod:
Response Shape
All catalog responses follow the platform-wide envelope:data field is a single Product object rather than an array.
Error Cases
| HTTP Status | Condition |
|---|---|
404 | Product ID does not exist |
409 | Requested decrement exceeds available stock |
400 | Request body fails Zod validation |
API Reference
GET /products
Retrieve all products.
GET /products/:id
Retrieve a single product by ID.
PATCH /products/:id/stock
Decrement product stock (internal).