How jgudo/ecommerce-react works
Main Components
• Frontend (React Application):
• Located in the “src” folder along with “public” assets.
• Contains views (pages for home, shop, product display, admin, checkout, authentication, error pages), components (both common UI elements and domain-specific elements like basket and product listings), and routing files (AdminRoute, ClientRoute, PublicRoute, etc.).
• Manages state using Redux (actions, reducers, sagas, store) and uses custom hooks and utilities.
• Backend (Firebase and Cloud Functions):
• Firebase configuration files such as firebase.json, .firebaserc, firestore.rules, database.rules.json indicate that Firebase is used for hosting, authentication, and database management.
• The “functions” directory contains Firebase Cloud Functions (index.js) that might be used for server-side business logic or processing webhooks.
• Database:
• Cloud Firestore is the primary database (referenced by firestore rules, indexes, and configuration in the README).
• External Services and Infrastructure:
• Firebase Authentication is in place to handle user sign up, login, and possibly role assignment (e.g., distinguishing ADMIN and USER roles).
• Deployment and CI/CD pipelines are available through GitHub Actions (see .github/workflows/main.yml) and Firebase Hosting.
Architecture Flow and Interactions
• The React frontend interacts directly with Firebase services through the “src/services/firebase.js” for authentication, Firestore CRUD operations, and potentially storage.
• Redux (with actions, reducers, sagas) acts as the business logic layer in the frontend, handling asynchronous calls to Firebase (via sagas such as authSaga, productSaga, etc.).
• Cloud Functions provide additional server-side operations when needed. They are triggered by events or called directly from the frontend.
• The e-commerce admin functionality is achieved by granting ADMIN privileges (manually toggled via Firestore user collection) and subsequently exposing additional CRUD operations.
Architectural Patterns and Principles
• Component-based Architecture: The application is separated into reusable components (organized in folders like components/basket, components/common, components/product, etc.) and pages (under views).
• Separation of Concerns: There is a clear distinction between the presentation layer (React views/components), the state management layer (Redux, sagas), and the backend services (Firebase Authentication, Firestore, and Cloud Functions).
• Routing & Access Control: With different route types (AdminRoute, ClientRoute, PublicRoute), the design captures different access levels within the app.