# rafaelgoulartb/nodejs-ecommerce architecture

> Architecture diagram of the GitHub repository rafaelgoulartb/nodejs-ecommerce, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-15). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/rafaelgoulartb/nodejs-ecommerce
- Repository: https://github.com/rafaelgoulartb/nodejs-ecommerce

## Overview

#### Purpose and runtime
This is a server-rendered Node.js ecommerce application following an MVC-style split. Express serves product browsing, category/search filtering, user sign-in/sign-up, and a cart/wishlist-oriented checkout surface. It runs locally on port 3000 and is deployable via Heroku’s process model. Primary bootstrap: `index.js`; deployment command: `Procfile`.

#### Application composition
`index.js` is the HTTP composition root: it initializes Express, applies custom framework configuration, exposes static assets, and mounts route modules. `config/custom-express.js` centralizes Express/Handlebars setup and likely defines shared middleware, view resolution, and error behavior. Handlebars templates are rendered server-side from `views/`, using the common shell at `views/layouts/layout.hbs`.

#### Request routing and page stages
Route modules represent the application’s controller layer:
- Home/product discovery: `routes/home.js`, `routes/search.js`
- Cart/checkout: `routes/checkout/cart.js`
- Account lifecycle: `routes/user/signIn.js`, `routes/user/signUp.js`, `routes/user/logOut.js`

A request enters Express, is dispatched to one of these routes, queries persistence through DAO modules where needed, then renders a Handlebars view or redirects. Error presentation is separated into `views/errors/404.hbs` and `views/errors/500.hbs`.

#### Persistence boundary
MySQL is the system of record, with schema/seed material in `equantom.sql`. Database connection creation is isolated in `dao/connectionFactory.js`; route/controller code should access data through DAO contracts rather than embed SQL. Domain-specific persistence modules are `dao/productsDAO.js`, `dao/categoriesDAO.js`, and `dao/userDAO.js`, defining the principal boundaries for catalog, category filtering, and user identity data.

#### Catalog and search flow
Home and search routes obtain product/category data via the catalog DAOs, shape it for template consumption, and render:
- `routes/home.js` → `views/home/index.hbs`
- `routes/search.js` → `views/search/index.hbs`
- reusable product presentation → `views/partials/products.hbs`

This keeps SQL/data access separate from page assembly, while category and product images remain public static content under `public/img/products` and `public/img/icons/category`.

#### Cart, user, and session-facing flow
The checkout/cart route is isolated at `routes/checkout/cart.js` with page output in `views/checkout/cart.hbs`. Authentication endpoints are split by action rather than consolidated in one controller, with corresponding forms at `views/sign/in.hbs` and `views/sign/up.hbs`. The route layout indicates stateful user/cart behavior is handled at the web-server boundary; no separate API, payment provider, queue, or frontend SPA is present in the repository.

#### Presentation and client boundary
Server-rendered pages share `views/partials/header.hbs` and `views/partials/footer.hbs`. Browser-side behavior is intentionally small and asset-based: `public/js/slider.js` and `public/js/rating.js`; styling and imagery live under `public/css` and `public/img`. Express serves these files directly, while templates own page structure and dynamic catalog/account/cart content.

