How weihong931021/shopping-site works
Project type and purpose
• This is a full-stack e-commerce web application scaffolded with Vue 3 + Vite on the front end, and a Node.js/Express API server under the server/ directory.
• Purpose: allow users to browse products, add to cart, register/login, and complete checkout.
File structure
• Top level:
• index.html, vite.config.js, src/ → Vue 3 single-page application (SPA).
• public/ → static assets served by Vite or production web server.
• server/ → Node/Express backend.
• In src/:
• App.vue, main.js, router.js → SPA bootstrapping and client-side routing.
• components/ → reusable UI pieces (buttons, cards, navbar, dialogs).
• pages/ → page-level views (Home, Products, Cart, Checkout, Login, Register).
• In server/:
• server.js → Express app initialization, middleware, route mounting.
• routes/*.js → REST endpoints: auth, products, cart, checkout.
• config/database.js + .env → database connection settings.
Key insights from the README
• Confirms Vue 3 + Vite as front-end toolchain.
• Standard npm scripts: dev, build.
Main components
a. Client-side SPA
• Browser/mobile UI
• Vue router and components
• Assets (CSS, images)
b. API Server
• Express app
• Route handlers (auth, products, cart, checkout)
• Database connector
c. Database
• e.g. MySQL/PostgreSQL/MongoDB (as configured in database.js)
d. External services
• Payment gateway (invoked in checkout.js)
• Optional: Email service for order confirmations
Relationships and data flows
• User → Browser UI: interactions via Vue components and Vuex/router (if used).
• Browser → API server: REST calls to /api/auth, /api/products, /api/cart, /api/checkout.
• API server ↔ Database: queries/inserts for users, products, cart sessions, orders.
• API server → Payment gateway: tokenized payment request, response handling.
• Server → (optional) Email/SMS service: order confirmation.
Architectural patterns and design principles
• Client-server separation (clear API layer).
• Layered design in backend:
• HTTP layer (Express) → Business logic (route handlers) → Data access (database.js).
• Component-based UI in frontend.
• Environment-driven configuration (.env).