# aaron-shrike/sistema-gestion-productos architecture

> Architecture diagram of the GitHub repository aaron-shrike/sistema-gestion-productos, 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/aaron-shrike/sistema-gestion-productos
- Repository: https://github.com/aaron-shrike/sistema-gestion-productos

## Overview

##### Project Type and Purpose
- This is a Windows-Forms “three-tier” product-management system written in C# (.NET Framework) with SQL Server as the backend.
- The README confirms it’s a semester project (“Sistema de Gestión de Productos”) using C# and SQL Server.

##### High-Level Architectural Layers
- Presentation (Ventas)
- Business Logic / Rules (ReglasNegocio)
- Data Access (DAL)
- Shared Domain Models (Entidades)
- Database (SQL Server)

##### Main Components and Their Roles
a. Presentation Layer (Ventas)
- A WinForms application with multiple forms (e.g., frmPrincipal, frmGestionarProducto).
- References MetroFramework packages for UI styling.
- Contains App.config for UI-level settings (e.g., connection strings).
b. Business Logic Layer (ReglasNegocio)
- RNEmpresa, RNProducto, etc.: encapsulate validation and business rules.
- Reads settings from app.config.
c. Data Access Layer (DAL)
- DAL.cs: CRUD operations using ADO.NET or similar.
- Manages SQL Server connections and commands.
d. Domain Models (Entidades)
- Plain CLR classes: Empresa, Categoria, Producto, Usuario, PrecioLocal, etc.
- Shared by all layers as method parameters and return types.
e. Database (SQL Server)
- Tables: Producto, Categoria, Empresa, Local, Marca, Personal, Usuario, PrecioLocal.
- Backup scripts under BackUp/ for initial schema and seed data.

##### Relationships and Data Flow
- UI → Business Logic: the forms call methods on RN* classes to apply rules.
- Business Logic → Data Access: RN* classes delegate persistence to DAL.
- Data Access ↔ Database: DAL executes SQL commands against SQL Server.
- All three layers reference the Entidades library for shared DTOs.
- MetroFramework packages are only referenced by the Presentation layer.

##### Architectural Patterns and Principles
- Layered architecture (Presentation → BLL → DAL → Database).
- Separation of concerns: UI is decoupled from business rules, which are decoupled from data access.
- Reusable domain models in Entidades.
- Dependency: Presentation depends on BLL and Entities; BLL depends on DAL and Entities; DAL depends on Entities.

##### Technologies and Frameworks
- C# .NET Framework (probably 4.x based on package libs “net40”).
- WinForms + MetroFramework (for theming).
- ADO.NET or similar in DAL.
- SQL Server (scripts provided in BackUp directory).

##### Checklist for the Principal Software Engineer
[ ] All four layers are represented.
[ ] Entidades is clearly shown as a shared component.
[ ] Note on backup scripts and config files.

## Diagram (Mermaid)

