# brsenax/p21-poo architecture

> Architecture diagram of the GitHub repository brsenax/p21-poo, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/brsenax/p21-poo
- Repository: https://github.com/brsenax/p21-poo

## Overview

This is a small TypeScript order-management example. Its demonstrated workflow creates customers, products, and orders; adds, removes, or reprices line items; calculates totals; and finalizes or cancels orders. The product repository offers in-memory product storage, while the service provides order creation and product addition. Promotional line items are also implemented, but their use is not shown in the runner. The README contains no additional capability details; relationships below are limited to calls and references visible in the supplied source.

Main entry points: [`src/entities/itemPedido.ts`](https://github.com/brsenax/p21-poo/blob/main/src/entities/itemPedido.ts) (Order item), [`src/entities/produto.ts`](https://github.com/brsenax/p21-poo/blob/main/src/entities/produto.ts) (Product), [`src/index.ts`](https://github.com/brsenax/p21-poo/blob/main/src/index.ts) (Demo runner), [`src/services/pedidoService.ts`](https://github.com/brsenax/p21-poo/blob/main/src/services/pedidoService.ts) (Order service)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_workflow["Order workflow"]
  node_runner["Demo runner<br/>[index.ts]"]
  node_service["Order service<br/>[pedidoService.ts]"]
end

subgraph group_domain["Order domain"]
  node_order["Order<br/>[pedido.ts]"]
  node_customer["Customer<br/>[cliente.ts]"]
  node_line["Order item<br/>[itemPedido.ts]"]
  node_promo["Promo item"]
end

subgraph group_catalog["Product catalog"]
  node_product["Product<br/>[produto.ts]"]
  node_productrepo["Product repository"]
end

node_runner -->|"creates"| node_customer
node_runner -->|"creates, manages"| node_order
node_runner -->|"creates"| node_product
node_runner -->|"creates"| node_line
node_order -->|"holds"| node_customer
node_order -->|"manages, totals"| node_line
node_line -->|"prices from"| node_product
node_promo -->|"extends"| node_line
node_promo -->|"accepts"| node_product
node_service -->|"creates, adds to"| node_order
node_service -->|"creates"| node_line
node_service -->|"accepts"| node_customer
node_service -->|"accepts"| node_product
node_productrepo -->|"stores, finds"| node_product

click node_runner "https://github.com/brsenax/p21-poo/blob/main/src/index.ts"
click node_service "https://github.com/brsenax/p21-poo/blob/main/src/services/pedidoService.ts"
click node_order "https://github.com/brsenax/p21-poo/blob/main/src/entities/pedido.ts"
click node_customer "https://github.com/brsenax/p21-poo/blob/main/src/entities/cliente.ts"
click node_line "https://github.com/brsenax/p21-poo/blob/main/src/entities/itemPedido.ts"
click node_promo "https://github.com/brsenax/p21-poo/blob/main/src/entities/itemPedidoPromocional.ts"
click node_product "https://github.com/brsenax/p21-poo/blob/main/src/entities/produto.ts"
click node_productrepo "https://github.com/brsenax/p21-poo/blob/main/src/repositories/produtoRepository.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_runner,node_service toneBlue
class node_order,node_customer,node_line,node_promo toneAmber
class node_product,node_productrepo toneMint
```

## Components

### Order workflow

- [Demo runner](https://github.com/brsenax/p21-poo/blob/main/src/index.ts): `src/index.ts`
- [Order service](https://github.com/brsenax/p21-poo/blob/main/src/services/pedidoService.ts): `src/services/pedidoService.ts`

### Order domain

- [Order](https://github.com/brsenax/p21-poo/blob/main/src/entities/pedido.ts): `src/entities/pedido.ts`
- [Customer](https://github.com/brsenax/p21-poo/blob/main/src/entities/cliente.ts): `src/entities/cliente.ts`
- [Order item](https://github.com/brsenax/p21-poo/blob/main/src/entities/itemPedido.ts): `src/entities/itemPedido.ts`
- [Promo item](https://github.com/brsenax/p21-poo/blob/main/src/entities/itemPedidoPromocional.ts): `src/entities/itemPedidoPromocional.ts`

### Product catalog

- [Product](https://github.com/brsenax/p21-poo/blob/main/src/entities/produto.ts): `src/entities/produto.ts`
- [Product repository](https://github.com/brsenax/p21-poo/blob/main/src/repositories/produtoRepository.ts): `src/repositories/produtoRepository.ts`

## Connections

- Demo runner → Customer: creates (evidence: `src/index.ts`)
- Demo runner → Order: creates, manages (evidence: `src/index.ts`)
- Demo runner → Product: creates (evidence: `src/index.ts`)
- Demo runner → Order item: creates (evidence: `src/index.ts`)
- Order → Customer: holds (evidence: `src/entities/pedido.ts`)
- Order → Order item: manages, totals (evidence: `src/entities/pedido.ts`)
- Order item → Product: prices from (evidence: `src/entities/itemPedido.ts`)
- Promo item → Order item: extends (evidence: `src/entities/itemPedidoPromocional.ts`)
- Promo item → Product: accepts (evidence: `src/entities/itemPedidoPromocional.ts`)
- Order service → Order: creates, adds to (evidence: `src/services/pedidoService.ts`)
- Order service → Order item: creates (evidence: `src/services/pedidoService.ts`)
- Order service → Customer: accepts (evidence: `src/services/pedidoService.ts`)
- Order service → Product: accepts (evidence: `src/services/pedidoService.ts`)
- Product repository → Product: stores, finds (evidence: `src/repositories/produtoRepository.ts`)
