# maressay/proyecto-ecommerce-deportivo-net architecture

> Architecture diagram of the GitHub repository maressay/proyecto-ecommerce-deportivo-net, 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/maressay/proyecto-ecommerce-deportivo-net
- Repository: https://github.com/maressay/proyecto-ecommerce-deportivo-net

## Overview

- User Interface (Frontend) Layer:
– Represented by the Views folder (with subdirectories for Admin, Carrito, Cliente, Contacto, Estadistica, Home, MisPedidos, NoCliente, Pago, Pedido, TipoCambio, and Shared).
– The wwwroot folder holds static assets (CSS, JavaScript, images, and libraries) that support the UI.
- Controller Layer:
– Two main subcategories:
○ UI Controllers (found in Controllers/UI) for serving rendered HTML pages.
○ REST Controllers (found in Controllers/Rest) for exposing APIs (e.g., for product and contact operations).
- Authentication & Identity Module:
– Located in the Areas/Identity folder, which contains pages and code-behind for login, registration, password management, and external login functionalities (including Google authentication).
- Business Logic & Service Layer:
– Found in the Models folder (classes such as CarritoService, EmailSender, and service classes under Models/Service) and DTOs, which encapsulate the core business rules (product management, order processing, shopping cart management, etc.).
- Data Access Layer:
– The Data folder contains ApplicationDbContext and all the EF Core migration files, demonstrating the use of an ORM (Entity Framework Core) to interact with the database.
- External Integrations:
– The Integrations folder shows connectors to external APIs (e.g., CurrencyExchangeApi, SendGridAPI for emails, WeatherAPI), which add extra functionality to the e-commerce operations.
- Infrastructure & Deployment:
– The Dockerfile and appsettings configuration files indicate containerization and environment-specific settings.
– The README also specifies commands for migrations and running the app.
– Database connectivity details are provided (hinting at a Postgres deployment on Render).

##### Relationships and data flows between components
- UI Controllers to the Views to represent response rendering and static assets served from wwwroot.
- API Controllers (REST) as endpoints accessed either through AJAX from the UI or through external systems.
- Path from both UI & API Controllers to the Business Logic Layer (Models and Services) where core processing takes place.
- Data flows from the Business Logic Layer down into the Data Access Layer (ApplicationDbContext with EF Core Migrations) and then to the Database (app.db or the external Postgres instance).
- External integrations by drawing connections from the Business Logic Layer to external services (currency exchange, email, weather), highlighting that these classes call external APIs.

##### Architectural patterns and design principles
- This project follows the MVC pattern, which should be clearly indicated by grouping the Views, Controllers, and Models separately.
- Separation of concerns is evident (authentication via Areas/Identity, business logic in Models/Service, API endpoints in a dedicated REST folder).
- The use of DTOs (in both the DTO folder and within Models/DTO) facilitates data transfer between layers.
- Integration with Entity Framework Core (via Migrations and ApplicationDbContext) shows a commitment to ORM-based data access.
- Containerization (using Dockerfile) signals deployment best practices and supports environment isolation.

##### Relevant technologies and frameworks
- ASP.NET Core MVC (for the overall web framework).
- Entity Framework Core (for database operations via ApplicationDbContext and migrations).
- . NET Identity (for user authentication and authorization, with dedicated Identity pages).
- External services: SendGrid (for email), CurrencyExchange API, Weather API.
- Client-side libraries and frameworks: Bootstrap and jQuery (located under wwwroot/lib).

## Diagram (Mermaid)

