How gcvishwas/e-commerce-book-store works
Project Type and Purpose
• This is a full-stack e-commerce Book Store.
• Frontend: React + Redux + Firebase, served as a static SPA (deployed on Vercel).
• Backend: Node.js + Express + TypeScript with JWT auth, deployed as a serverless or Node service (Vercel).
• Database: MongoDB (hosted on Atlas or self‐managed).
• External services: Firebase (analytics, notifications), potentially email/SMS services.
Main Components
a. Frontend SPA
• React app (components, pages)
• Redux store (features: books, cart, orders)
• React-Router (public vs. private vs. admin routes)
• Firebase integration (config, analytics/auth backup)
b. API Gateway / Server
• Express server (index.ts)
• Middleware (JWT validation, verifyAdmin)
• Routes layer (/routes)
• Controllers (/controllers: user, book, order)
• Business modules (/modules: user_data, book_store, orders_data)
• DB utils (/utils/db.ts)
c. Database
• MongoDB collections: users, books, orders
d. External Services
• Firebase (analytics, notifications)
• Vercel (hosting for both frontend & backend)
• (Optionally) Email/SMS provider
Relationships & Data Flows
• User’s Browser → (HTTPS) → Frontend (static assets)
• Frontend → (HTTPS, JSON) → Backend API endpoints
• Public endpoints: sign up, login, browse/search books
• Protected endpoints (JWT): cart management, place orders
• Admin endpoints (JWT + verifyAdmin): add/edit/delete books & users
• Backend → MongoDB
• Controllers invoke modules → DB utils execute CRUD
• Frontend → Firebase
• Analytics events, optional notifications
• Deployment platform (Vercel) hosts both front and back
Architectural Patterns & Design Principles
• Backend follows a layered MVC-style pattern:
Routes → Controllers → Domain Modules → DB Utils
• Stateless JWT authentication, middleware for access control
• Frontend uses unidirectional data flow (Redux) + Context for auth state
• Component decomposition: layout, pages, reusable components
• Separation of concerns: UI vs. state vs. side effects (API calls)