# juliansuarez5/sistema_ventas_web architecture

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

- Interactive diagram: https://gitdiagram.com/juliansuarez5/sistema_ventas_web
- Repository: https://github.com/juliansuarez5/sistema_ventas_web

## Overview

##### Project Type and Purpose
- This is a full-stack e-commerce web application built on ASP.NET MVC (.NET Framework 4.7.2).
- It has two separate MVC frontends (Admin panel and Storefront), a layered backend (Entity, Business, Data), and integrates with SQL Server and PayPal REST API.

##### File Structure
- Top-Level Layers (N-Tier Architecture):
· CapaEntidad (Data Models/DTOs)
· CapaNegocio (Business Logic)
· CapaDatos (Data Access / CRUD)
- Presentation Projects (UI):
· CapaPresentacionAdmin (Admin MVC App – Controllers, Views, Client-side assets)
· CapaPresentacionTienda (Storefront MVC App – Controllers, Views, Client-side assets)
- Other artifacts:
· SQLQuery script for schema
· FotosCarrito folder (filesystem storage for product images)
· Solution file (.sln) and NuGet package configs

##### README Insights
- Layer responsibilities are explicitly documented (Entities, Business, Data, Presentation).
- Key external dependency: PayPal REST API for payment, SQL Server for persistence, ClosedXML for Excel export, jQuery/DataTables/SweetAlert/LoadingOverlay for UI.

##### Main Components
A. Presentation Layer
1. Admin UI (CapaPresentacionAdmin)
2. Store UI (CapaPresentacionTienda)
B. Business Layer (CapaNegocio)
C. Data Layer (CapaDatos)
D. Entity Layer (CapaEntidad)
E. Persistence
1. SQL Server Database (DB_CARRITO)
2. File system (FotosCarrito folder for images)
F. External Services
1. PayPal REST API
2. Excel export (ClosedXML)

##### Relationships & Interactions
- UI → Controllers → Business Layer → Data Layer → Database / File System
- Data Layer uses ADO.NET or similar to run SQL CRUD against SQL Server
- Entities flow up from Data Layer through Business Layer to Controllers, then to Views
- Storefront UI upon checkout invokes Business → PayPal service (via clsN_PayPal in CapaNegocio and cls_Checkout_Order in CapaEntidad/PayPal) → PayPal returns capture response → Business persists payment record via Data Layer → UI shows confirmation
- Admin UI can trigger Excel export: Business Layer uses ClosedXML to generate file

##### Architectural Patterns & Principles
- Layered (N-Tier) architecture with strict dependency direction (Presentation → Business → Data → Database)
- MVC pattern in each presentation project (Models = Entities/DTOs, Views = Razor .cshtml, Controllers)
- Separation of concerns:
· Business holds rules,
· Data holds persistence code,
· Presentation handles routing and UI
- Dependency injection can be highlighted if used (or at least show layers referencing only the next lower layer)

##### Essential Elements to Capture
- Two separate MVC frontends (Admin, Store) with Controllers→Views flow.
- Business layer as central orchestrator of rules, Excel export, payment logic.
- Data layer handling direct SQL CRUD.
- Entity layer as common model assembly.
- SQL Server database and file-system storage for product images.
- PayPal REST API integration flow.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Presentation Layer - Admin
    subgraph "Admin UI" 
        direction TB
        AdminViews["Views"]:::frontend
        AdminControllers["Controllers"]:::frontend
    end

    %% Presentation Layer - Storefront
    subgraph "Storefront UI"
        direction TB
        StoreViews["Views"]:::frontend
        StoreControllers["Controllers"]:::frontend
    end

    %% Business Layer
    Business["CapaNegocio\n(Business Services)"]:::business

    %% Data Layer
    Data["CapaDatos\n(Data Access)"]:::data

    %% Entity Layer
    Entity["CapaEntidad\n(Entities/DTOs)"]:::entity

    %% Storage Layer
    SQLDB["SQL Server\n(DB_CARRITO)"]:::storage
    FileSys["File System\n(FotosCarrito)"]:::storage

    %% External Services
    PayPal["PayPal REST API"]:::external
    Excel["ClosedXML\n(Excel Export)"]:::external

    %% Connections
    AdminControllers -->|"renders"| AdminViews
    AdminControllers -->|"GET/POST"| Business
    StoreControllers -->|"renders"| StoreViews
    StoreControllers -->|"GET/POST"| Business

    Business -->|"uses entities"| Entity
    Data -->|"uses entities"| Entity

    Business -->|"CRUD calls"| Data
    Data -->|"SQL CRUD"| SQLDB
    Data -->|"reads/writes"| FileSys

    Business -->|"PayPal Checkout"| PayPal
    Business -->|"Generate Excel"| Excel

    %% References from Presentation to Business and Entity
    AdminControllers -->|"use"| Entity
    StoreControllers -->|"use"| Entity

    %% Click Events
    click AdminUI "https://github.com/juliansuarez5/sistema_ventas_web/tree/master/CapaPresentacionAdmin/"
    click StoreUI "https://github.com/juliansuarez5/sistema_ventas_web/tree/master/CapaPresentacionTienda/"
    click Business "https://github.com/juliansuarez5/sistema_ventas_web/tree/master/CapaNegocio/"
    click Data "https://github.com/juliansuarez5/sistema_ventas_web/tree/master/CapaDatos/"
    click Entity "https://github.com/juliansuarez5/sistema_ventas_web/tree/master/CapaEntidad/"
    click PayPalBiz "https://github.com/juliansuarez5/sistema_ventas_web/blob/master/CapaNegocio/clsN_PayPal.cs"
    click PayPalEntity "https://github.com/juliansuarez5/sistema_ventas_web/tree/master/CapaEntidad/PayPal/"
    click ReportBiz "https://github.com/juliansuarez5/sistema_ventas_web/blob/master/CapaNegocio/clsN_Reporte.cs"
    click SQLScript "https://github.com/juliansuarez5/sistema_ventas_web/blob/master/SQLQuery (Sin Inserts ).sql"
    click ImageFS "https://github.com/juliansuarez5/sistema_ventas_web/tree/master/FotosCarrito/"
    click Solution "https://github.com/juliansuarez5/sistema_ventas_web/blob/master/Sistema_Ventas_Web.sln"
    click Readme "https://github.com/juliansuarez5/sistema_ventas_web/blob/master/README.md"
    click NugetBN "https://github.com/juliansuarez5/sistema_ventas_web/blob/master/CapaNegocio/packages.config"
    click NugetAdmin "https://github.com/juliansuarez5/sistema_ventas_web/blob/master/CapaPresentacionAdmin/packages.config"
    click NugetStore "https://github.com/juliansuarez5/sistema_ventas_web/blob/master/CapaPresentacionTienda/packages.config"

    %% Styles
    classDef frontend fill:#cce5ff,stroke:#004085,color:#004085
    classDef business fill:#d4edda,stroke:#155724,color:#155724
    classDef data fill:#fff3cd,stroke:#856404,color:#856404
    classDef entity fill:#e2e3e5,stroke:#6c757d,color:#6c757d
    classDef storage fill:#f8f9fa,stroke:#6c757d,color:#6c757d
    classDef external fill:#e2d5f7,stroke:#5a32a3,color:#5a32a3
```
