How santibalbiani/dh_grupo_02_slc works
1. Repository shape
- This repo is centered on a two-part application:
- an Express-based store backend + server-rendered storefront under app/
- a separate React dashboard/admin UI under app/dashboard/
- The rest of the repository is mostly project documentation: DB scripts, wireframes, design diagrams, and sprint retrospectives.
2. Primary business domain
- The application is an e-commerce site for electronic components / IoT solutions.
- The core user journeys are: browsing product categories, searching products, viewing product details, registering/logging in, managing a cart, and completing purchases.
- There is also an administrative side for managing users, products, and sales metrics.
3. Server entrypoint and web layer
- The main server app lives in app/app.js with the startup script in app/bin/www.
- This is a classic Express + EJS structure: the server renders pages, serves static assets, and exposes JSON endpoints.
- Page routes are separated from API routes, which keeps the storefront and machine-readable endpoints distinct.
4. Route/controller split
- Domain routing is organized by feature:
- routes/products.js, routes/users.js, routes/transactions.js
- API routes in routes/apiProducts.js, routes/apiUsers.js, routes/apiSells.js
- Controllers mirror those domains:
- productsController.js, userController.js, transactionController.js
- searchBarController.js for search behavior
- apiProdsByCategory.js, apiUserController.js, apiSellsController.js for JSON responses
- mainController.js for shared/homepage behavior
- This indicates a feature-oriented backend, not a layered generic MVC split.
5. Persistence layer
- Data access is handled through Sequelize ORM under app/database/.
- The repo includes:
- config/config.js for DB connection settings
- migrations/ for schema evolution
- models/ for relational entities
- The model set suggests a commerce schema with:
- product, category
- masteruser / user-related models
- cart and transaction entities: aCart, acartitem, aTrx, atrxItem
- This points to a relational core with products, users, carts, and purchases as the main data flow.
6. Request processing and shared middleware
- Cross-cutting request behavior is centralized in middlewares/:
- user/session cookies
- locals injection for templates
- flash/messages handling
- access control for buying and editing users
- These middleware files act as the boundary between identity/session state and the page/API handlers.
7. Storefront presentation layer
- Server-rendered views live in app/views/ using EJS templates.
- Reusable fragments are in app/partials/ for layout elements like header, footer, nav, search bar, and error handling.
- Static frontend assets are in app/public/:
- CSS for product detail, cart, registration, and general layout
- client-side JS for validation, cart loading, local storage, and multi-step flows
- images for products and users
- This frontend is tightly coupled to the Express controllers and is the primary UX for shoppers.
8. User and commerce flows
- The structure shows distinct flows for:
- browsing/searching products
- product detail and add-to-cart
- checkout/transaction completion
- user registration, profile, and admin editing
- The presence of buyNotLogged middleware and cart/transaction models suggests the checkout flow enforces authentication or special purchase rules.
9. API surface
- The api/* routes expose backend data in JSON form, likely for:
- dashboard charts and indicators
- category/product listings
- user/sales metrics
- This separates internal data consumption from the HTML-rendering storefront and makes the backend usable by the dashboard SPA.
10. React dashboard subsystem
- app/dashboard/ is a standalone React app with its own package.json.
- It contains chart components such as:
- BarGraph, LineGraph, Indicators
- UI navigation components like NavBar
- src/config/API.js and datesHandler.js indicate the dashboard pulls remote data and formats it for reporting.
- This is the repository’s admin/analytics boundary, consuming backend APIs rather than rendering server-side pages.
11. Data and seed artifacts
- app/data/products.json and app/data/users.json appear to be seed/mock datasets or import sources.
- The Scripts/ folder contains DB creation and population documentation, reinforcing that database setup is part of the project workflow.
- These assets are support material for bootstrapping and demonstrating the schema, not runtime dependencies.
12. Project artifacts and legacy history
- DER/, Wireframes/, old/, and retrospectivas/ contain design diagrams, earlier HTML/EJS versions, and sprint retrospectives.
- These do not affect runtime architecture, but they help explain the evolution of the app and the intended UX.
13. High-level system boundary
- The repo overall represents a monolith with one backend and one separate frontend dashboard:
- Express/EJS storefront + JSON API + relational persistence
- React dashboard consuming those APIs
- The key architectural boundary is between server-rendered commerce pages and API-driven analytics/admin UI.
14. What to draw in an architecture diagram
- A good diagram should show:
- Browser shoppers talking to the Express app for HTML pages and cart/checkout actions
- The Express app talking to Sequelize-backed relational tables
- The React dashboard talking to the same backend via JSON APIs
- Shared middleware sitting in front of controllers
- Static assets and EJS partials as part of the storefront presentation layer
Main entry points: mainController.js Controllers · index.js Models · app.js Express app · App.js Dashboard app
Components 17
Storefront app
Express/EJS commerce experience for shoppers
- Express app · Bootstraps the storefront server and mounts web/API routes
app/app.js - WWW boot · Starts the HTTP server and wires the Express app
app/bin/www - Web routes · Feature routes for storefront pages and commerce actions
app/routes/index.js - Controllers · Page and domain controllers for products, users, search, and transactions
app/controllers/mainController.js - Middleware · Session, locals, flash, and access-control middleware
app/middlewares/localsMiddleware.js - EJS views · Server-rendered storefront screens and forms
app/views/index.ejs - Partials · Reusable layout fragments for head, nav, footer, search, and errors
app/partials/nav.ejs - Static assets · CSS and client-side JavaScript for storefront interactions
app/public/stylesheets/style.css
Backend API
JSON surface used by the dashboard and internal clients
- API routes · JSON endpoints for products, users, and sales
app/routes/apiProducts.js - API controllers · Controllers that shape data for API responses
app/controllers/apiUserController.js
Persistence
Sequelize models and database schema
- DB config · Connection settings for the relational database
app/database/config/config.js - Migrations · Database schema definition and versioned changes
app/database/migrations/20200210160609-create-user.js - Models · Relational entities for products, categories, users, carts, and transactions
app/database/models/index.js - Seed data · JSON datasets used for bootstrap or reference content
app/data/products.json
Admin dashboard
React reporting UI for metrics and management
- Dashboard app · Standalone React admin and analytics UI
app/dashboard/src/App.js - Dashboard UI · Graphs, indicators, and navigation for admin reporting
app/dashboard/src/components/BarGraph.js - Dashboard config · API configuration and date formatting for dashboard data
app/dashboard/src/config/API.js
Connections 18
- WWW boot → Express app: starts · HTTP bootstrap loads the Express application
- Express app → Middleware: uses · Requests pass through shared middleware first
- Express app → Web routes: mounts · Express mounts storefront page routes
- Express app → API routes: mounts · Express mounts JSON API routes
- Web routes → Controllers: delegates · Feature routes hand off to page/domain controllers
- API routes → API controllers: delegates · API routes hand off to JSON controllers
- Controllers → EJS views: renders · Controllers return EJS pages for shoppers
- Controllers → Partials: composes · Views reuse shared template fragments
- Controllers → Static assets: serves · Controllers and views rely on static CSS and client scripts
- Controllers → Models: reads/writes · Commerce flows persist and query relational data
- API controllers → Models: reads/writes · API responses are built from Sequelize models
- DB config → Models: configures · Database connection settings are consumed by the ORM layer
- Migrations → Models: shapes · Schema migrations define the tables the models map to
- Seed data → Models: seeds · Sample product and user data support the commerce domain
- Dashboard app → Dashboard UI: uses · React app composes charts and navigation components
- Dashboard app → Dashboard config: fetches · Dashboard config points to backend API endpoints
- Dashboard app → API routes: consumes · Analytics UI consumes the backend JSON surface
- Middleware → Controllers: guards · Session and access control wrap page and commerce handlers