How andresbaquiax/ecommerce-front works
Project Type and Purpose
• This is a single‐page application (SPA) frontend for an enterprise ecommerce system. It’s built with React 18 and Vite, and designed to be hosted as static assets (e.g., on Vercel or a CDN). It communicates with backend APIs (auth, inventory, orders, invoices, reports, etc.) and a PostgreSQL database.
File Structure
• Top‐level artifacts:
• src/ – Application source code subdivided into:
– _mock: dummy data for local development.
– app.tsx & main.tsx: app bootstrap, router, theme provider.
– layouts/: page shell implementations (auth vs dashboard) and header/nav pieces.
– pages/: route views and route titles.
– sections/: composition of components into views (cart, blog, checkout, overview, products, users, etc.).
– services/: HTTP client and per‐resource API wrappers (authService, usuarios, inventario, pedidos, reportes, etc.).
– context/ & hooks/: global state management (AuthContext, CartContext) and custom hooks (useAuth, useRole).
– theme/: design system (palette, typography, shadows) and theme provider.
– utils/: generic helpers (format-number, format-time).
• Config/build files: vite.config.ts, tsconfig.json, eslint.config.mjs, prettier.config.mjs, vercel.json.
README
• Confirms React+Vite SPA.
• Lists features (inventory, roles, dashboard, analytics, PostgreSQL backend).
• No backend code here—frontend calls external APIs.
• Mentions HMR, ESLint, build & preview scripts.
Main Components
a. Client Browser (User Agent)
b. Static File Host (e.g., Vercel/CDN)
c. React Application (SPA)
• UI Layer: layouts, pages, sections, components
• State Layer: Context Providers (AuthContext, CartContext)
• Service Layer: HTTP client (src/services/http.ts) + API modules
• Theme Layer: theme-provider, design system
• Utility Layer: hooks, utils
d. External Backend APIs (Auth API, Inventory API, Orders API, Reports API, Users API)
e. Database (PostgreSQL) behind the APIs
f. (Optionally) CI/CD Pipeline (GitHub → Vercel)
Relationships & Interactions
• Browser requests index.html from Static File Host → downloads JS/CSS bundle
• React SPA bootstraps: ThemeProvider → Router → ContextProviders
• User interacts with UI → triggers component event → calls service (e.g., authService.login)
• service → http.ts → HTTP request to External Backend API
• Backend API → Business logic → PostgreSQL
• Response flows back through http.ts → service module → updates Context or component state → UI re‐renders
Architectural Patterns & Principles
• Component-based UI (atomic & composite components)
• Separation of concerns:
• Presentation (components, sections, pages)
• State (Context + Hooks)
• Data access (services + http client)
• Theming (theme directory)
• Declarative routing (React Router via src/routes)
• Mock data injection for dev/test (_mock)
• Standards: ESLint, Prettier, HMR