```mermaid
flowchart TD
    Client("User/Browser"):::frontend

    subgraph "Web Application"
        UI("UI Controllers"):::backend
        REST("REST Controllers"):::backend
        FRONT("Views"):::frontend
        STATIC("Static Assets (wwwroot)"):::frontend
        AUTH("Areas/Identity (Auth Module)"):::backend
    end

    Client -->|"requests"| UI
    Client -->|"AJAX calls"| REST
    UI -->|"renders"| FRONT
    UI -->|"serves"| STATIC
    UI -->|"authCheck"| AUTH

    subgraph "Business Logic Layer"
        CS1("CarritoService"):::backend
        ES("EmailSender"):::backend
        CSrv("ContactanosService"):::backend
        PSrv("ProductoService"):::backend
        DTO("DTOs"):::backend
    end

    UI -->|"calls"| CS1
    REST -->|"calls"| CS1
    UI -->|"calls"| ES
    REST -->|"calls"| ES
    UI -->|"calls"| CSrv
    REST -->|"calls"| CSrv
    UI -->|"calls"| PSrv
    REST -->|"calls"| PSrv
    UI -- "dataTransfer"--> DTO
    REST -- "dataTransfer"--> DTO

    subgraph "Data Access Layer"
        ADb("ApplicationDbContext"):::data
        MIG("Migrations"):::data
    end

    CS1 -->|"persists"| ADb
    ES -->|"persists"| ADb
    CSrv -->|"persists"| ADb
    PSrv -->|"persists"| ADb
    DTO -- "uses" --> ADb
    ADb -->|"updates"| MIG
    MIG -->|"migrates to"| DB("Database (Postgres)"):::data

    subgraph "External Integrations"
        CE("CurrencyExchangeApiIntegration"):::integration
        SG("SendGridAPIIntegration"):::integration
        WA("WeatherAPIIntegration"):::integration
    end

    CS1 -->|"integrates"| CE
    CS1 -->|"integrates"| SG
    CS1 -->|"integrates"| WA
    ES -->|"integrates"| SG
    CSrv -->|"integrates"| SG
    PSrv -->|"integrates"| CE

    subgraph "Infrastructure & Deployment"
        DOCKER("Dockerfile"):::deployment
        APPSET("appsettings.json"):::deployment
        APPDEV("appsettings.Development.json"):::deployment
        LAUNCH("launchSettings.json"):::deployment
    end

    DOCKER -->|"configures"| UI
    APPSET -->|"configures"| ADb
    APPDEV -->|"configures"| ADb
    LAUNCH -->|"configures"| DOCKER

    %% Click Events
    click FRONT "https://github.com/maressay/proyecto-ecommerce-deportivo-net/tree/master/Views"
    click STATIC "https://github.com/maressay/proyecto-ecommerce-deportivo-net/tree/master/wwwroot"
    click UI "https://github.com/maressay/proyecto-ecommerce-deportivo-net/tree/master/Controllers/UI"
    click REST "https://github.com/maressay/proyecto-ecommerce-deportivo-net/tree/master/Controllers/Rest"
    click AUTH "https://github.com/maressay/proyecto-ecommerce-deportivo-net/tree/master/Areas/Identity"
    click CS1 "https://github.com/maressay/proyecto-ecommerce-deportivo-net/blob/master/Models/CarritoService.cs"
    click ES "https://github.com/maressay/proyecto-ecommerce-deportivo-net/blob/master/Models/EmailSender.cs"
    click CSrv "https://github.com/maressay/proyecto-ecommerce-deportivo-net/blob/master/Models/Service/ContactanosService.cs"
    click PSrv "https://github.com/maressay/proyecto-ecommerce-deportivo-net/blob/master/Models/Service/ProductoService.cs"
    click DTO "https://github.com/maressay/proyecto-ecommerce-deportivo-net/tree/master/DTO"
    click ADb "https://github.com/maressay/proyecto-ecommerce-deportivo-net/blob/master/Data/ApplicationDbContext.cs"
    click MIG "https://github.com/maressay/proyecto-ecommerce-deportivo-net/tree/master/Data/Migrations"
    click CE "https://github.com/maressay/proyecto-ecommerce-deportivo-net/blob/master/Integrations/CurrencyExchangeApiIntegration.cs"
    click SG "https://github.com/maressay/proyecto-ecommerce-deportivo-net/blob/master/Integrations/SendGridAPIIntegration.cs"
    click WA "https://github.com/maressay/proyecto-ecommerce-deportivo-net/blob/master/Integrations/WeatherAPIIntegration.cs"
    click DOCKER "https://github.com/maressay/proyecto-ecommerce-deportivo-net/tree/master/Dockerfile"
    click APPSET "https://github.com/maressay/proyecto-ecommerce-deportivo-net/blob/master/appsettings.json"
    click APPDEV "https://github.com/maressay/proyecto-ecommerce-deportivo-net/blob/master/appsettings.Development.json"
    click LAUNCH "https://github.com/maressay/proyecto-ecommerce-deportivo-net/blob/master/Properties/launchSettings.json"

    %% Styles
    classDef frontend fill:#AED6F1,stroke:#1B4F72,stroke-width:2px;
    classDef backend fill:#F5B7B1,stroke:#641E16,stroke-width:2px;
    classDef data fill:#D5F5E3,stroke:#145A32,stroke-width:2px;
    classDef integration fill:#F9E79F,stroke:#7D6608,stroke-width:2px;
    classDef deployment fill:#D6EAF8,stroke:#1B4F72,stroke-width:2px;
```
