A vanilla JS e‑commerce Single Page App focused on IoT devices (smart home), built with HTML5, CSS3, and ES modules, plus a lightweight Node.js + Express REST API for product, review, and order management.
-
With Docker Compose (recommended):
- Optional: copy
.env.exampleto.envto override defaults used by Compose. docker compose up --build- App (SPA): http://localhost
- API (proxied): http://localhost/api
- MySQL: localhost:3306 (see Compose env in
docker-compose.ymlor.env)
- Optional: copy
-
Without Docker:
- Requirements: Node.js 18+ and a running MySQL 8+ instance.
- Provide env vars:
DB_HOST,DB_USER,DB_PASSWORD,DB_NAME(and optionallyDB_PORT). - Run
npm run db:migratethennpm run db:seed. - Start API + static app:
npm run dev→ http://localhost:4000 (API served at/api)
- SPA with hash routes:
#/,#/catalog,#/product/:id,#/cart,#/checkout,#/profile,#/admin,#/about. - IoT catalog with server-side search, category/rating filters, sort, and pagination.
- Product details: gallery, rating, wishlist, quick add, category/tag badges.
- Orders: secure checkout, user-associated orders, admin order listing.
- Admin: product CRUD, import/export, custom categories.
- Auth: register/login (JWT), admin-only endpoints and UI.
- Theming: light/dark with toggle and persistence.
- Nginx reverse proxy with static caching.
- Categories: lighting, sensors, security, power/energy, hubs, climate, cleaning, garden, air.
- Protocols: mixed catalog featuring Matter, Wi‑Fi, Zigbee, Thread/Z‑Wave (as metadata/tags).
- Use-cases: automation, energy monitoring, safety (smoke/leak), access (locks), cameras/doorbells.
SAVE10: 10% off subtotalFREESHIP: free shippingWELCOME5: €5 off orders ≥ €30
- In
#/adminunder Products tab, use Export JSON to download current merged catalog; Import JSON to overlay products from a file shaped as{ "products": [...] }.
index.html: App shell, mounts header/main/footer and JS entryjs/app.js.assets/: Icons and placeholder images.styles/: Base, layout, components, and themes CSS.js/: ES modules for router, store, API, utils, components, and pages.server/api.mjs: Express server exposing REST endpoints.
- Base URL:
- Without Docker:
http://localhost:4000 - With Docker:
http://localhost/api
- Without Docker:
- Endpoints:
GET /api/healthGET /api/products,GET /api/products/:id,POST /api/products,PUT /api/products/:id,DELETE /api/products/:idGET /api/products-export,POST /api/products-import(admin import/export)GET /api/products/:id/reviews,POST /api/products/:id/reviewsGET /api/orders(admin),GET /api/my-orders(user),POST /api/orders
- Storage: MySQL for users, products, reviews, orders, and custom categories. Seeded via scripts.
- Auth: JWT tokens for sessions; admin routes require admin token.
POST /api/auth/registerbody{ name, email, password, adminKey? }→{ token, user }.POST /api/auth/loginbody{ email, password }→{ token, user }.GET /api/auth/mewith headerAuthorization: Bearer <token>→{ user }.- Admin-only routes require the token of a user with
isAdmin: true.
- Database migrations live in
server/migrations/and are executed bynpm run db:migrate. The API also auto-runs migrations on start.
PORT: API port (default 4000)JWT_SECRET: secret for signing tokens (defaultdevsecret-change-me).ADMIN_KEY: admin registration key to grant admin role (defaultNOVA-ADMIN).DB_HOST(defaultmysqlin Docker),DB_PORT(3306)DB_USER,DB_PASSWORD,DB_NAME
Docker Compose reads variables from .env in the project root. For local (non-Docker) runs, export variables in your shell before invoking scripts.
Seeder variables (optional):
ADMIN_EMAIL(defaultadmin@example.com)ADMIN_PASSWORD(defaultadmin123)ADMIN_NAME(defaultAdmin)
- Images are placeholders located in
assets/images/. - Create additional admin:
npm run admin:create -- EMAIL PASSWORD NAME(or set envEMAIL,PASSWORD,NAME). - Seed demo orders:
npm run seed:demo-orders.
npm run mock:serve: Run a lightweight mock API + static server athttp://localhost:4000(no database required).npm run screenshots: Generate UI screenshots using Puppeteer (uses the mock by default).