# navarro-n/frontend-tiendaonline architecture

> Architecture diagram of the GitHub repository navarro-n/frontend-tiendaonline, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/navarro-n/frontend-tiendaonline
- Repository: https://github.com/navarro-n/frontend-tiendaonline

## Overview

##### Project Overview and Main Components
- Recognize that the project is a front-end Angular application focused on an e-commerce scenario.
- Main components to highlight:
- Cliente (Customer Frontend): Contains areas like home, tienda (store), carrito (shopping cart), login, registro, header-cliente, layout, etc.
- Shared Components & Utilities: Elements like footer, page-not-found, and global styles.
- Services: Authentication (using token and credentials), guards for route protection, interceptors for attaching tokens to HTTP requests, pipes, and application-level utilities.

a. Create distinct sections/containers for each of the main parts:
- Public Client Area: Emphasize components that are visible to site visitors—the “cliente” module.
- Backoffice Area: Emphasize components reserved for logged-in vendors (control panel, graphics, user management, etc.).
- Shared Components: Footer, header (which exists in both cliente and backoffice), and global page-not-found component.
- Authentication and authorization via auth services (credentials, token, state).
- Interceptors that attach tokens to outgoing API requests.
- Route guards that protect certain routes (auth.guard, public.guard).
- Figuring out potential integration with backend APIs (even though the backend isn’t in the repository, assume that the API endpoints exist as external services).

##### Interactions and Data Flow
- How the customer interacts with authentication services to gain access.
- The flow from login/registration through the auth services to either the cliente or backoffice area.
- Interaction between shopping cart actions (in cliente) and the tienda service for product and order management.
- Data flow from backoffice components (like statistics and dashboard graphics) to the underlying data service layer, presumably consuming APIs.
- The role of interceptors that automatically append tokens to outgoing API requests.

##### Architectural Patterns and Design Principles
- Component-Based Structure: Emphasize Angular’s modularity by depicting how different groups of components (cliente and backoffice) interact.
- Separation of Concerns: Mark a clear separation between UI components, service layers, and routing modules (e.g., app.routes.ts and the layout modules).
- Usage of Guards and Interceptors: Highlight that security and user flow control are managed at a global level, ensuring protected routes and token handling.
- Shared Theme & Styles: Note the common use of Scss, Bootstrap, and Angular’s component styling that ties the UI together.

##### Technologies and Frameworks
- Angular as the primary framework.
- TypeScript for typed JavaScript development.
- SCSS and Bootstrap for styling.
- ChartJS is used in the backoffice for generating statistical charts/analytics.
- Optionally, note that the project uses common Angular patterns such as modules, components, services, and routing.

