# estebanjgg/projecto-final-toti-voke architecture

> Architecture diagram of the GitHub repository estebanjgg/projecto-final-toti-voke, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-08-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/estebanjgg/projecto-final-toti-voke
- Repository: https://github.com/estebanjgg/projecto-final-toti-voke

## Overview

##### 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

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Tier
    subgraph "Presentation Tier" 
        direction TB
        Browser["User's Browser"]:::frontend
        CDN["Vercel CDN & Edge"]:::cloud
        Browser -->|"GET /"| CDN
        CDN -->|"Serves index.html"| IndexHTML
        IndexHTML["index.html"]:::frontend
        click IndexHTML "https://github.com/estebanjgg/projecto-final-toti-voke/blob/main//index.html"
        CDN -->|"Serves Bundles"| MainJS
        MainJS["main.jsx"]:::frontend
        click MainJS "https://github.com/estebanjgg/projecto-final-toti-voke/blob/main/src/main.jsx"
        MainJS -->|"Renders"| AppComponent
        AppComponent["App.jsx"]:::frontend
        click AppComponent "https://github.com/estebanjgg/projecto-final-toti-voke/blob/main/src/App.jsx"
    end

    %% Application Tier
    subgraph "Application Tier" 
        direction TB
        subgraph "UI Layer" 
            direction TB
            Home["Home.jsx"]:::frontend
            click Home "https://github.com/estebanjgg/projecto-final-toti-voke/blob/main/src/components/Home.jsx"
            Banner["Banner.jsx"]:::frontend
            click Banner "https://github.com/estebanjgg/projecto-final-toti-voke/blob/main/src/components/Banner.jsx"
            BestOffers["BestOffers.jsx"]:::frontend
            click BestOffers "https://github.com/estebanjgg/projecto-final-toti-voke/blob/main/src/components/BestOffers.jsx"
            ProductCard["ProductCard.jsx"]:::frontend
            click ProductCard "https://github.com/estebanjgg/projecto-final-toti-voke/blob/main/src/components/ProductCard.jsx"
            Checkout["Checkout.jsx"]:::frontend
            click Checkout "https://github.com/estebanjgg/projecto-final-toti-voke/blob/main/src/components/checkout/Checkout.jsx"
            AdminDashboard["AdminDashboard.jsx"]:::frontend
            click AdminDashboard "https://github.com/estebanjgg/projecto-final-toti-voke/blob/main/src/components/admin/AdminDashboard.jsx"
        end

        subgraph "State Management (Contexts)"
            direction TB
            AuthContext["AuthContext.jsx"]:::frontend
            click AuthContext "https://github.com/estebanjgg/projecto-final-toti-voke/blob/main/src/contexts/AuthContext.jsx"
            CartContext["CartContext.jsx"]:::frontend
            click CartContext "https://github.com/estebanjgg/projecto-final-toti-voke/blob/main/src/contexts/CartContext.jsx"
            FavoritesContext["FavoritesContext.jsx"]:::frontend
            click FavoritesContext "https://github.com/estebanjgg/projecto-final-toti-voke/blob/main/src/contexts/FavoritesContext.jsx"
            AlertContext["AlertContext.jsx"]:::frontend
            click AlertContext "https://github.com/estebanjgg/projecto-final-toti-voke/blob/main/src/contexts/AlertContext.jsx"
        end

        subgraph "Service Layer (API Modules)"
            direction TB
            APIConfig["api-config.js"]:::service
            click APIConfig "https://github.com/estebanjgg/projecto-final-toti-voke/blob/main/src/config/api-config.js"
            AuthAPI["authAPI.js"]:::service
            click AuthAPI "https://github.com/estebanjgg/projecto-final-toti-voke/blob/main/src/services/authAPI.js"
            ProductsAPI["categoriesAPI.js"]:::service
            click ProductsAPI "https://github.com/estebanjgg/projecto-final-toti-voke/blob/main/src/services/categoriesAPI.js"
            CartAPI["cartAPI.js"]:::service
            click CartAPI "https://github.com/estebanjgg/projecto-final-toti-voke/blob/main/src/services/cartAPI.js"
            OrdersAPI["ordersAPI.js"]:::service
            click OrdersAPI "https://github.com/estebanjgg/projecto-final-toti-voke/blob/main/src/services/ordersAPI.js"
            PaymentsAPI["paymentsAPI.js"]:::service
            click PaymentsAPI "https://github.com/estebanjgg/projecto-final-toti-voke/blob/main/src/services/paymentsAPI.js"
            AdminAPI["adminAPI.js"]:::service
            click AdminAPI "https://github.com/estebanjgg/projecto-final-toti-voke/blob/main/src/services/adminAPI.js"
        end

        subgraph "Utilities & Hooks"
            direction TB
            UseAlert["useAlert.js"]:::frontend
            click UseAlert "https://github.com/estebanjgg/projecto-final-toti-voke/blob/main/src/hooks/useAlert.js"
        end

        %% Relationships within Application Tier
        AppComponent -->|uses| Home
        AppComponent -->|wraps| AuthContext
        AuthContext -->|provides| Home
        CartContext -->|provides| Checkout
        FavoritesContext -->|provides| Home
        AlertContext -->|provides| Alerts
        Home -->|calls| ProductsAPI
        Checkout -->|calls| CartAPI
        Checkout -->|calls| PaymentsAPI
        AdminDashboard -->|calls| AdminAPI
    end

    %% Data Tier
    subgraph "Data Tier"
        direction TB
        HerokuAPI["Heroku REST API"]:::cloud
        Database["External Database"]:::database
        PaymentGateway["Payment Processor"]:::cloud
        HerokuAPI -->|reads/writes| Database
        PaymentsAPI -->|POST /payments| PaymentGateway
    end

    %% Cross-tier Flows
    ServiceLayer["Service Layer"]:::service
    ProductsAPI -->|HTTP| HerokuAPI
    AuthAPI -->|HTTP| HerokuAPI
    CartAPI -->|HTTP| HerokuAPI
    OrdersAPI -->|HTTP| HerokuAPI
    AdminAPI -->|HTTP| HerokuAPI

    %% click events for config and deployment
    click APIConfig "https://github.com/estebanjgg/projecto-final-toti-voke/blob/main/src/config/api-config.js"
    click UseAlert "https://github.com/estebanjgg/projecto-final-toti-voke/blob/main/src/hooks/useAlert.js"

    %% Styles
    classDef frontend fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef service fill:#90EE90,stroke:#333,stroke-width:1px
    classDef database fill:#FFA500,stroke:#333,stroke-width:1px
    classDef cloud fill:#F0E68C,stroke:#333,stroke-width:1px
```
