How estebanjgg/projecto-final-toti-voke works
Project Type and Purpose
• This is the frontend of a modern e-commerce web application built with React 19 and Vite, deployed to Vercel.
• It consumes a RESTful API hosted on Heroku and implements features like product catalogs, filters, checkout, authentication, user profiles, and an admin dashboard.
File Structure
• Top-level:
• index.html, public/ → static entry point and assets (logos, propaganda images).
• src/ → all React code.
• components/ → UI split by domain (home, products, auth, checkout, orders, admin, debug, ui).
• services/ → modules wrapping HTTP calls to backend API endpoints (authAPI, cartAPI, ordersAPI, paymentsAPI, etc.).
• contexts/ → React Context providers for global state (Auth, Cart, Favorites, Alerts).
• hooks/ → custom hooks (e.g., useAlert).
• config/api-config.js → base URLs and headers.
• Build & deployment: vite.config.js, vercel.json, eslint.config.js.
• Patterns:
• Component-Driven UI, Context for state management, Service layer for API interactions.
• Separation between UI, state, and data-access layers.
README for Additional Insights
• Framework: Vite for lightning-fast rebuilds.
• Deployment: automatic via Vercel on GitHub pushes.
• API host: https://tu-app-voke-backend…herokuapp.com/api (no env vars).
• Key features: real-time search, category navigation, responsive/mobile-first design.
Main Components & Their Relationships
a. User’s Browser
• Hosts the React SPA served via Vercel’s CDN.
• Interacts with React components and triggers API calls.
b. Vercel Hosting (CDN + Edge)
• Serves index.html, JS bundles, CSS, static assets.
c. React App
• UI Layer: components under src/components/….
• State Layer: contexts under src/contexts/….
• Data Layer: services under src/services/….
• Routing: React Router (implied in components like ProtectedRoute.jsx).
d. Backend API (Heroku)
• Exposes REST endpoints for auth, products, categories, cart, orders, payments.
• May integrate with database, payment gateway (Stripe, PayPal), and email/SMS providers.
e. External Services
• Payment Processor: via paymentsAPI.js.
• Third-party analytics/CDN (if any).
f. Admin Dashboard
• A subset of React components under components/admin, calling admin-specific API endpoints.
Data & control flow:
1. User → Browser → React UI → Service layer → API host
2. API responses → Service layer → Contexts → UI re-render
3. Checkout → Payment API → Confirmation page → OrderSummary component
Architectural Patterns & Design Principles
• Separation of Concerns: UI vs. state vs. API layers.
• Component Reuse: shared UI elements in components/ui.
• Context API: for global, cross-component state (cart, auth, favorites).
• Single Page Application: client-side routing, code-splitting via Vite.
• Service Abstraction: one file per API domain to encapsulate HTTP details.
Essential Elements to Capture
• Static asset delivery (public folder → CDN)
• React SPA runtime (main.jsx → App.jsx → nested components)
• Context providers wrapping the component tree
• Service layer calling https://…herokuapp.com/api
• Payment gateway interaction
• User roles (guest, authenticated user, admin) and corresponding UI paths