# ahmed-niaz/open_shop_server architecture

> Architecture diagram of the GitHub repository ahmed-niaz/open_shop_server, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ahmed-niaz/open_shop_server
- Repository: https://github.com/ahmed-niaz/open_shop_server

## Overview

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: [`server/src/product/infrastructure/adapters/drizzle-product.repository.ts`](https://github.com/ahmed-niaz/open_shop_server/blob/main/server/src/product/infrastructure/adapters/drizzle-product.repository.ts) (Drizzle repository), [`server/src/product/application/ports/product.repository.port.ts`](https://github.com/ahmed-niaz/open_shop_server/blob/main/server/src/product/application/ports/product.repository.port.ts) (Repository port), [`server/src/product/presentation/proudct.controller.ts`](https://github.com/ahmed-niaz/open_shop_server/blob/main/server/src/product/presentation/proudct.controller.ts) (Product controller), [`server/src/product/application/use-cases/create-product/create-product.handler.ts`](https://github.com/ahmed-niaz/open_shop_server/blob/main/server/src/product/application/use-cases/create-product/create-product.handler.ts) (Create handler)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["HTTP API"]
  node_bootstrap["Nest bootstrap<br/>[main.ts]"]
  node_controller["Product controller"]
  node_dto["Request/response DTOs"]
  node_appmodule["App module<br/>[app.module.ts]"]
  node_filters["Exception filters"]
end

subgraph group_application["CQRS Application"]
  node_commands["Product commands"]
  node_createhandler["Create handler"]
  node_deletehandler["Delete handler"]
  node_queries["Product queries"]
  node_gethandler["Get handler"]
  node_listhandler["List handler"]
  node_repoport["Repository port"]
end

subgraph group_domain["Product Domain"]
  node_product["Product entity<br/>[proudct.entity.ts]"]
  node_valueobjects["Product value objects<br/>[product-id.vo.ts]"]
  node_money["Money value object<br/>[money.vo.ts]"]
  node_exceptions["Domain exceptions"]
end

subgraph group_persistence["Persistence"]
  node_repository["Drizzle repository"]
  node_schema["Products schema<br/>[products.schema.ts]"]
  node_dbprovider["Drizzle provider"]
end

node_client(("API client"))
node_postgres[("PostgreSQL")]

node_client -->|"sends HTTP"| node_controller
node_bootstrap -->|"creates app"| node_appmodule
node_bootstrap -->|"registers filters"| node_filters
node_controller -->|"validates/maps"| node_dto
node_controller -->|"creates commands"| node_commands
node_controller -->|"creates queries"| node_queries
node_commands -->|"dispatches"| node_createhandler
node_commands -->|"dispatches"| node_deletehandler
node_queries -->|"dispatches"| node_gethandler
node_queries -->|"dispatches"| node_listhandler
node_createhandler -->|"checks and saves"| node_repoport
node_deletehandler -->|"finds and deletes"| node_repoport
node_gethandler -->|"finds product"| node_repoport
node_listhandler -->|"lists filtered"| node_repoport
node_createhandler -->|"creates entity"| node_product
node_createhandler -->|"creates SKU"| node_valueobjects
node_deletehandler -->|"wraps product ID"| node_valueobjects
node_gethandler -->|"wraps product ID"| node_valueobjects
node_repoport -->|"implemented by"| node_repository
node_repository -->|"queries and writes"| node_schema
node_repository -->|"uses connection"| node_dbprovider
node_repository -->|"reconstitutes entities"| node_product
node_repository -->|"maps identifiers"| node_valueobjects
node_repository -->|"maps prices"| node_money
node_dbprovider -->|"connects to"| node_postgres
node_schema -->|"defines table"| node_postgres

click node_bootstrap "https://github.com/ahmed-niaz/open_shop_server/blob/main/server/src/main.ts"
click node_controller "https://github.com/ahmed-niaz/open_shop_server/blob/main/server/src/product/presentation/proudct.controller.ts"
click node_dto "https://github.com/ahmed-niaz/open_shop_server/blob/main/server/src/product/presentation/dto/create-product.dto.ts"
click node_appmodule "https://github.com/ahmed-niaz/open_shop_server/blob/main/server/src/app.module.ts"
click node_commands "https://github.com/ahmed-niaz/open_shop_server/tree/main/server/src/product/application/use-cases"
click node_createhandler "https://github.com/ahmed-niaz/open_shop_server/blob/main/server/src/product/application/use-cases/create-product/create-product.handler.ts"
click node_deletehandler "https://github.com/ahmed-niaz/open_shop_server/blob/main/server/src/product/application/use-cases/delete-product/delete-product.handler.ts"
click node_queries "https://github.com/ahmed-niaz/open_shop_server/tree/main/server/src/product/application/queires"
click node_gethandler "https://github.com/ahmed-niaz/open_shop_server/blob/main/server/src/product/application/queires/handlers/get-product.handler.ts"
click node_listhandler "https://github.com/ahmed-niaz/open_shop_server/blob/main/server/src/product/application/queires/handlers/list-product.handler.ts"
click node_repoport "https://github.com/ahmed-niaz/open_shop_server/blob/main/server/src/product/application/ports/product.repository.port.ts"
click node_product "https://github.com/ahmed-niaz/open_shop_server/blob/main/server/src/product/domain/entities/proudct.entity.ts"
click node_valueobjects "https://github.com/ahmed-niaz/open_shop_server/blob/main/server/src/product/domain/value-objects/product-id.vo.ts"
click node_money "https://github.com/ahmed-niaz/open_shop_server/blob/main/server/src/shared/domain/value-objects/money.vo.ts"
click node_exceptions "https://github.com/ahmed-niaz/open_shop_server/blob/main/server/src/shared/domain/exceptions/domain.exception.ts"
click node_repository "https://github.com/ahmed-niaz/open_shop_server/blob/main/server/src/product/infrastructure/adapters/drizzle-product.repository.ts"
click node_schema "https://github.com/ahmed-niaz/open_shop_server/blob/main/server/src/shared/infrastructure/database/postgres/schema/products.schema.ts"
click node_dbprovider "https://github.com/ahmed-niaz/open_shop_server/blob/main/server/src/shared/infrastructure/database/postgres/drizzle.provider.ts"
click node_filters "https://github.com/ahmed-niaz/open_shop_server/blob/main/server/src/shared/infrastructure/filters/application-exception.filters.ts"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_bootstrap,node_controller,node_dto,node_appmodule,node_filters,node_client toneBlue
class node_commands,node_createhandler,node_deletehandler,node_queries,node_gethandler,node_listhandler,node_repoport,node_postgres toneAmber
class node_product,node_valueobjects,node_money,node_exceptions toneMint
class node_repository,node_schema,node_dbprovider toneRose
```

## Components

### HTTP API

- [Nest bootstrap](https://github.com/ahmed-niaz/open_shop_server/blob/main/server/src/main.ts): `server/src/main.ts`
- [Product controller](https://github.com/ahmed-niaz/open_shop_server/blob/main/server/src/product/presentation/proudct.controller.ts): `server/src/product/presentation/proudct.controller.ts`
- [Request/response DTOs](https://github.com/ahmed-niaz/open_shop_server/blob/main/server/src/product/presentation/dto/create-product.dto.ts): `server/src/product/presentation/dto/create-product.dto.ts`
- [App module](https://github.com/ahmed-niaz/open_shop_server/blob/main/server/src/app.module.ts): `server/src/app.module.ts`
- [Exception filters](https://github.com/ahmed-niaz/open_shop_server/blob/main/server/src/shared/infrastructure/filters/application-exception.filters.ts): `server/src/shared/infrastructure/filters/application-exception.filters.ts`

### CQRS Application

- [Product commands](https://github.com/ahmed-niaz/open_shop_server/tree/main/server/src/product/application/use-cases): `server/src/product/application/use-cases`
- [Create handler](https://github.com/ahmed-niaz/open_shop_server/blob/main/server/src/product/application/use-cases/create-product/create-product.handler.ts): `server/src/product/application/use-cases/create-product/create-product.handler.ts`
- [Delete handler](https://github.com/ahmed-niaz/open_shop_server/blob/main/server/src/product/application/use-cases/delete-product/delete-product.handler.ts): `server/src/product/application/use-cases/delete-product/delete-product.handler.ts`
- [Product queries](https://github.com/ahmed-niaz/open_shop_server/tree/main/server/src/product/application/queires): `server/src/product/application/queires`
- [Get handler](https://github.com/ahmed-niaz/open_shop_server/blob/main/server/src/product/application/queires/handlers/get-product.handler.ts): `server/src/product/application/queires/handlers/get-product.handler.ts`
- [List handler](https://github.com/ahmed-niaz/open_shop_server/blob/main/server/src/product/application/queires/handlers/list-product.handler.ts): `server/src/product/application/queires/handlers/list-product.handler.ts`
- [Repository port](https://github.com/ahmed-niaz/open_shop_server/blob/main/server/src/product/application/ports/product.repository.port.ts): `server/src/product/application/ports/product.repository.port.ts`

### Product Domain

- [Product entity](https://github.com/ahmed-niaz/open_shop_server/blob/main/server/src/product/domain/entities/proudct.entity.ts): `server/src/product/domain/entities/proudct.entity.ts`
- [Product value objects](https://github.com/ahmed-niaz/open_shop_server/blob/main/server/src/product/domain/value-objects/product-id.vo.ts): `server/src/product/domain/value-objects/product-id.vo.ts`
- [Money value object](https://github.com/ahmed-niaz/open_shop_server/blob/main/server/src/shared/domain/value-objects/money.vo.ts): `server/src/shared/domain/value-objects/money.vo.ts`
- [Domain exceptions](https://github.com/ahmed-niaz/open_shop_server/blob/main/server/src/shared/domain/exceptions/domain.exception.ts): `server/src/shared/domain/exceptions/domain.exception.ts`

### Persistence

- [Drizzle repository](https://github.com/ahmed-niaz/open_shop_server/blob/main/server/src/product/infrastructure/adapters/drizzle-product.repository.ts): `server/src/product/infrastructure/adapters/drizzle-product.repository.ts`
- [Products schema](https://github.com/ahmed-niaz/open_shop_server/blob/main/server/src/shared/infrastructure/database/postgres/schema/products.schema.ts): `server/src/shared/infrastructure/database/postgres/schema/products.schema.ts`
- [Drizzle provider](https://github.com/ahmed-niaz/open_shop_server/blob/main/server/src/shared/infrastructure/database/postgres/drizzle.provider.ts): `server/src/shared/infrastructure/database/postgres/drizzle.provider.ts`

### Other components

- **API client**
- **PostgreSQL**

## Connections

- 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
