# jve386/cescit_erptextil architecture

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

- Interactive diagram: https://gitdiagram.com/jve386/cescit_erptextil
- Repository: https://github.com/jve386/cescit_erptextil

## Overview

##### Project Overview
- This is a full-stack ERP system designed for a textile enterprise.
- It combines a Spring Boot-based backend (in Java) that provides RESTful APIs and a Quasar (Vue.js) frontend that acts as the user interface.
- The system integrates with a PostgreSQL (or MySQL) database and is deployable using Docker Compose.

##### Main Components to Highlight
a. Frontend (Quasar/Vue.js):
- Location: quasar-project directory.
- Components include various pages (e.g., AgregarStockPage, ConsultarStockPage, etc.), layouts (MainLayout), and reusable Vue components.
- Important libraries: Pinia for state management, vee-validate for validation, date-fns, echarts, vue-echarts, vue-i18n.
- Role: Provides a responsive, modern UI, interacts with the backend API for data operations.

b. Backend (Spring Boot):
- Location: src/main/java/com/tiendatextil.
- Organized using a layered architecture:
- Controllers: Handle HTTP requests for various entities (Almacen, Articulo, Categoria, Cliente, etc.).
- Services: Implement business logic.
- Repositories: Abstract data access (integrated with PostgreSQL/MySQL).
- DTOs and Models: Define data structures exchanged between controllers and services.
- Additional configurations: Security (JWT authentication), validation, and Flyway for database migrations.

c. Database:
- Technology: PostgreSQL (or MySQL as mentioned in the README).

d. Infrastructure / Deployment:
- Docker support: Docker Compose setup is available for easy deployment.
- Additional scripts: wait-for-it.sh for handling service dependencies at startup.

e. API Testing / Collections:
- Collections (in the collections folder) indicate that Postman (or similar) collections are used for testing API endpoints.

##### Relationships & Data Flow
- The frontend sends API requests (HTTP/HTTPS) to the backend REST controllers.
- The backend controllers call the appropriate service methods to process the business logic.
- The services interact with the repository layer to read/write data from the database.
- Authentication, authorization, and validation occur at various stages in the backend.
- Docker containers can be used to encapsulate the frontend, backend, and database components, with defined dependencies and network flows among them.

##### Architectural Patterns & Design Principles
- Layered Architecture: Clear separation into UI (frontend), API Controllers, Business Services, Data Repositories, and Database.
- MVC Pattern: Evident in the Quasar/Vue.js structure where components, layouts, and pages are separated.
- RESTful API Design: Controllers expose endpoints and interact via JSON.
- Microservices’ influence is minimal here; the design is more monolithic but well-layered.
- Use of JWT and Spring Security adds an authentication/authorization layer, which should be represented.
- Integration points (e.g., external services and Docker orchestration).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Frontend Layer"
        FE["Frontend (Quasar/Vue.js)"]:::frontend
        FE_Pages["Frontend Pages"]:::frontend
        FE_Layout["Main Layout"]:::frontend
    end

    %% Backend Layer
    subgraph "Backend Layer"
        BE["Backend (Spring Boot)"]:::backend
        BE_Control["REST API Controllers"]:::backend
        BE_Service["Service Layer"]:::backend
        BE_Repo["Repository Layer"]:::backend
        BE_Models["Models"]:::backend
        BE_DTO["DTOs"]:::backend
    end

    %% Database Layer
    subgraph "Database Layer"
        DB["Database (PostgreSQL/MySQL)"]:::database
    end

    %% Deployment & Testing
    subgraph "Deployment & Testing"
        DOCKER["Docker Compose"]:::infrastructure
        WAIT["wait-for-it.sh"]:::infrastructure
        API_TEST["API Testing Collections"]:::infrastructure
    end

    %% Relationships & Data Flow
    FE_Pages -->|"sendsAPIRequest"| BE_Control
    FE_Layout -->|"sendsAPIRequest"| BE_Control
    BE --> BE_Control
    BE_Control -->|"calls"| BE_Service
    BE_Service -->|"invokes"| BE_Repo
    BE_Repo -->|"queries"| DB
    BE_Service -->|"uses"| BE_Models
    BE_Service -->|"uses"| BE_DTO
    API_TEST -->|"tests"| BE_Control

    DOCKER -->|"deploys"| FE
    DOCKER -->|"deploys"| BE
    DOCKER -->|"deploys"| DB
    WAIT -->|"ensuresReadiness"| DOCKER

    %% Click Events
    click FE "https://github.com/jve386/cescit_erptextil/tree/main/quasar-project"
    click FE_Pages "https://github.com/jve386/cescit_erptextil/tree/main/quasar-project/src/pages"
    click FE_Layout "https://github.com/jve386/cescit_erptextil/blob/main/quasar-project/src/layouts/MainLayout.vue"
    click BE "https://github.com/jve386/cescit_erptextil/tree/main/src/main/java/com/tiendatextil"
    click BE_Control "https://github.com/jve386/cescit_erptextil/tree/main/src/main/java/com/tiendatextil/controller"
    click BE_Service "https://github.com/jve386/cescit_erptextil/tree/main/src/main/java/com/tiendatextil/service"
    click BE_Repo "https://github.com/jve386/cescit_erptextil/tree/main/src/main/java/com/tiendatextil/repository"
    click BE_Models "https://github.com/jve386/cescit_erptextil/tree/main/src/main/java/com/tiendatextil/model"
    click BE_DTO "https://github.com/jve386/cescit_erptextil/tree/main/src/main/java/com/tiendatextil/dto"
    click DB "https://github.com/jve386/cescit_erptextil/tree/main/assets/screens"
    click WAIT "https://github.com/jve386/cescit_erptextil/blob/main/wait-for-it.sh"
    click API_TEST "https://github.com/jve386/cescit_erptextil/tree/main/collections"

    %% Styles
    classDef frontend fill:#F9E79F,stroke:#F39C12,stroke-width:2px,color:black;
    classDef backend fill:#AED6F1,stroke:#3498DB,stroke-width:2px,color:black;
    classDef database fill:#ABEBC6,stroke:#28B463,stroke-width:2px,color:black;
    classDef infrastructure fill:#F5B7B1,stroke:#E74C3C,stroke-width:2px,color:black;
```
