# jose-santillano/punto-venta-csharp-sqlserver-2021 architecture

> Architecture diagram of the GitHub repository jose-santillano/punto-venta-csharp-sqlserver-2021, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/jose-santillano/punto-venta-csharp-sqlserver-2021
- Repository: https://github.com/jose-santillano/punto-venta-csharp-sqlserver-2021

## Overview

##### Project Type and Purpose
- This is a Windows-based, three-tier “Punto de Venta” (Point of Sale) desktop application written in C# and targeting .NET Framework 4.7.2.
- It follows a classic layered architecture (Presentation → Business → Data) and uses Microsoft SQL Server as its database.
- Key modules include user authentication, inventory (categorías, artículos), proveedores, clientes, ventas, ingresos, and reporting (PDF/Excel via RDLC).

##### File-Structure Analysis
- Top-level folders:
- CapaPresentacion – Windows Forms UI (forms, resources, report definitions, SqlServerTypes loader)
- CapaNegocio – Business Logic Layer (classes prefixed “N”, e.g., NArticulo, NVenta)
- CapaDatos – Data Access Layer (classes prefixed “D”, e.g., DArticulo, DVenta; ADO.NET dataset files)
- SistemaVentas – Main WinForms executable project tying the three layers together, ClickOnce publish artifacts.
- packages – NuGet packages for reporting (ReportViewerControl) and spatial types.
- dbventascopia.bak – Sample/backup of the SQL Server database.
- Each layer compiles to its own assembly: CapaDatos.dll, CapaNegocio.dll, CapaPresentacion.dll, and the final SistemaVentas.exe which references the three.

##### Assembly and Dependency Mapping (from README & file tree)
- The UI calls methods in CapaNegocio (business), which in turn calls CapaDatos (data).
- CapaDatos opens connections (Conexion.cs), executes queries or stored procedures against the SQL Server database.
- Reporting uses RDLC files (rpt*.rdlc) loaded in the UI via ReportViewerControl.Winforms.

##### Main Components
a. Client (User) with Windows Forms UI
b. Presentation Layer
- Forms (Login, Artículo, Categoría, Cliente, Venta, Ingreso, Reportes)
- RDLC Report definitions & ReportViewer control
- SqlServerTypes loader for spatial data
c. Business Logic Layer (CapaNegocio)
- NArticulo, NCategoria, NCliente, NProveedor, NTrabajador, NVenta, NIngreso, NDetalle_Venta, NDetalle_Ingreso
d. Data Access Layer (CapaDatos)
- Conexion.cs (DB connection management)
- D* classes for each entity
- Typed DataSet (dbventasDataSet.xsd)
e. Database Server
- SQL Server database (tables: Artículos, Categorías, Clientes, Ventas, Ingresos, Detalles)
f. External Dependencies
- Microsoft.ReportingServices.ReportViewerControl.Winforms
- Microsoft.SqlServer.Types (native loader for geography/data-types)
- ClickOnce deployment artifacts

##### Relationships and Data Flows
- User → UI (forms)
- UI → BLL: presentation invokes methods (e.g., NVenta.Insertar(), NArticulo.Mostrar())
- BLL → DAL: business classes call data classes (e.g., DVenta.Insertar())
- DAL → DB: SQL queries/stored procedures via ADO.NET
- UI → ReportViewer → Typed DataSet → DB (for on-the-fly report generation)
- Deployment: SistemaVentas.exe bundles all layer assemblies + config + SqlServerTypes + RDLC

