# juansanchez40/prueba_tecnica_frontend architecture

> Architecture diagram of the GitHub repository juansanchez40/prueba_tecnica_frontend, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-06-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/juansanchez40/prueba_tecnica_frontend
- Repository: https://github.com/juansanchez40/prueba_tecnica_frontend

## Overview

##### Project type and purpose
- This is a full-stack single-page application built with React (Vite), Redux, Tailwind/PostCSS, and hosted via Firebase.
- It uses a JSON-server (db.json) as a mock REST API and Firebase for user authentication (email/password + Google).

##### File structure
- Top level:
- index.html, package.json, vite.config.js → build and serve the React app
- db.json + json-server script → mock REST API
- firebaseConfig.js, firebase.js → Firebase initialization
- src/:
- src/main.jsx, src/App.jsx → SPA entry point
- src/components/… → reusable UI components (Encabezado, Carrito, TarjetaProducto, Toast)
- src/pages/… → route-level views (Home, Tienda, ProductDetail, Formulario)
- src/routes/… → React Router v6 setup (constRoutes, routes.jsx)
- src/redux/… & src/store/… → Redux action slices + global store
- src/assets/images → static assets
- Config files: .env.local for secrets, tailwind.config.js, postcss.config.js, eslint.config.js

##### README for additional insights
- Startup flow:
- “npm install” → installs dependencies
- “npx json-server…” → starts mock API at port 3001
- “npm run dev” → starts Vite dev server (http://localhost:5173)
- Authentication: only logged-in users can access “Tienda”
- Deploy target: Firebase Hosting

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Dev Environment
    subgraph "Dev Environment"
        direction TB
        Browser["Browser"]:::client
        Vite["Vite Dev Server"]:::client
        ReactApp["React Application"]:::client
        Browser -->|"loads via HTTP"| Vite
        Vite -->|"serves JS/CSS"| ReactApp

        subgraph "UI Layer"
            direction TB
            MainEntry["src/main.jsx"]:::client
            AppRoot["src/App.jsx"]:::client
            MainEntry --> AppRoot
            AppRoot --> Components
        end

        subgraph "Components & Pages"
            direction TB
            Encabezado["Encabezado"]:::client
            Carrito["Carrito"]:::client
            TarjetaProducto["TarjetaProducto"]:::client
            Toast["Toast Notifications"]:::client
            SlideMenu["Slide Menu"]:::client
            HomePage["Home Page"]:::client
            TiendaPage["Store Page"]:::client
            DetailPage["Product Detail Page"]:::client
            FormPage["Form Page"]:::client

            Encabezado --> ReactApp
            Carrito --> ReactApp
            TarjetaProducto --> ReactApp
            Toast --> ReactApp
            SlideMenu --> ReactApp
            HomePage --> ReactApp
            TiendaPage --> ReactApp
            DetailPage --> ReactApp
            FormPage --> ReactApp
        end

        subgraph "Routing Layer"
            direction TB
            RoutesConst["constRoutes.js"]:::client
            RoutesConfig["routes.jsx"]:::client
            RoutesConst --> RoutesConfig
            RoutesConfig --> ReactApp
        end

        subgraph "State Management"
            direction TB
            StoreConfig["store/store.js"]:::client
            CombinedReducer["reducer.js"]:::client
            AuthSlice["authSlice.js"]:::client
            CartSlice["carritoSlice.js"]:::client
            ProdActions["actionProductos.js"]:::client
            ProdReducer["reducerProductos.js"]:::client
            FormActions["actionFormulario.js"]:::client
            FormReducer["reducerFormulario.js"]:::client

            StoreConfig --> CombinedReducer
            CombinedReducer --> AuthSlice
            CombinedReducer --> CartSlice
            CombinedReducer --> ProdReducer
            CombinedReducer --> FormReducer
            ProdActions --> ProdReducer
            FormActions --> FormReducer
            ReactApp -->|"dispatch/select"| StoreConfig
        end

        ReactApp -->|"navigates"| RoutesConfig
    end

    %% Data Access Layer
    subgraph "Data Access Layer"
        direction TB
        JSONServer["json-server API"]:::backend
        FirebaseAuth["Firebase Auth Service"]:::external
        ReactApp -->|"HTTP GET/POST"| JSONServer
        ReactApp -->|"signIn / OAuth"| FirebaseAuth
        JSONServer -->|"reads/writes"| DBjson
    end

    %% Persistence Layer
    subgraph "Persistence / Services"
        direction TB
        DBjson["db.json"]:::backend
        FirebaseConfig["firebaseConfig.js"]:::external
        FirebaseInit["firebase.js"]:::external
        JSONServer --> DBjson
        FirebaseAuth --> FirebaseInit
        FirebaseInit --> FirebaseConfig
    end

    %% Prod Environment
    subgraph "Prod Environment"
        direction TB
        Hosting["Firebase Hosting"]:::external
        Hosting --> ReactApp
    end

    %% Click Events
    click MainEntry "https://github.com/juansanchez40/prueba_tecnica_frontend/blob/master/src/main.jsx"
    click AppRoot "https://github.com/juansanchez40/prueba_tecnica_frontend/blob/master/src/App.jsx"
    click Encabezado "https://github.com/juansanchez40/prueba_tecnica_frontend/blob/master/src/components/Encabezado/Encabezado.jsx"
    click Carrito "https://github.com/juansanchez40/prueba_tecnica_frontend/blob/master/src/components/Carrito/Carrito.jsx"
    click TarjetaProducto "https://github.com/juansanchez40/prueba_tecnica_frontend/blob/master/src/components/TarjetaProducto/TarjetaProducto.jsx"
    click Toast "https://github.com/juansanchez40/prueba_tecnica_frontend/blob/master/src/components/Toast.js"
    click SlideMenu "https://github.com/juansanchez40/prueba_tecnica_frontend/blob/master/src/components/SlideMenu.jsx"
    click HomePage "https://github.com/juansanchez40/prueba_tecnica_frontend/blob/master/src/pages/Home.jsx"
    click TiendaPage "https://github.com/juansanchez40/prueba_tecnica_frontend/blob/master/src/pages/Tienda.jsx"
    click DetailPage "https://github.com/juansanchez40/prueba_tecnica_frontend/blob/master/src/pages/ProductDetail.jsx"
    click FormPage "https://github.com/juansanchez40/prueba_tecnica_frontend/blob/master/src/pages/Formulario.jsx"
    click RoutesConst "https://github.com/juansanchez40/prueba_tecnica_frontend/blob/master/src/routes/constRoutes.js"
    click RoutesConfig "https://github.com/juansanchez40/prueba_tecnica_frontend/blob/master/src/routes/routes.jsx"
    click StoreConfig "https://github.com/juansanchez40/prueba_tecnica_frontend/blob/master/src/store/store.js"
    click CartSlice "https://github.com/juansanchez40/prueba_tecnica_frontend/blob/master/src/store/carritoSlice.js"
    click AuthSlice "https://github.com/juansanchez40/prueba_tecnica_frontend/blob/master/src/redux/authSlice.js"
    click ProdActions "https://github.com/juansanchez40/prueba_tecnica_frontend/blob/master/src/redux/actions/actionProductos/actionProductos.js"
    click ProdReducer "https://github.com/juansanchez40/prueba_tecnica_frontend/blob/master/src/redux/actions/actionProductos/reducerProductos.js"
    click FormActions "https://github.com/juansanchez40/prueba_tecnica_frontend/blob/master/src/redux/actions/actionFormulario/actionFormulario.js"
    click FormReducer "https://github.com/juansanchez40/prueba_tecnica_frontend/blob/master/src/redux/actions/actionFormulario/reducerFormulario.js"
    click CombinedReducer "https://github.com/juansanchez40/prueba_tecnica_frontend/blob/master/src/redux/reducer.js"
    click DBjson "https://github.com/juansanchez40/prueba_tecnica_frontend/blob/master/db.json"
    click FirebaseConfig "https://github.com/juansanchez40/prueba_tecnica_frontend/blob/master/src/firebaseConfig.js"
    click FirebaseInit "https://github.com/juansanchez40/prueba_tecnica_frontend/blob/master/src/firebase.js"

    %% Styles
    classDef client fill:#AEDFF7,stroke:#333,stroke-width:1px
    classDef backend fill:#C2F0C2,stroke:#333,stroke-width:1px
    classDef external fill:#FFD59E,stroke:#333,stroke-width:1px
```
