# martinfmelendez/coderhouse-backend-3 architecture

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

- Interactive diagram: https://gitdiagram.com/martinfmelendez/coderhouse-backend-3
- Repository: https://github.com/martinfmelendez/coderhouse-backend-3

## Overview

Shipnow is a small Express/Mongoose products API. A client request enters the app, is routed to the products controller, and proceeds through the service and repository to the Mongo persistence adapter; the controller returns the result as JSON. Startup loads required environment variables, starts the HTTP listener, and connects to MongoDB. Product schema and status constants represent the persistence model. Error middleware is registered globally; the excerpts show the controller forwarding failures, but not the full Express error-dispatch path.

Main entry points: [`src/app.js`](https://github.com/martinfmelendez/coderhouse-backend-3/blob/main/src/app.js) (Express App), [`src/server.js`](https://github.com/martinfmelendez/coderhouse-backend-3/blob/main/src/server.js) (HTTP Server), [`src/controllers/products.controller.js`](https://github.com/martinfmelendez/coderhouse-backend-3/blob/main/src/controllers/products.controller.js) (Products Controller), [`src/config/configDB.js`](https://github.com/martinfmelendez/coderhouse-backend-3/blob/main/src/config/configDB.js) (Database Connection)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["HTTP API"]
  node_app["Express App<br/>[app.js]"]
  node_route_index["API Router<br/>[index.router.js]"]
  node_products_route["Products Route<br/>[products.router.js]"]
  node_error_handler["Error Handler<br/>[errorHanddler.js]"]
end

subgraph group_products["Product Workflow"]
  node_controller["Products Controller"]
  node_service["Products Service"]
  node_repository["Products Repository"]
  node_product_constants["Product Status Constants"]
end

subgraph group_storage["Persistence"]
  node_mongo_adapter["Products Mongo Adapter<br/>[products.mongo.js]"]
  node_product_model["Product Model<br/>[products.model.js]"]
end

subgraph group_runtime["Runtime Setup"]
  node_server["HTTP Server<br/>[server.js]"]
  node_env["Environment Config<br/>[variablesEnv.js]"]
  node_db_config["Database Connection<br/>[configDB.js]"]
end

node_client(("API Client"))
node_mongodb[("MongoDB")]

node_client -->|"sends request"| node_app
node_app -->|"mounts at /api"| node_route_index
node_app -->|"registers handler"| node_error_handler
node_route_index -->|"mounts /products"| node_products_route
node_products_route -->|"handles GET"| node_controller
node_controller -->|"requests products"| node_service
node_service -->|"gets products"| node_repository
node_repository -->|"delegates query"| node_mongo_adapter
node_mongo_adapter -->|"imports model"| node_product_model
node_product_model -->|"uses status"| node_product_constants
node_controller -.->|"forwards errors"| node_error_handler
node_server -->|"starts listener"| node_app
node_server -->|"reads port"| node_env
node_server -->|"connects on startup"| node_db_config
node_db_config -->|"reads URI"| node_env
node_db_config -->|"connects"| node_mongodb

click node_app "https://github.com/martinfmelendez/coderhouse-backend-3/blob/main/src/app.js"
click node_route_index "https://github.com/martinfmelendez/coderhouse-backend-3/blob/main/src/routers/index.router.js"
click node_products_route "https://github.com/martinfmelendez/coderhouse-backend-3/blob/main/src/routers/products.router.js"
click node_controller "https://github.com/martinfmelendez/coderhouse-backend-3/blob/main/src/controllers/products.controller.js"
click node_error_handler "https://github.com/martinfmelendez/coderhouse-backend-3/blob/main/src/middlewares/errorHanddler.js"
click node_service "https://github.com/martinfmelendez/coderhouse-backend-3/blob/main/src/services/products.service.js"
click node_repository "https://github.com/martinfmelendez/coderhouse-backend-3/blob/main/src/repositories/products.repository.js"
click node_mongo_adapter "https://github.com/martinfmelendez/coderhouse-backend-3/blob/main/src/DAO/mongo/products.mongo.js"
click node_product_model "https://github.com/martinfmelendez/coderhouse-backend-3/blob/main/src/DAO/models/products.model.js"
click node_product_constants "https://github.com/martinfmelendez/coderhouse-backend-3/blob/main/src/utils/products.constants.js"
click node_server "https://github.com/martinfmelendez/coderhouse-backend-3/blob/main/src/server.js"
click node_env "https://github.com/martinfmelendez/coderhouse-backend-3/blob/main/src/config/variablesEnv.js"
click node_db_config "https://github.com/martinfmelendez/coderhouse-backend-3/blob/main/src/config/configDB.js"

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_app,node_route_index,node_products_route,node_error_handler,node_client toneBlue
class node_controller,node_service,node_repository,node_product_constants,node_mongodb toneAmber
class node_mongo_adapter,node_product_model toneMint
class node_server,node_env,node_db_config toneRose
```

## Components

### HTTP API

- [Express App](https://github.com/martinfmelendez/coderhouse-backend-3/blob/main/src/app.js): `src/app.js`
- [API Router](https://github.com/martinfmelendez/coderhouse-backend-3/blob/main/src/routers/index.router.js): `src/routers/index.router.js`
- [Products Route](https://github.com/martinfmelendez/coderhouse-backend-3/blob/main/src/routers/products.router.js): `src/routers/products.router.js`
- [Error Handler](https://github.com/martinfmelendez/coderhouse-backend-3/blob/main/src/middlewares/errorHanddler.js): `src/middlewares/errorHanddler.js`

### Product Workflow

- [Products Controller](https://github.com/martinfmelendez/coderhouse-backend-3/blob/main/src/controllers/products.controller.js): `src/controllers/products.controller.js`
- [Products Service](https://github.com/martinfmelendez/coderhouse-backend-3/blob/main/src/services/products.service.js): `src/services/products.service.js`
- [Products Repository](https://github.com/martinfmelendez/coderhouse-backend-3/blob/main/src/repositories/products.repository.js): `src/repositories/products.repository.js`
- [Product Status Constants](https://github.com/martinfmelendez/coderhouse-backend-3/blob/main/src/utils/products.constants.js): `src/utils/products.constants.js`

### Persistence

- [Products Mongo Adapter](https://github.com/martinfmelendez/coderhouse-backend-3/blob/main/src/DAO/mongo/products.mongo.js): `src/DAO/mongo/products.mongo.js`
- [Product Model](https://github.com/martinfmelendez/coderhouse-backend-3/blob/main/src/DAO/models/products.model.js): `src/DAO/models/products.model.js`

### Runtime Setup

- [HTTP Server](https://github.com/martinfmelendez/coderhouse-backend-3/blob/main/src/server.js): `src/server.js`
- [Environment Config](https://github.com/martinfmelendez/coderhouse-backend-3/blob/main/src/config/variablesEnv.js): `src/config/variablesEnv.js`
- [Database Connection](https://github.com/martinfmelendez/coderhouse-backend-3/blob/main/src/config/configDB.js): `src/config/configDB.js`

### Other components

- **API Client**
- **MongoDB**

## Connections

- API Client → Express App: sends request (evidence: `src/app.js`)
- Express App → API Router: mounts at /api (evidence: `src/app.js`)
- Express App → Error Handler: registers handler (evidence: `src/app.js`)
- API Router → Products Route: mounts /products (evidence: `src/routers/index.router.js`)
- Products Route → Products Controller: handles GET (evidence: `src/routers/products.router.js`)
- Products Controller → Products Service: requests products (evidence: `src/controllers/products.controller.js`)
- Products Service → Products Repository: gets products (evidence: `src/services/products.service.js`)
- Products Repository → Products Mongo Adapter: delegates query (evidence: `src/repositories/products.repository.js`)
- Products Mongo Adapter → Product Model: imports model (evidence: `src/DAO/mongo/products.mongo.js`)
- Product Model → Product Status Constants: uses status (evidence: `src/DAO/models/products.model.js`)
- Products Controller → Error Handler: forwards errors
- HTTP Server → Express App: starts listener (evidence: `src/server.js`)
- HTTP Server → Environment Config: reads port (evidence: `src/server.js`)
- HTTP Server → Database Connection: connects on startup (evidence: `src/server.js`)
- Database Connection → Environment Config: reads URI (evidence: `src/config/configDB.js`)
- Database Connection → MongoDB: connects (evidence: `src/config/configDB.js`)