Main entry points: [`index.js`](https://github.com/rafaelgoulartb/nodejs-ecommerce/blob/master/index.js) (Express bootstrap), [`views/home/index.hbs`](https://github.com/rafaelgoulartb/nodejs-ecommerce/blob/master/views/home/index.hbs) (Catalog pages), [`config/custom-express.js`](https://github.com/rafaelgoulartb/nodejs-ecommerce/blob/master/config/custom-express.js) (Express configuration), [`routes/home.js`](https://github.com/rafaelgoulartb/nodejs-ecommerce/blob/master/routes/home.js) (Home discovery)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Runtime"]
  node_bootstrap["Express bootstrap<br/>Node.js entry<br/>[index.js]"]
  node_express_config["Express configuration<br/>framework setup<br/>[custom-express.js]"]
  node_procfile["Heroku process<br/>deployment entry"]
end

subgraph group_routes["Routes"]
  node_home_route["Home discovery<br/>route controller<br/>[home.js]"]
  node_search_route["Search and filtering<br/>route controller<br/>[search.js]"]
  node_cart_route["Cart checkout<br/>route controller<br/>[cart.js]"]
  node_account_routes["Account actions<br/>route controllers"]
end

subgraph group_persistence["Persistence"]
  node_connection_factory["DB connection factory<br/>DAO infrastructure"]
  node_catalog_daos["Catalog DAOs<br/>persistence contracts"]
  node_user_dao["User DAO<br/>persistence contract<br/>[userDAO.js]"]
  node_mysql[("MySQL<br/>system of record<br/>[equantom.sql]")]
end

subgraph group_presentation["Server-rendered UI"]
  node_handlebars["Handlebars rendering<br/>view engine"]
  node_shared_shell["Shared shell and partials<br/>layout components<br/>[layout.hbs]"]
  node_catalog_views["Catalog pages<br/>Handlebars views<br/>[index.hbs]"]
  node_account_views["Account forms<br/>Handlebars views<br/>[in.hbs]"]
  node_cart_view["Cart page<br/>Handlebars view<br/>[cart.hbs]"]
  node_error_views["Error pages<br/>Handlebars views<br/>[404.hbs]"]
  node_static_assets["Static browser assets<br/>public assets"]
end

node_procfile -->|"starts"| node_bootstrap
node_bootstrap -->|"initializes"| node_express_config
node_bootstrap -->|"mounts"| node_home_route
node_bootstrap -->|"mounts"| node_search_route
node_bootstrap -->|"mounts"| node_cart_route
node_bootstrap -->|"mounts"| node_account_routes
node_bootstrap -->|"serves"| node_static_assets
node_express_config -->|"configures"| node_handlebars
node_express_config -->|"renders errors"| node_error_views
node_home_route -->|"queries"| node_catalog_daos
node_search_route -->|"queries"| node_catalog_daos
node_account_routes -->|"uses"| node_user_dao
node_catalog_daos -->|"connects through"| node_connection_factory
node_user_dao -->|"connects through"| node_connection_factory
node_connection_factory -->|"connects"| node_mysql
node_home_route -->|"renders"| node_catalog_views
node_search_route -->|"renders"| node_catalog_views
node_cart_route -->|"renders"| node_cart_view
node_account_routes -->|"renders"| node_account_views
node_handlebars -->|"uses"| node_shared_shell
node_handlebars -->|"renders"| node_catalog_views
node_handlebars -->|"renders"| node_account_views
node_handlebars -->|"renders"| node_cart_view
node_catalog_views -.->|"references"| node_static_assets

click node_bootstrap "https://github.com/rafaelgoulartb/nodejs-ecommerce/blob/master/index.js"
click node_express_config "https://github.com/rafaelgoulartb/nodejs-ecommerce/blob/master/config/custom-express.js"
click node_procfile "https://github.com/rafaelgoulartb/nodejs-ecommerce/blob/master/Procfile"
click node_home_route "https://github.com/rafaelgoulartb/nodejs-ecommerce/blob/master/routes/home.js"
click node_search_route "https://github.com/rafaelgoulartb/nodejs-ecommerce/blob/master/routes/search.js"
click node_cart_route "https://github.com/rafaelgoulartb/nodejs-ecommerce/blob/master/routes/checkout/cart.js"
click node_connection_factory "https://github.com/rafaelgoulartb/nodejs-ecommerce/blob/master/dao/connectionFactory.js"
click node_user_dao "https://github.com/rafaelgoulartb/nodejs-ecommerce/blob/master/dao/userDAO.js"
click node_mysql "https://github.com/rafaelgoulartb/nodejs-ecommerce/blob/master/equantom.sql"
click node_shared_shell "https://github.com/rafaelgoulartb/nodejs-ecommerce/blob/master/views/layouts/layout.hbs"
click node_catalog_views "https://github.com/rafaelgoulartb/nodejs-ecommerce/blob/master/views/home/index.hbs"
click node_account_views "https://github.com/rafaelgoulartb/nodejs-ecommerce/blob/master/views/sign/in.hbs"
click node_cart_view "https://github.com/rafaelgoulartb/nodejs-ecommerce/blob/master/views/checkout/cart.hbs"
click node_error_views "https://github.com/rafaelgoulartb/nodejs-ecommerce/blob/master/views/errors/404.hbs"
click node_static_assets "https://github.com/rafaelgoulartb/nodejs-ecommerce/tree/master/public/css"

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_express_config,node_procfile toneBlue
class node_home_route,node_search_route,node_cart_route,node_account_routes toneAmber
class node_connection_factory,node_catalog_daos,node_user_dao,node_mysql toneMint
class node_handlebars,node_shared_shell,node_catalog_views,node_account_views,node_cart_view,node_error_views,node_static_assets toneRose
```

## Components

### Runtime

- [Express bootstrap](https://github.com/rafaelgoulartb/nodejs-ecommerce/blob/master/index.js): Node.js entry · Composes Express, static assets, and route modules. · `index.js`
- [Express configuration](https://github.com/rafaelgoulartb/nodejs-ecommerce/blob/master/config/custom-express.js): framework setup · Configures Handlebars, shared middleware, and errors. · `config/custom-express.js`
- [Heroku process](https://github.com/rafaelgoulartb/nodejs-ecommerce/blob/master/Procfile): deployment entry · `Procfile`

### Routes

- [Home discovery](https://github.com/rafaelgoulartb/nodejs-ecommerce/blob/master/routes/home.js): route controller · `routes/home.js`
- [Search and filtering](https://github.com/rafaelgoulartb/nodejs-ecommerce/blob/master/routes/search.js): route controller · `routes/search.js`
- [Cart checkout](https://github.com/rafaelgoulartb/nodejs-ecommerce/blob/master/routes/checkout/cart.js): route controller · `routes/checkout/cart.js`
- **Account actions**: route controllers · Separate sign-in, sign-up, and logout endpoints.

### Persistence

- [DB connection factory](https://github.com/rafaelgoulartb/nodejs-ecommerce/blob/master/dao/connectionFactory.js): DAO infrastructure · `dao/connectionFactory.js`
- **Catalog DAOs**: persistence contracts · Product and category data access.
- [User DAO](https://github.com/rafaelgoulartb/nodejs-ecommerce/blob/master/dao/userDAO.js): persistence contract · `dao/userDAO.js`
- [MySQL](https://github.com/rafaelgoulartb/nodejs-ecommerce/blob/master/equantom.sql): system of record · Schema and seed material is provided by equantom.sql. · `equantom.sql`

### Server-rendered UI

- **Handlebars rendering**: view engine · Resolves views and applies the shared layout.
- [Shared shell and partials](https://github.com/rafaelgoulartb/nodejs-ecommerce/blob/master/views/layouts/layout.hbs): layout components · Layout, header, footer, and reusable product presentation. · `views/layouts/layout.hbs`
- [Catalog pages](https://github.com/rafaelgoulartb/nodejs-ecommerce/blob/master/views/home/index.hbs): Handlebars views · Home and search pages render catalog results. · `views/home/index.hbs`
- [Account forms](https://github.com/rafaelgoulartb/nodejs-ecommerce/blob/master/views/sign/in.hbs): Handlebars views · `views/sign/in.hbs`
- [Cart page](https://github.com/rafaelgoulartb/nodejs-ecommerce/blob/master/views/checkout/cart.hbs): Handlebars view · `views/checkout/cart.hbs`
- [Error pages](https://github.com/rafaelgoulartb/nodejs-ecommerce/blob/master/views/errors/404.hbs): Handlebars views · Dedicated 404 and 500 presentation. · `views/errors/404.hbs`
- [Static browser assets](https://github.com/rafaelgoulartb/nodejs-ecommerce/tree/master/public/css): public assets · Styles, product/category images, slider, and rating behavior. · `public/css`

## Connections

- Heroku process → Express bootstrap: starts
- Express bootstrap → Express configuration: initializes
- Express bootstrap → Home discovery: mounts
- Express bootstrap → Search and filtering: mounts
- Express bootstrap → Cart checkout: mounts
- Express bootstrap → Account actions: mounts
- Express bootstrap → Static browser assets: serves
- Express configuration → Handlebars rendering: configures
- Express configuration → Error pages: renders errors
- Home discovery → Catalog DAOs: queries
- Search and filtering → Catalog DAOs: queries
- Account actions → User DAO: uses
- Catalog DAOs → DB connection factory: connects through
- User DAO → DB connection factory: connects through
- DB connection factory → MySQL: connects
- Home discovery → Catalog pages: renders
- Search and filtering → Catalog pages: renders
- Cart checkout → Cart page: renders
- Account actions → Account forms: renders
- Handlebars rendering → Shared shell and partials: uses
- Handlebars rendering → Catalog pages: renders
- Handlebars rendering → Account forms: renders
- Handlebars rendering → Cart page: renders
- Catalog pages → Static browser assets: references