```mermaid
flowchart TD
    title["Sistema de Gestión de Productos – Arquitectura de Capas"]

    %% Presentation Layer
    subgraph "Presentation Layer (Ventas)"
        direction TB
        P1["frmPrincipal"]:::frontend
        P2["frmGestionarProducto"]:::frontend
        P3["frmIdentificar"]:::frontend
        P4["App.config"]:::config
        Metro["MetroFramework (UI theme)"]:::dependency
    end

    %% Business Logic Layer
    subgraph "Business Logic Layer (ReglasNegocio)"
        direction TB
        RN1["RNProducto"]:::bll
        RN2["RNCategoria"]:::bll
        RN3["RNEmpresa"]:::bll
        RN4["RNLocal"]:::bll
        RN5["RNMarca"]:::bll
        RN6["RNPersonal"]:::bll
        RN7["RNPrecioLocal"]:::bll
        RN8["RNUsuario"]:::bll
        RNConf["app.config"]:::config
    end

    %% Data Access Layer
    subgraph "Data Access Layer (DAL)"
        direction TB
        DALcs["DAL.cs"]:::dal
        DALproj["DAL.csproj"]:::dal
        DALAsm["Properties/AssemblyInfo.cs"]:::dal
    end

    %% Shared Domain Models
    subgraph "Domain Models (Entidades)"
        direction TB
        E1["Producto.cs"]:::shared
        E2["Categoria.cs"]:::shared
        E3["Empresa.cs"]:::shared
        E4["Local.cs"]:::shared
        E5["Marca.cs"]:::shared
        E6["Personal.cs"]:::shared
        E7["PrecioLocal.cs"]:::shared
        E8["Usuario.cs"]:::shared
        Eproj["Entidades.csproj"]:::shared
        EAsm["Properties/AssemblyInfo.cs"]:::shared
    end

    %% Database
    DB[(SQL Server)]:::database
    BackUp["Backup scripts in BackUp/"]:::note

    %% Relationships
    P1 -->|"Uses business rules"| RN1
    P2 -->|"Uses business rules"| RN1
    P3 -->|"Uses business rules"| RN8
    Metro -->|"UI theming"| P1
    Metro -->|"UI theming"| P2
    Metro -->|"UI theming"| P3

    RN1 -->|"CRUD operations"| DALcs
    RN2 -->|"CRUD operations"| DALcs
    RN3 -->|"CRUD operations"| DALcs
    RN4 -->|"CRUD operations"| DALcs
    RN5 -->|"CRUD operations"| DALcs
    RN6 -->|"CRUD operations"| DALcs
    RN7 -->|"CRUD operations"| DALcs
    RN8 -->|"CRUD operations"| DALcs

    DALcs -->|"ExecuteQuery() / ADO.NET"| DB
    DB -->|"Schema & Data"| BackUp

    %% References to shared models
    P1 -->|"DTOs"| E1
    P1 -->|"DTOs"| E2
    P1 -->|"DTOs"| E3
    RN1 -->|"DTOs"| E1
    RN2 -->|"DTOs"| E2
    DALcs -->|"DTOs"| E1
    DALcs -->|"DTOs"| E2

    %% Click Events
    click P1 "https://github.com/aaron-shrike/sistema-gestion-productos/blob/main/Ventas/frmPrincipal.cs"
    click P2 "https://github.com/aaron-shrike/sistema-gestion-productos/blob/main/Ventas/frmGestionarProducto.cs"
    click P3 "https://github.com/aaron-shrike/sistema-gestion-productos/blob/main/Ventas/frmIdentificar.cs"
    click P4 "https://github.com/aaron-shrike/sistema-gestion-productos/blob/main/Ventas/App.config"
    click RN1 "https://github.com/aaron-shrike/sistema-gestion-productos/blob/main/ReglasNegocio/RNProducto.cs"
    click RN2 "https://github.com/aaron-shrike/sistema-gestion-productos/blob/main/ReglasNegocio/RNCategoria.cs"
    click RN3 "https://github.com/aaron-shrike/sistema-gestion-productos/blob/main/ReglasNegocio/RNEmpresa.cs"
    click RN4 "https://github.com/aaron-shrike/sistema-gestion-productos/blob/main/ReglasNegocio/RNLocal.cs"
    click RN5 "https://github.com/aaron-shrike/sistema-gestion-productos/blob/main/ReglasNegocio/RNMarca.cs"
    click RN6 "https://github.com/aaron-shrike/sistema-gestion-productos/blob/main/ReglasNegocio/RNPersonal.cs"
    click RN7 "https://github.com/aaron-shrike/sistema-gestion-productos/blob/main/ReglasNegocio/RNPrecioLocal.cs"
    click RN8 "https://github.com/aaron-shrike/sistema-gestion-productos/blob/main/ReglasNegocio/RNUsuario.cs"
    click RNConf "https://github.com/aaron-shrike/sistema-gestion-productos/blob/main/ReglasNegocio/app.config"
    click DALcs "https://github.com/aaron-shrike/sistema-gestion-productos/blob/main/DAL/DAL.cs"
    click DALproj "https://github.com/aaron-shrike/sistema-gestion-productos/blob/main/DAL/DAL.csproj"
    click DALAsm "https://github.com/aaron-shrike/sistema-gestion-productos/blob/main/DAL/Properties/AssemblyInfo.cs"
    click E1 "https://github.com/aaron-shrike/sistema-gestion-productos/blob/main/Entidades/Producto.cs"
    click E2 "https://github.com/aaron-shrike/sistema-gestion-productos/blob/main/Entidades/Categoria.cs"
    click E3 "https://github.com/aaron-shrike/sistema-gestion-productos/blob/main/Entidades/Empresa.cs"
    click E4 "https://github.com/aaron-shrike/sistema-gestion-productos/blob/main/Entidades/Local.cs"
    click E5 "https://github.com/aaron-shrike/sistema-gestion-productos/blob/main/Entidades/Marca.cs"
    click E6 "https://github.com/aaron-shrike/sistema-gestion-productos/blob/main/Entidades/Personal.cs"
    click E7 "https://github.com/aaron-shrike/sistema-gestion-productos/blob/main/Entidades/PrecioLocal.cs"
    click E8 "https://github.com/aaron-shrike/sistema-gestion-productos/blob/main/Entidades/Usuario.cs"
    click Eproj "https://github.com/aaron-shrike/sistema-gestion-productos/blob/main/Entidades/Entidades.csproj"
    click EAsm "https://github.com/aaron-shrike/sistema-gestion-productos/blob/main/Entidades/Properties/AssemblyInfo.cs"

    %% Styles
    classDef frontend fill:#D0E4F5,stroke:#357ABD,color:#000
    classDef bll fill:#DFF5D0,stroke:#4CAF50,color:#000
    classDef dal fill:#FFE5B4,stroke:#FF9800,color:#000
    classDef database fill:#CCCCCC,stroke:#888,color:#000
    classDef shared fill:#F5E6D0,stroke:#FFC107,color:#000
    classDef dependency fill:#E1D4F0,stroke:#9C27B0,color:#000
    classDef config fill:#F0F0F0,stroke:#555,color:#000
    classDef note fill:#FFF3E0,stroke:#FFA726,color:#000
```
