How rafaelgoulartb/nodejs-ecommerce works
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 Express bootstrap · index.hbs Catalog pages · custom-express.js Express configuration · home.js Home discovery
Components 18
Runtime
- Express bootstrap · Composes Express, static assets, and route modules.
index.js - Express configuration · Configures Handlebars, shared middleware, and errors.
config/custom-express.js - Heroku process
Procfile
Routes
- Home discovery
routes/home.js - Search and filtering
routes/search.js - Cart checkout
routes/checkout/cart.js - Account actions · Separate sign-in, sign-up, and logout endpoints.
Persistence
- DB connection factory
dao/connectionFactory.js - Catalog DAOs · Product and category data access.
- User DAO
dao/userDAO.js - MySQL · Schema and seed material is provided by equantom.sql.
equantom.sql
Server-rendered UI
- Handlebars rendering · Resolves views and applies the shared layout.
- Shared shell and partials · Layout, header, footer, and reusable product presentation.
views/layouts/layout.hbs - Catalog pages · Home and search pages render catalog results.
views/home/index.hbs - Account forms
views/sign/in.hbs - Cart page
views/checkout/cart.hbs - Error pages · Dedicated 404 and 500 presentation.
views/errors/404.hbs - Static browser assets · Styles, product/category images, slider, and rating behavior.
public/css
Connections 24
- 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