- Detail Component Interactions: Show how login and registration pages lead into services, which in turn allow access to the cliente or backoffice sections.
- Static and Dynamic Components: For example, the static ones like header, footer, and the dynamic backoffice tabs (graphics, stats, profile) that build a responsive layout.
- Clearly denote modules or grouping where similar functionalities reside (e.g., group all “graphic-line”, “graphic-primera-caja”, etc. under the control-panel-tabs grouping).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Layer
    subgraph "Presentation Layer"
        subgraph "Cliente (Customer Frontend)"
            clienteHome["Cliente Home"]:::frontend
            clienteTienda["Cliente Tienda"]:::frontend
            clienteCarrito["Cliente Carrito"]:::frontend
            clienteLogin["Cliente Login"]:::frontend
            clienteRegistro["Cliente Registro"]:::frontend
            clienteHeader["Cliente Header"]:::frontend
            clienteLayout["Cliente Layout"]:::frontend
        end
        subgraph "Backoffice (Vendor Area)"
            backofficeControlPanel["Control Panel"]:::backoffice
            backofficeControlPanelTabs["Control Panel Tabs"]:::backoffice
            backofficeHeader["Backoffice Header"]:::backoffice
            backofficeLayout["Backoffice Layout"]:::backoffice
            backofficePerfil["Backoffice Perfil"]:::backoffice
            backofficeProductos["Backoffice Productos"]:::backoffice
            backofficeSidebar["Backoffice Sidebar"]:::backoffice
            backofficeTabs["Backoffice Tabs"]:::backoffice
        end
        subgraph "Shared Components"
            sharedFooter["Footer"]:::shared
            sharedPageNotFound["Page Not Found"]:::shared
            sharedAssets["Global Styles & Assets"]:::shared
        end
    end

    %% Services Layer
    subgraph "Services Layer"
        authService["Auth Services"]:::service
        guards["Guards"]:::service
        interceptors["Interceptors"]:::service
        carritoService["Carrito Service"]:::service
        tiendaService["Tienda Service"]:::service
        utilsService["Popup & Utility Services"]:::service
        pipes["Pipes"]:::service
        statusService["Status Services"]:::service
    end

    %% External API / Backend
    externalApi["External API/Backend"]:::external

    %% Connections for Authentication Flow
    clienteLogin -->|"login"| authService
    clienteRegistro -->|"register"| authService
    authService -->|"authenticates"| clienteLayout
    authService -->|"authenticates"| backofficeLayout

    %% Cliente Interactions
    clienteTienda -->|"productInfo"| tiendaService
    clienteCarrito -->|"cartAction"| carritoService
    clienteHeader -->|"navigatesTo"| clienteLayout

    %% Backoffice Interactions
    backofficeControlPanel -->|"dashboard"| authService
    backofficeControlPanelTabs -->|"graphics"| authService
    backofficeHeader -->|"navigatesTo"| backofficeLayout
    backofficeProductos -->|"updates"| backofficeControlPanel

    %% Shared Integration
    clienteLayout -->|"includes"| sharedFooter
    backofficeLayout -->|"includes"| sharedFooter
    clienteLayout -->|"styles"| sharedAssets
    backofficeLayout -->|"styles"| sharedAssets

    %% Route Protection and Utilities
    clienteLayout -->|"protect"| guards
    backofficeLayout -->|"protect"| guards
    pipes -->|"transform"| clienteHome
    statusService -->|"updateStatus"| backofficeSidebar

    %% API Communication via Interceptors
    authService -->|"attachToken"| interceptors
    tiendaService -->|"apiCall"| interceptors
    carritoService -->|"apiCall"| interceptors
    interceptors -->|"forwardRequest"| externalApi
    utilsService -->|"notify"| externalApi

    %% Click Events for Cliente Components
    click clienteHome "https://github.com/navarro-n/frontend-tiendaonline/tree/master/src/app/cliente/home"
    click clienteTienda "https://github.com/navarro-n/frontend-tiendaonline/tree/master/src/app/cliente/tienda"
    click clienteCarrito "https://github.com/navarro-n/frontend-tiendaonline/tree/master/src/app/cliente/carrito"
    click clienteLogin "https://github.com/navarro-n/frontend-tiendaonline/tree/master/src/app/cliente/login"
    click clienteRegistro "https://github.com/navarro-n/frontend-tiendaonline/tree/master/src/app/cliente/registro"
    click clienteHeader "https://github.com/navarro-n/frontend-tiendaonline/tree/master/src/app/cliente/header-cliente"
    click clienteLayout "https://github.com/navarro-n/frontend-tiendaonline/tree/master/src/app/cliente/layout"

    %% Click Events for Backoffice Components
    click backofficeControlPanel "https://github.com/navarro-n/frontend-tiendaonline/tree/master/src/app/backoffice/control-panel"
    click backofficeControlPanelTabs "https://github.com/navarro-n/frontend-tiendaonline/tree/master/src/app/backoffice/control-panel-tabs"
    click backofficeHeader "https://github.com/navarro-n/frontend-tiendaonline/tree/master/src/app/backoffice/header-backoffice"
    click backofficeLayout "https://github.com/navarro-n/frontend-tiendaonline/tree/master/src/app/backoffice/layout"
    click backofficePerfil "https://github.com/navarro-n/frontend-tiendaonline/tree/master/src/app/backoffice/perfil"
    click backofficeProductos "https://github.com/navarro-n/frontend-tiendaonline/tree/master/src/app/backoffice/productos"
    click backofficeSidebar "https://github.com/navarro-n/frontend-tiendaonline/tree/master/src/app/backoffice/sidebar"
    click backofficeTabs "https://github.com/navarro-n/frontend-tiendaonline/tree/master/src/app/backoffice/tabs"

    %% Click Events for Shared Components
    click sharedFooter "https://github.com/navarro-n/frontend-tiendaonline/tree/master/src/app/footer"
    click sharedPageNotFound "https://github.com/navarro-n/frontend-tiendaonline/tree/master/src/app/page-not-found"
    click sharedAssets "https://github.com/navarro-n/frontend-tiendaonline/tree/master/src/assets"

    %% Click Events for Services Layer
    click authService "https://github.com/navarro-n/frontend-tiendaonline/tree/master/src/app/services/auth"
    click guards "https://github.com/navarro-n/frontend-tiendaonline/tree/master/src/app/services/guards"
    click interceptors "https://github.com/navarro-n/frontend-tiendaonline/tree/master/src/app/services/interceptors"
    click carritoService "https://github.com/navarro-n/frontend-tiendaonline/blob/master/src/app/services/carrito.service.ts"
    click tiendaService "https://github.com/navarro-n/frontend-tiendaonline/blob/master/src/app/services/tienda.service.ts"
    click utilsService "https://github.com/navarro-n/frontend-tiendaonline/tree/master/src/app/services/utils"
    click pipes "https://github.com/navarro-n/frontend-tiendaonline/tree/master/src/app/services/pipes"
    click statusService "https://github.com/navarro-n/frontend-tiendaonline/blob/master/src/app/services/status/sidebar-status.service.ts"

    %% Styling Classes
    classDef frontend fill:#ADD8E6,stroke:#000,stroke-width:2px;
    classDef backoffice fill:#90EE90,stroke:#000,stroke-width:2px;
    classDef shared fill:#FFB6C1,stroke:#000,stroke-width:2px;
    classDef service fill:#FFD700,stroke:#000,stroke-width:2px;
    classDef external fill:#D3D3D3,stroke:#000,stroke-width:2px;
```
