# diogobrazil/db-agent-api architecture

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

- Interactive diagram: https://gitdiagram.com/diogobrazil/db-agent-api
- Repository: https://github.com/diogobrazil/db-agent-api

## Overview

db-agent-api is an HTTP API for customer and product records. Requests enter through the application entry point, reach resource controllers, and are handled by CRUD use cases backed by repository implementations and Prisma. The domain also defines customer and product entities and repository contracts. The README does not describe capabilities beyond the product name; repository implementations and entry-point wiring are not excerpted, so uncertain connections are omitted or marked unverified.

Main entry points: [`src/infra/container.ts`](https://github.com/diogobrazil/db-agent-api/blob/main/src/infra/container.ts) (Dependency Container), [`src/index.ts`](https://github.com/diogobrazil/db-agent-api/blob/main/src/index.ts) (Application Entry), [`src/infra/http/controllers/CustomerController.ts`](https://github.com/diogobrazil/db-agent-api/blob/main/src/infra/http/controllers/CustomerController.ts) (Customer Controller), [`src/infra/http/controllers/ProductController.ts`](https://github.com/diogobrazil/db-agent-api/blob/main/src/infra/http/controllers/ProductController.ts) (Product Controller)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_http["HTTP API"]
  node_entry["Application Entry<br/>[index.ts]"]
  node_customer_controller["Customer Controller"]
  node_product_controller["Product Controller"]
  node_container["Dependency Container<br/>[container.ts]"]
  node_errors["Error Handler<br/>[errorHandler.ts]"]
end

subgraph group_domain["Domain Logic"]
  node_customer_ops["Customer CRUD"]
  node_product_ops["Product CRUD"]
  node_customer_contract["Customer Repository"]
  node_product_contract["Product Repository"]
end

subgraph group_persistence["Persistence"]
  node_customer_impl["Customer Persistence"]
  node_product_impl["Product Persistence"]
  node_prisma["Prisma Client<br/>[prisma.ts]"]
  node_database[("Database")]
end

subgraph group_models["Domain Models"]
  node_customer_entity["Customer Entity<br/>[Customer.ts]"]
  node_product_entity["Product Entity<br/>[Products.ts]"]
end

node_client(("API Client"))

node_client -.->|"sends requests"| node_entry
node_entry -.->|"routes requests"| node_customer_controller
node_entry -.->|"routes requests"| node_product_controller
node_entry -.->|"uses bindings"| node_container
node_customer_controller -->|"executes use cases"| node_customer_ops
node_product_controller -->|"executes use cases"| node_product_ops
node_customer_controller -->|"handles errors"| node_errors
node_product_controller -->|"handles errors"| node_errors
node_customer_ops -.->|"uses repository"| node_customer_contract
node_product_ops -.->|"uses repository"| node_product_contract
node_customer_impl -.->|"implements contract"| node_customer_contract
node_product_impl -.->|"implements contract"| node_product_contract
node_customer_impl -.->|"uses client"| node_prisma
node_product_impl -.->|"uses client"| node_prisma
node_prisma -.->|"accesses"| node_database
node_container -->|"binds use cases"| node_customer_ops
node_container -->|"binds use cases"| node_product_ops
node_container -->|"binds controller"| node_customer_controller
node_container -->|"binds controller"| node_product_controller

click node_entry "https://github.com/diogobrazil/db-agent-api/blob/main/src/index.ts"
click node_customer_controller "https://github.com/diogobrazil/db-agent-api/blob/main/src/infra/http/controllers/CustomerController.ts"
click node_product_controller "https://github.com/diogobrazil/db-agent-api/blob/main/src/infra/http/controllers/ProductController.ts"
click node_customer_ops "https://github.com/diogobrazil/db-agent-api/tree/main/src/domain/usecases/customers"
click node_product_ops "https://github.com/diogobrazil/db-agent-api/tree/main/src/domain/usecases/products"
click node_customer_contract "https://github.com/diogobrazil/db-agent-api/blob/main/src/domain/repositories/CustomerRepository.ts"
click node_product_contract "https://github.com/diogobrazil/db-agent-api/blob/main/src/domain/repositories/ProductRepository.ts"
click node_customer_impl "https://github.com/diogobrazil/db-agent-api/blob/main/src/infra/http/repositories/CustomerReposiotyImpl.ts"
click node_product_impl "https://github.com/diogobrazil/db-agent-api/blob/main/src/infra/http/repositories/ProductReposiotyImpl.ts"
click node_prisma "https://github.com/diogobrazil/db-agent-api/blob/main/src/infra/config/prisma.ts"
click node_customer_entity "https://github.com/diogobrazil/db-agent-api/blob/main/src/domain/entities/Customer.ts"
click node_product_entity "https://github.com/diogobrazil/db-agent-api/blob/main/src/domain/entities/Products.ts"
click node_container "https://github.com/diogobrazil/db-agent-api/blob/main/src/infra/container.ts"
click node_errors "https://github.com/diogobrazil/db-agent-api/blob/main/src/utils/errorHandler.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_entry,node_customer_controller,node_product_controller,node_container,node_errors,node_client toneBlue
class node_customer_ops,node_product_ops,node_customer_contract,node_product_contract toneAmber
class node_customer_impl,node_product_impl,node_prisma,node_database toneMint
class node_customer_entity,node_product_entity toneRose
```

## Components

### HTTP API

- [Application Entry](https://github.com/diogobrazil/db-agent-api/blob/main/src/index.ts): `src/index.ts`
- [Customer Controller](https://github.com/diogobrazil/db-agent-api/blob/main/src/infra/http/controllers/CustomerController.ts): `src/infra/http/controllers/CustomerController.ts`
- [Product Controller](https://github.com/diogobrazil/db-agent-api/blob/main/src/infra/http/controllers/ProductController.ts): `src/infra/http/controllers/ProductController.ts`
- [Dependency Container](https://github.com/diogobrazil/db-agent-api/blob/main/src/infra/container.ts): `src/infra/container.ts`
- [Error Handler](https://github.com/diogobrazil/db-agent-api/blob/main/src/utils/errorHandler.ts): `src/utils/errorHandler.ts`

### Domain Logic

- [Customer CRUD](https://github.com/diogobrazil/db-agent-api/tree/main/src/domain/usecases/customers): `src/domain/usecases/customers`
- [Product CRUD](https://github.com/diogobrazil/db-agent-api/tree/main/src/domain/usecases/products): `src/domain/usecases/products`
- [Customer Repository](https://github.com/diogobrazil/db-agent-api/blob/main/src/domain/repositories/CustomerRepository.ts): `src/domain/repositories/CustomerRepository.ts`
- [Product Repository](https://github.com/diogobrazil/db-agent-api/blob/main/src/domain/repositories/ProductRepository.ts): `src/domain/repositories/ProductRepository.ts`

### Persistence

- [Customer Persistence](https://github.com/diogobrazil/db-agent-api/blob/main/src/infra/http/repositories/CustomerReposiotyImpl.ts): `src/infra/http/repositories/CustomerReposiotyImpl.ts`
- [Product Persistence](https://github.com/diogobrazil/db-agent-api/blob/main/src/infra/http/repositories/ProductReposiotyImpl.ts): `src/infra/http/repositories/ProductReposiotyImpl.ts`
- [Prisma Client](https://github.com/diogobrazil/db-agent-api/blob/main/src/infra/config/prisma.ts): `src/infra/config/prisma.ts`
- **Database**

### Domain Models

- [Customer Entity](https://github.com/diogobrazil/db-agent-api/blob/main/src/domain/entities/Customer.ts): `src/domain/entities/Customer.ts`
- [Product Entity](https://github.com/diogobrazil/db-agent-api/blob/main/src/domain/entities/Products.ts): `src/domain/entities/Products.ts`

### Other components

- **API Client**

## Connections

- API Client → Application Entry: sends requests
- Application Entry → Customer Controller: routes requests (evidence: `src/index.ts`)
- Application Entry → Product Controller: routes requests (evidence: `src/index.ts`)
- Application Entry → Dependency Container: uses bindings (evidence: `src/index.ts`)
- Customer Controller → Customer CRUD: executes use cases (evidence: `src/infra/http/controllers/CustomerController.ts`)
- Product Controller → Product CRUD: executes use cases (evidence: `src/infra/http/controllers/ProductController.ts`)
- Customer Controller → Error Handler: handles errors (evidence: `src/infra/http/controllers/CustomerController.ts`)
- Product Controller → Error Handler: handles errors (evidence: `src/infra/http/controllers/ProductController.ts`)
- Customer CRUD → Customer Repository: uses repository (evidence: `src/domain/usecases/customers/UpdateCustomer.ts`)
- Product CRUD → Product Repository: uses repository (evidence: `src/domain/usecases/products/UpdateProduct.ts`)
- Customer Persistence → Customer Repository: implements contract (evidence: `src/infra/http/repositories/CustomerReposiotyImpl.ts`)
- Product Persistence → Product Repository: implements contract (evidence: `src/infra/http/repositories/ProductReposiotyImpl.ts`)
- Customer Persistence → Prisma Client: uses client (evidence: `src/infra/http/repositories/CustomerReposiotyImpl.ts`)
- Product Persistence → Prisma Client: uses client (evidence: `src/infra/http/repositories/ProductReposiotyImpl.ts`)
- Prisma Client → Database: accesses
- Dependency Container → Customer CRUD: binds use cases (evidence: `src/infra/container.ts`)
- Dependency Container → Product CRUD: binds use cases (evidence: `src/infra/container.ts`)
- Dependency Container → Customer Controller: binds controller (evidence: `src/infra/container.ts`)
- Dependency Container → Product Controller: binds controller (evidence: `src/infra/container.ts`)
