# vicentesilv/ecommerdeportics architecture

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

- Interactive diagram: https://gitdiagram.com/vicentesilv/ecommerdeportics
- Repository: https://github.com/vicentesilv/ecommerdeportics

## Overview

##### Main Components
- Frontend (Angular, TypeScript, Bootstrap) – Contains components, services (like auth, carrito, producto, usuario, etc.) and routing configured in Angular modules.
- Backend (Node.js/Express) – Organized into controllers (auth, carrito, productos, usuarios), routes, middleware (e.g., token verification), and configuration (database connection, email configuration) with its own entry point (index.js / app.js).
- Database – A MariaDB server hosting the “ecommerceDeportics.sql” schema with tables and views (e.g., productos_cliente, productos_empleado) for managing product data based on user roles.
- External Services – Payment processing libraries (PayPal’s checkout-server-sdk and Stripe), file upload and image processing tools (multer, sharp), and email service integration (nodemailer).

##### Relationships and Interactions
- File uploads and image processing modules (express-fileupload, multer, sharp) are used by the backend when handling media assets, so indicate these processing pipelines within the backend.

##### Architectural Patterns or Design Principles
- Separation of Concerns: Clearly show separation between the presentation layer (frontend) and the application logic (backend), with a distinct data layer (database).
- RESTful API Design: Indicate that the backend exposes various endpoints managed through dedicated route files and controllers.
- Modular Design: In the backend, highlight modules like configuration, middleware, controllers, and routes.
- Security & Scalability: Include components like middleware for authentication (JWT - jsonwebtoken) and any considerations for secure file handling (multer, express-fileupload).

##### Relevant Technologies and Frameworks
- Frontend Technologies: Angular, TypeScript, and Bootstrap.
- Backend Technologies: Node.js, Express, and supporting libraries (body-parser, cors, dotenv, bcrypt).
- Database: MariaDB via MySQL2.
- Payment Integrations: @paypal/checkout-server-sdk and Stripe.
- Additional Tools: nodemailer for emails, nodemon for development, and sharp for image manipulations.

- Use clear labels for each major component: “Frontend (Angular)”, “Backend (Node.js/Express)”, “Database (MariaDB)”, “Payment Services”, “Email Service”, “File/Media Processing”.
– Use rectangles for logical modules (e.g., Controllers, Middleware, Routes).
- Annotations or notes on important technology stacks and libraries that influence design decisions (for example, the use of middleware for JWT token verification or how file uploading is managed).

##### Final Recommendations
- Following core sections: Frontend (Angular app and its business logic), Backend (Express server with controllers, routes, configuration, and middleware), Database (MariaDB with e-commerce schema), and External Services (payments and email).

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Frontend Layer
    subgraph "Frontend Layer"
        F1["Frontend (Angular)"]:::frontend
        FC["Routing & Components"]:::frontend
        FS["Services (Auth,Carrito,Producto,Usuario,Pedido)"]:::frontend
        F1 --> FC
        F1 --> FS
    end

    %% Backend Layer
    subgraph "Backend Layer"
        B1["Backend Entry (app.js & index.js)"]:::backend
        BC["Controllers"]:::backend
        BR["Routes"]:::backend
        BM["Middleware (JWT)"]:::backend
        DBConfig["DB Connection"]:::backend
        EC["Email Config"]:::backend
        B1 --> BC
        B1 --> BR
        B1 --> BM
        B1 --> DBConfig
        B1 --> EC
        BR -->|"calls"| BC
    end

    %% External Services
    subgraph "External Services"
        P["Payment Services (PayPal&Stripe)"]:::external
        E["Email Service (Nodemailer)"]:::external
        FMP["File/Media Processing (Multer&Sharp)"]:::external
    end

    %% Database Layer
    subgraph "Database Layer"
        DB["Database (MariaDB)"]:::db
    end

    %% Interactions
    F1 -->|"REST_API"| B1
    B1 -->|"CRUD"| DB
    B1 -->|"Payment"| P
    B1 -->|"Email"| E
    B1 -->|"Media"| FMP

    %% Click Events
    click F1 "https://github.com/vicentesilv/ecommerdeportics/tree/master/frontend/"
    click FC "https://github.com/vicentesilv/ecommerdeportics/blob/master/frontend/src/app/app-routing.module.ts"
    click FS "https://github.com/vicentesilv/ecommerdeportics/tree/master/frontend/src/services/"
    click B1 "https://github.com/vicentesilv/ecommerdeportics/blob/master/backend/src/app.js"
    click BC "https://github.com/vicentesilv/ecommerdeportics/tree/master/backend/src/controllers/"
    click BR "https://github.com/vicentesilv/ecommerdeportics/tree/master/backend/src/routes/"
    click BM "https://github.com/vicentesilv/ecommerdeportics/blob/master/backend/src/middleware/middleware.verify.js"
    click DBConfig "https://github.com/vicentesilv/ecommerdeportics/blob/master/backend/src/config/dbConeccion.js"
    click EC "https://github.com/vicentesilv/ecommerdeportics/blob/master/backend/src/config/correo.config.js"
    click DB "https://github.com/vicentesilv/ecommerdeportics/blob/master/database/ecommerceDeportics.sql"

    %% Styles
    classDef frontend fill:#dce9ff,stroke:#0066cc,stroke-width:2px;
    classDef backend fill:#ffe6cc,stroke:#cc6600,stroke-width:2px;
    classDef db fill:#e6ffe6,stroke:#33cc33,stroke-width:2px;
    classDef external fill:#fff2e6,stroke:#ff9933,stroke-width:2px;
```
