# je7remy/sistema-inventario-farmacia architecture

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

- Interactive diagram: https://gitdiagram.com/je7remy/sistema-inventario-farmacia
- Repository: https://github.com/je7remy/sistema-inventario-farmacia

## Overview

##### Project Type and Main Purpose
- This is a full-stack desktop application built with C# using Visual Studio.
- It employs a multi-layer architecture with a Windows Forms-based user interface, a business logic layer (CapaNegocio), a data access layer (CapaDatos), and a back-end SQL Server database.
- The system is designed to manage product inventory, employee data, and inventory movements for a pharmacy.

##### File Structure
- Notice the separation into folders like CapaDatos and CapaNegocio that indicate a layered architecture.
- The presence of multiple “Sistema Inventario” files (including Windows Forms (.cs, .Designer.cs, .resx)) shows that the UI is implemented as a Windows Forms application.
- Database files and SQL scripts (e.g., DBInventario.mdf, SQL scripts for product/category/employee insertions) emphasize a reliance on SQL Server as the data store.
- There is also integration for reporting (with Microsoft ReportingServices packages) which should be shown as an external reporting component or service.

##### Main Components
a. Presentation Layer:
- Windows Forms User Interface – Screens, menus (Mantenimientos, Procesos, Consultas, Reportes, Seguridad).
- “form” elements such as Login, Bienvenida, Gestión de Productos, etc.
b. Business Logic Layer:
- CapaNegocio – Handles business rules and operations (validations, processing of inventory entries/exits, etc.).
c. Data Access Layer:
- CapaDatos – Manages CRUD operations, database connection logic (using InventarioConexion.cs and direct interactions with the SQL Server database).
d. Database:
- SQL Server database that stores entities: Productos, Empleados, Movimientos de Inventario, and Categorías.
e. External Services and Utilities:
- Reporting Services through Microsoft.ReportingServices.ReportViewer for generating detailed reports.
- SQL scripts and backup utilities that support security and data resilience (backups, copias de seguridad).

##### Relationships and Data Flow
- The UI communicates user actions (e.g., product registration, movements) to the Business Logic Layer.
- CapaNegocio processes the user input, applies the needed business rules and then calls the Data Access Layer.
- CapaDatos interacts with the SQL Server database using direct queries or stored procedures.
- For report generation, data is extracted perhaps through the business logic or directly via report components, and then formatted and displayed through the reporting tools.
- Bidirectional interactions where necessary (for example, confirmation messages flowing back from CapaNegocio to the UI).

##### Architectural Design Principles & Patterns
- Separation of Concerns: Clearly distinguish between presentation, business logic, and data access.
- External Dependencies: Highlight integration with SQL Server and reporting tools.

##### Final Touches
- Every component is detailed enough so that a principal software engineer can see the complete interaction flow.

¡Buena suerte con el diagrama y la presentación del sistema!

## Diagram (Mermaid)

```mermaid
graph TD
    %% Presentation Layer
    subgraph "Presentation Layer"
        UI["Windows Forms UI (Sistema Inventario)"]:::presentation
    end

    %% Business Logic Layer
    subgraph "Business Logic Layer"
        BL["Business Layer (CapaNegocio)"]:::business
    end

    %% Data Access Layer
    subgraph "Data Access Layer"
        DA["Data Access (CapaDatos)"]:::dataaccess
    end

    %% Database
    subgraph "Database"
        DB["SQL Server Database"]:::database
    end

    %% External Services
    subgraph "External Services"
        RS["Reporting Services"]:::reporting
    end

    %% Connections
    UI -->|"userAction"| BL
    BL -->|"processLogic"| DA
    DA -->|"CRUDOperations"| DB
    BL -->|"generateReports"| RS
    UI -->|"reportRequest"| RS

    %% Click Events
    click UI "https://github.com/je7remy/sistema-inventario-farmacia/tree/main/Sistema Inventario"
    click BL "https://github.com/je7remy/sistema-inventario-farmacia/tree/main/CapaNegocio"
    click DA "https://github.com/je7remy/sistema-inventario-farmacia/tree/main/CapaDatos"
    click DB "https://github.com/je7remy/sistema-inventario-farmacia/blob/main/CapaDatos/DBInventario.mdf"
    click RS "https://github.com/je7remy/sistema-inventario-farmacia/blob/main/packages/Microsoft.ReportingServices.ReportViewerControl.Winforms.150.1586.0"

    %% Styles
    classDef presentation fill:#ADD8E6,stroke:#000,stroke-width:2px;
    classDef business fill:#90EE90,stroke:#000,stroke-width:2px;
    classDef dataaccess fill:#FFA07A,stroke:#000,stroke-width:2px;
    classDef database fill:#D3D3D3,stroke:#000,stroke-width:2px;
    classDef reporting fill:#DDA0DD,stroke:#000,stroke-width:2px;
```
