How ahmed-niaz/open_shop_server works
This is a NestJS product-catalog API. Clients create products, list them with active/price filters, fetch by ID, and delete by ID; CQRS dispatches those requests to command/query handlers, which apply domain rules and use a repository backed by PostgreSQL. The graph also includes application bootstrap and shared persistence/error handling. Wiring for the Mongo module and some module registrations is not shown in the sampled source, so uncertain runtime links are omitted.
Main entry points: drizzle-product.repository.ts Drizzle repository · product.repository.port.ts Repository port · proudct.controller.ts Product controller · create-product.handler.ts Create handler
Components 21
HTTP API
- Nest bootstrap
server/src/main.ts - Product controller
server/src/product/presentation/proudct.controller.ts - Request/response DTOs
server/src/product/presentation/dto/create-product.dto.ts - App module
server/src/app.module.ts - Exception filters
server/src/shared/infrastructure/filters/application-exception.filters.ts
CQRS Application
- Product commands
server/src/product/application/use-cases - Create handler
server/src/product/application/use-cases/create-product/create-product.handler.ts - Delete handler
server/src/product/application/use-cases/delete-product/delete-product.handler.ts - Product queries
server/src/product/application/queires - Get handler
server/src/product/application/queires/handlers/get-product.handler.ts - List handler
server/src/product/application/queires/handlers/list-product.handler.ts - Repository port
server/src/product/application/ports/product.repository.port.ts
Product Domain
- Product entity
server/src/product/domain/entities/proudct.entity.ts - Product value objects
server/src/product/domain/value-objects/product-id.vo.ts - Money value object
server/src/shared/domain/value-objects/money.vo.ts - Domain exceptions
server/src/shared/domain/exceptions/domain.exception.ts
Persistence
- Drizzle repository
server/src/product/infrastructure/adapters/drizzle-product.repository.ts - Products schema
server/src/shared/infrastructure/database/postgres/schema/products.schema.ts - Drizzle provider
server/src/shared/infrastructure/database/postgres/drizzle.provider.ts
Other components
- API client
- PostgreSQL
Connections 26
- API client → Product controller: sends HTTP
- Nest bootstrap → App module: creates app
- Nest bootstrap → Exception filters: registers filters
- Product controller → Request/response DTOs: validates/maps
- Product controller → Product commands: creates commands
- Product controller → Product queries: creates queries
- Product commands → Create handler: dispatches
- Product commands → Delete handler: dispatches
- Product queries → Get handler: dispatches
- Product queries → List handler: dispatches
- Create handler → Repository port: checks and saves
- Delete handler → Repository port: finds and deletes
- Get handler → Repository port: finds product
- List handler → Repository port: lists filtered
- Create handler → Product entity: creates entity
- Create handler → Product value objects: creates SKU
- Delete handler → Product value objects: wraps product ID
- Get handler → Product value objects: wraps product ID
- Repository port → Drizzle repository: implemented by
- Drizzle repository → Products schema: queries and writes
- Drizzle repository → Drizzle provider: uses connection
- Drizzle repository → Product entity: reconstitutes entities
- Drizzle repository → Product value objects: maps identifiers
- Drizzle repository → Money value object: maps prices
- Drizzle provider → PostgreSQL: connects to
- Products schema → PostgreSQL: defines table