##### Architectural Patterns & Principles
- Layered architecture (Separation of Concerns)
- ADO.NET Typed DataSets in DAL
- Strongly-typed business objects in BLL
- WinForms UI with code-behind
- ClickOnce for deployment/distribution

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User
    User["User"]:::user

    %% Presentation Layer
    subgraph "Presentation Layer"
        direction TB
        frmLogin["frmLogin"]:::ui
        frmArticulo["frmArticulo"]:::ui
        frmCategoria["frmCategoria"]:::ui
        frmCliente["frmCliente"]:::ui
        frmVenta["frmVenta"]:::ui
        frmIngreso["frmIngreso"]:::ui
        frmReporteFactura["frmReporteFactura"]:::ui
        rptArticulo["rptArticulo.rdlc"]:::ui
        rptComprobanteFactura["rptComprobanteFactura.rdlc"]:::ui
        dsPrincipal["dsPrincipal.xsd"]:::ui
        Loader["Loader (SqlServerTypes)"]:::ui
        ReportViewerControl["ReportViewerControl.Winforms"]:::ui
    end

    %% Business Layer
    subgraph "Business Logic Layer"
        direction TB
        NArticulo["NArticulo"]:::bll
        NCategoria["NCategoria"]:::bll
        NCliente["NCliente"]:::bll
        NProveedor["NProveedor"]:::bll
        NTrabajador["NTrabajador"]:::bll
        NVenta["NVenta"]:::bll
        NIngreso["NIngreso"]:::bll
        NPresentacion["NPresentacion"]:::bll
    end

    %% Data Access Layer
    subgraph "Data Access Layer"
        direction TB
        Conexion["Conexion"]:::dal
        DArticulo["DArticulo"]:::dal
        DCategoria["DCategoria"]:::dal
        DCliente["DCliente"]:::dal
        DProveedor["DProveedor"]:::dal
        DTrabajador["DTrabajador"]:::dal
        DVenta["DVenta"]:::dal
        DIngreso["DIngreso"]:::dal
        DDetalle_Venta["DDetalle_Venta"]:::dal
        DDetalle_Ingreso["DDetalle_Ingreso"]:::dal
        DPresentacion["DPresentacion"]:::dal
        dbDataSet["dbventasDataSet.xsd"]:::dal
    end

    %% Main Executable
    SistemaVentasExe["SistemaVentas.exe"]:::exe

    %% Database
    Database["SQL Server Database"]:::db

    %% External Dependencies
    subgraph "External Dependencies"
        direction TB
        ReportViewerPkg["ReportViewerControl.Winforms Lib"]:::ext
        SqlServerTypesPkg["SqlServerTypes Loader"]:::ext
    end

    %% Connections
    User -->|"interacts with"| frmLogin
    User --> frmVenta
    User --> frmIngreso
    User --> frmArticulo
    User --> frmCategoria
    User --> frmCliente
    User --> frmReporteFactura

    frmLogin -->|"calls BLL"| NCliente
    frmArticulo -->|"calls BLL"| NArticulo
    frmCategoria -->|"calls BLL"| NCategoria
    frmCliente -->|"calls BLL"| NCliente
    frmVenta -->|"calls NVenta.Insertar()"| NVenta
    frmIngreso -->|"calls NIngreso.Insertar()"| NIngreso
    frmReporteFactura -->|"loads RDLC"| ReportViewerControl
    ReportViewerControl -->|"binds to"| dsPrincipal
    dsPrincipal -->|"uses dataset"| dbDataSet
    dbDataSet -->|"ADO.NET/SqlClient"| Database

    NArticulo -->|"uses DAL"| DArticulo
    NCategoria --> DCategoria
    NCliente --> DCliente
    NProveedor --> DProveedor
    NTrabajador --> DTrabajador
    NVenta --> DVenta
    NIngreso --> DIngreso
    NPresentacion --> DPresentacion

    DArticulo -->|"ADO.NET"| Database
    DCategoria --> Database
    DCliente --> Database
    DProveedor --> Database
    DTrabajador --> Database
    DVenta --> Database
    DIngreso --> Database
    DDetalle_Venta --> Database
    DDetalle_Ingreso --> Database
    DPresentacion --> Database

    SistemaVentasExe -->|references| CapaPresentacion
    SistemaVentasExe -->|references| CapaNegocio
    SistemaVentasExe -->|references| CapaDatos
    SistemaVentasExe -->|includes| SqlServerTypesPkg
    SistemaVentasExe -->|includes| ReportViewerPkg

    %% Click Events Presentation
    click frmLogin "https://github.com/jose-santillano/punto-venta-csharp-sqlserver-2021/blob/main/CapaPresentacion/frmLogin.cs"
    click frmArticulo "https://github.com/jose-santillano/punto-venta-csharp-sqlserver-2021/blob/main/CapaPresentacion/frmArticulo.cs"
    click frmCategoria "https://github.com/jose-santillano/punto-venta-csharp-sqlserver-2021/blob/main/CapaPresentacion/frmCategoria.cs"
    click frmCliente "https://github.com/jose-santillano/punto-venta-csharp-sqlserver-2021/blob/main/CapaPresentacion/frmCliente.cs"
    click frmVenta "https://github.com/jose-santillano/punto-venta-csharp-sqlserver-2021/blob/main/CapaPresentacion/frmVenta.cs"
    click frmIngreso "https://github.com/jose-santillano/punto-venta-csharp-sqlserver-2021/blob/main/CapaPresentacion/frmIngreso.cs"
    click frmReporteFactura "https://github.com/jose-santillano/punto-venta-csharp-sqlserver-2021/blob/main/CapaPresentacion/Reportes/frmReporteFactura.cs"
    click rptArticulo "https://github.com/jose-santillano/punto-venta-csharp-sqlserver-2021/blob/main/CapaPresentacion/Reportes/rptArticulo.rdlc"
    click rptComprobanteFactura "https://github.com/jose-santillano/punto-venta-csharp-sqlserver-2021/blob/main/CapaPresentacion/Reportes/rptComprobanteFactura.rdlc"
    click dsPrincipal "https://github.com/jose-santillano/punto-venta-csharp-sqlserver-2021/blob/main/CapaPresentacion/dsPrincipal.xsd"
    click Loader "https://github.com/jose-santillano/punto-venta-csharp-sqlserver-2021/blob/main/CapaPresentacion/SqlServerTypes/Loader.cs"

    %% Click Events BLL
    click NArticulo "https://github.com/jose-santillano/punto-venta-csharp-sqlserver-2021/blob/main/CapaNegocio/NArticulo.cs"
    click NCategoria "https://github.com/jose-santillano/punto-venta-csharp-sqlserver-2021/blob/main/CapaNegocio/NCategoria.cs"
    click NCliente "https://github.com/jose-santillano/punto-venta-csharp-sqlserver-2021/blob/main/CapaNegocio/NCliente.cs"
    click NProveedor "https://github.com/jose-santillano/punto-venta-csharp-sqlserver-2021/blob/main/CapaNegocio/NProveedor.cs"
    click NTrabajador "https://github.com/jose-santillano/punto-venta-csharp-sqlserver-2021/blob/main/CapaNegocio/NTrabajador.cs"
    click NVenta "https://github.com/jose-santillano/punto-venta-csharp-sqlserver-2021/blob/main/CapaNegocio/NVenta.cs"
    click NIngreso "https://github.com/jose-santillano/punto-venta-csharp-sqlserver-2021/blob/main/CapaNegocio/NIngreso.cs"
    click NPresentacion "https://github.com/jose-santillano/punto-venta-csharp-sqlserver-2021/blob/main/CapaNegocio/NPresentacion.cs"

    %% Click Events DAL
    click Conexion "https://github.com/jose-santillano/punto-venta-csharp-sqlserver-2021/blob/main/CapaDatos/Conexion.cs"
    click DArticulo "https://github.com/jose-santillano/punto-venta-csharp-sqlserver-2021/blob/main/CapaDatos/DArticulo.cs"
    click DCategoria "https://github.com/jose-santillano/punto-venta-csharp-sqlserver-2021/blob/main/CapaDatos/DCategoria.cs"
    click DCliente "https://github.com/jose-santillano/punto-venta-csharp-sqlserver-2021/blob/main/CapaDatos/DCliente.cs"
    click DProveedor "https://github.com/jose-santillano/punto-venta-csharp-sqlserver-2021/blob/main/CapaDatos/DProveedor.cs"
    click DTrabajador "https://github.com/jose-santillano/punto-venta-csharp-sqlserver-2021/blob/main/CapaDatos/DTrabajador.cs"
    click DVenta "https://github.com/jose-santillano/punto-venta-csharp-sqlserver-2021/blob/main/CapaDatos/DVenta.cs"
    click DIngreso "https://github.com/jose-santillano/punto-venta-csharp-sqlserver-2021/blob/main/CapaDatos/DIngreso.cs"
    click DDetalle_Venta "https://github.com/jose-santillano/punto-venta-csharp-sqlserver-2021/blob/main/CapaDatos/DDetalle_Venta.cs"
    click DDetalle_Ingreso "https://github.com/jose-santillano/punto-venta-csharp-sqlserver-2021/blob/main/CapaDatos/DDetalle_Ingreso.cs"
    click DPresentacion "https://github.com/jose-santillano/punto-venta-csharp-sqlserver-2021/blob/main/CapaDatos/DPresentacion.cs"
    click dbDataSet "https://github.com/jose-santillano/punto-venta-csharp-sqlserver-2021/blob/main/CapaDatos/dbventasDataSet.xsd"

    %% Click Events Executable & External
    click SistemaVentasExe "https://github.com/jose-santillano/punto-venta-csharp-sqlserver-2021/blob/main/SistemaVentas/Program.cs"
    click ReportViewerPkg "https://github.com/jose-santillano/punto-venta-csharp-sqlserver-2021/tree/main/packages/Microsoft.ReportingServices.ReportViewerControl.Winforms.150.1449.0/lib/net40"
    click SqlServerTypesPkg "https://github.com/jose-santillano/punto-venta-csharp-sqlserver-2021/blob/main/packages/Microsoft.SqlServer.Types.14.0.314.76/content/SqlServerTypes/Loader.cs"

    %% Classes
    classDef user fill:#EBF5FF,stroke:#2C3E50,color:#2C3E50;
    classDef ui fill:#D5F5E3,stroke:#27AE60,color:#27AE60;
    classDef bll fill:#D6EAF8,stroke:#2874A6,color:#2874A6;
    classDef dal fill:#FCF3CF,stroke:#B7950B,color:#B7950B;
    classDef exe fill:#F5EEF8,stroke:#8E44AD,color:#8E44AD;
    classDef db fill:#E5E8E8,stroke:#566573,color:#566573;
    classDef ext fill:#FADBD8,stroke:#C0392B,color:#C0392B;
```
