# colodreroalex/mundo-nomada architecture

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

- Interactive diagram: https://gitdiagram.com/colodreroalex/mundo-nomada
- Repository: https://github.com/colodreroalex/mundo-nomada

## Overview

##### Project type and purpose
- This is a single-page e-commerce frontend built with Angular. It comprises UI components, feature modules, routing, services that consume REST APIs, and model classes. The application is served as static assets (likely via Netlify) and interacts with a separate backend (not part of this repo) for data persistence, authentication, and business logic.

##### High-level file-structure analysis
- **src/app/** contains the core Angular application.
- app.component + app.routes.ts + app.config.ts: the root component, routing definitions and global configuration.
- componentes/: all reusable UI components (product list, cart, admin panel, login, register, etc.).
- pages/footer-pages/: a feature module for legal/info pages.
- services/: Angular services (AuthService, ProductosService, CarritoService, OrdersService, UsuariosService, etc.) that perform HTTP calls.
- models/: TypeScript interfaces/classes representing domain entities (Producto, Categoria, Pedido, Users, etc.).
- **public/** & **src/index.html**: static assets and HTML entrypoint.
- **angular.json**, **tsconfig.json**: build and TypeScript configurations.

a. Frontend (Angular SPA)
- **UI Layer**: Components & Pages that render views and capture user interactions.
- **Routing Layer**: app.routes.ts + feature-module routing to navigate between screens.
- **Service Layer**: injectable services that handle business rules and perform HTTP requests to backend REST endpoints.
- **Domain Models**: TypeScript classes/interfaces to type API payloads.
- **Guards & Interceptors** (e.g., AuthGuard): protect routes and inject authentication tokens.
- **Build/Deploy**: Angular CLI → static bundle → CDN/Netlify.
b. Backend (External REST API)
- **Authentication API**: login, register, token refresh.
- **Product API**: CRUD operations for products/categories.
- **Cart & Order API**: endpoints for shopping cart, checkout, order history.
- **User API**: user profile, admin user management.
c. Persistence & External Services
- **Database**: relational or NoSQL DB storing products, users, orders, etc.
- **External Payment Gateway**: invoked during checkout (not shown in code but implied).
- **PDF Generation**: pdf.service.ts for client-side invoice/receipt generation.

##### Relationships and data flow
- **User Browser** → loads **Angular SPA** (index.html + JS bundle).
- **Angular Components** ←→ **Angular Services**: components call service methods to fetch/update data.
- **Angular Services** → **Backend REST API**: HTTP GET/POST/PUT/DELETE calls.
- **Backend API** → **Database**: CRUD operations.
- **AuthGuard** inspects the JWT (or session token) stored in LocalStorage/Session and blocks/permits route activation.
- **PDF Service** consumes Order data to render/download receipts client-side.

##### Important architectural patterns
- Component-based UI (Angular).
- Module decomposition (root AppModule + feature FooterPagesModule).
- Service-oriented interaction with backend (separation of concerns).
- Route guarding for authentication/authorization.
- Client-side state via services (singleton services hold cart state).
- Model classes for type safety and mapping API payloads.

## Diagram (Mermaid)

```mermaid
flowchart TD
    Browser["Browser/Client (Angular SPA)"]
    UI["UI Components & Pages"]:::ui
    Routing["Routing Layer"]:::ui
    FeatureFooter["Footer Pages Module"]:::ui
    AvisoLegal["Aviso Legal Page"]:::ui
    Guards["Auth Guard"]:::svc
    subgraph ServicesLayer["Service Layer"]
        AuthService["Auth Service"]:::svc
        ProductosService["Productos Service"]:::svc
        CategoriasService["Categorias Service"]:::svc
        CarritoService["Carrito Service"]:::svc
        OrdersService["Orders Service"]:::svc
        UsuariosService["Usuarios Service"]:::svc
        PdfService["PDF Generation Service"]:::svc
    end
    subgraph DomainModels["Domain Models"]
        Producto["Producto"]:::model
        Categoria["Categoria"]:::model
        Pedido["Pedido"]:::model
        OrderItem["OrderItem"]:::model
        CarritoModel["Carrito"]:::model
        Users["Users"]:::model
    end
    ExternalAPI["External REST API"]:::external
    Database["Database"]:::external
    Payment["Payment Gateway"]:::external
    BuildDeploy["Build & Deploy\n(angular.json, tsconfig.json, Netlify)"]:::deploy

    Browser --> UI
    UI --> Routing
    Routing --> Guards
    UI --> ServicesLayer
    Guards --> ServicesLayer
    ServicesLayer --> ExternalAPI
    ExternalAPI --> Database
    ExternalAPI --> Payment
    ServicesLayer --> PdfService
    PdfService --> Browser
    BuildDeploy --> Browser
    Routing --> FeatureFooter
    FeatureFooter --> AvisoLegal

    click Browser "https://github.com/colodreroalex/mundo-nomada/tree/main/src/"
    click UI "https://github.com/colodreroalex/mundo-nomada/tree/main/src/app/componentes/"
    click Routing "https://github.com/colodreroalex/mundo-nomada/blob/main/src/app/app.routes.ts"
    click FeatureFooter "https://github.com/colodreroalex/mundo-nomada/blob/main/src/app/pages/footer-pages/footer-pages.module.ts"
    click AvisoLegal "https://github.com/colodreroalex/mundo-nomada/blob/main/src/app/pages/footer-pages/aviso-legal/aviso-legal.component.ts"
    click Guards "https://github.com/colodreroalex/mundo-nomada/blob/main/src/app/services/auth.guard.ts"
    click AuthService "https://github.com/colodreroalex/mundo-nomada/blob/main/src/app/services/auth.service.ts"
    click ProductosService "https://github.com/colodreroalex/mundo-nomada/blob/main/src/app/services/productos.service.ts"
    click CategoriasService "https://github.com/colodreroalex/mundo-nomada/blob/main/src/app/services/categorias.service.ts"
    click CarritoService "https://github.com/colodreroalex/mundo-nomada/blob/main/src/app/services/carrito.service.ts"
    click OrdersService "https://github.com/colodreroalex/mundo-nomada/blob/main/src/app/services/orders.service.ts"
    click UsuariosService "https://github.com/colodreroalex/mundo-nomada/blob/main/src/app/services/usuarios.service.ts"
    click PdfService "https://github.com/colodreroalex/mundo-nomada/blob/main/src/app/services/pdf.service.ts"
    click Producto "https://github.com/colodreroalex/mundo-nomada/blob/main/src/models/Producto.ts"
    click Categoria "https://github.com/colodreroalex/mundo-nomada/blob/main/src/models/Categoria.ts"
    click Pedido "https://github.com/colodreroalex/mundo-nomada/blob/main/src/models/Pedido.ts"
    click OrderItem "https://github.com/colodreroalex/mundo-nomada/blob/main/src/models/OrderItem.ts"
    click CarritoModel "https://github.com/colodreroalex/mundo-nomada/blob/main/src/models/Carrito.ts"
    click Users "https://github.com/colodreroalex/mundo-nomada/blob/main/src/models/Users.ts"
    click BuildDeploy "https://github.com/colodreroalex/mundo-nomada/blob/main/angular.json"

    classDef ui fill:#ADD8E6,stroke:#333,stroke-width:2px
    classDef svc fill:#90EE90,stroke:#333,stroke-width:2px
    classDef external fill:#FFA500,stroke:#333,stroke-width:2px
    classDef model fill:#D3D3D3,stroke:#333,stroke-width:2px
    classDef deploy fill:#FFD700,stroke:#333,stroke-width:2px
```
