# jhan7two/sistema_vidrieria architecture

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

- Interactive diagram: https://gitdiagram.com/jhan7two/sistema_vidrieria
- Repository: https://github.com/jhan7two/sistema_vidrieria

## Overview

##### Project Type and Purpose
- This is a full-stack web application (“Sistema Vidriería”) for managing a glassworks business.
- The backend (Node.js + Express) provides a REST API and database access; the frontend (Vue.js) delivers a single-page application (SPA) UI.

##### File Structure Analysis
- Top-level directories: `/backend` and `/frontend`.
- Backend:
- `config/` (DB and server configuration)
- `models/` (Sequelize or similar ORM entities + associations)
- `controllers/` (business logic for entities: user, cliente, venta, etc.)
- `routes/` (Express endpoints exposing controllers)
- `middlewares/` (authentication)
- `utils/` (helper functions)
- Frontend:
- `src/components/` (Vue components, organized by feature and layout)
- `src/views/` (page-level Vue views grouped by route)
- `src/router/` (Vue Router setup)
- `src/store/` (Vuex or Pinia stores)
- `src/services/` (API wrappers)
- `assets/` and `styles/` for static CSS

##### README Insights
- Confirms a REST-based backend and Vue-based SPA.
- Lists primary features: client, sales, inventory, authentication.

a. Frontend SPA (Vue.js + Vue Router + Vuex)
b. Backend API (Node.js + Express + Controllers + Models)
c. Database (e.g., MySQL/PostgreSQL via ORM)
d. External services (authentication middleware, possibly third-party email/SMS)

##### Relationships and Interactions
- The user’s browser hosts the SPA.
- SPA → API calls (JSON over HTTP/HTTPS) to backend routes (e.g., `/api/ventas`).
- Backend → ORM → Database for CRUD operations.
- Auth middleware protects certain endpoints; optionally integrate OAuth/JWT.
- (Optional) External notifications or reporting services.

##### Architectural Patterns
- MVC-ish on the backend: Controllers ↔ Models ↔ Routes.
- Service layer on the frontend: Components → Services → API → Store → Components.
- Stateless REST API, token-based authentication.

##### Technologies & Frameworks
- Backend: Node.js, Express, Sequelize (or similar), JWT or session middleware, YAML/K8s config (render.yaml).
- Frontend: Vue.js (v3), Vue Router, Vuex/Pinia, Vite, Tailwind CSS.
- Database: Relational (MySQL/PostgreSQL).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Frontend SPA" 
        direction TB
        UserBrowser["User Browser"]:::external
        MainJS["SPA Entry (main.js)"]:::frontend
        Router["Vue Router"]:::frontend
        Components["Vue Components"]:::frontend
        AuthLoginForm["LoginForm.vue"]:::frontend
        AuthLayout["AuthLayout.vue"]:::frontend
        AuthView["LoginUser View"]:::frontend
        MainLayout["MainLayout.vue"]:::frontend
        StoreAuth["Auth Store"]:::frontend
        Services["Domain Services"]:::frontend
        APIService["API Service (api.js)"]:::frontend
        UtilsFE["Date Utils"]:::frontend
    end

    %% Domain Services breakdown
    subgraph "Services" 
        direction TB
        ClienteService["clienteService.js"]:::frontend
        VentaService["ventasService.js"]:::frontend
        CobroService["cobroService.js"]:::frontend
        CajaService["cajaService.js"]:::frontend
        GastoService["gastosService.js"]:::frontend
        TrabajoService["trabajoService.js"]:::frontend
        UserService["user.service.js"]:::frontend
        DashboardService["dashboardService.js"]:::frontend
    end

    %% Backend Layer
    subgraph "Backend API" 
        direction TB
        Server["server.js"]:::backend
        ConfigDB["DB Config (database.js)"]:::backend
        ConfigSrv["Server Config (config.js)"]:::backend
        RenderCfg["render.yaml"]:::backend
        AuthMiddleware["Auth Middleware"]:::backend
        subgraph "Routes"
            direction TB
            AuthRoutes["authRoutes.js"]:::backend
            ClienteRoutes["clienteRoutes.js"]:::backend
            VentaRoutes["ventaRoutes.js"]:::backend
            CobroRoutes["cobroRoutes.js"]:::backend
            CajaRoutes["cajaRoutes.js"]:::backend
            GastoRoutes["gastoRoutes.js"]:::backend
            TrabajoRoutes["trabajoRoutes.js"]:::backend
            UserRoutes["userRoutes.js"]:::backend
        end
        subgraph "Controllers"
            direction TB
            AuthCtrl["authController.js"]:::backend
            ClienteCtrl["clienteController.js"]:::backend
            VentaCtrl["ventaController.js"]:::backend
            CobroCtrl["cobroController.js"]:::backend
            CajaCtrl["cajaController.js"]:::backend
            GastoCtrl["gastoController.js"]:::backend
            TrabajoCtrl["trabajoController.js"]:::backend
            UserCtrl["userController.js"]:::backend
        end
        subgraph "Models"
            direction TB
            ModelsDir["Models Directory"]:::backend
            Assoc["associations.js"]:::backend
        end
        UtilsBE["Backend Utils"]:::backend
    end

    %% Database
    subgraph "Database"
        DB["Relational DB"]:::db
    end

    %% Frontend Connections
    UserBrowser -->|"loads SPA"| MainJS
    MainJS -->|"initializes"| Router
    Router -->|"routes to"| AuthView
    AuthView -->|"uses"| AuthLoginForm
    AuthView -->|"wraps in"| AuthLayout
    Router -->|"routes to"| MainLayout
    MainLayout --> Components
    Components --> Services
    Services --> APIService
    APIService -->|"HTTP JSON"| AuthRoutes
    APIService -->|"HTTP JSON"| ClienteRoutes
    APIService -->|"HTTP JSON"| VentaRoutes
    APIService -->|"HTTP JSON"| CobroRoutes
    APIService -->|"HTTP JSON"| CajaRoutes
    APIService -->|"HTTP JSON"| GastoRoutes
    APIService -->|"HTTP JSON"| TrabajoRoutes
    APIService -->|"HTTP JSON"| UserRoutes
    Components --> StoreAuth
    Components --> UtilsFE

    %% Backend Connections
    AuthRoutes -->|"protect"| AuthMiddleware
    ClienteRoutes -->|"protect"| AuthMiddleware
    VentaRoutes --> AuthMiddleware
    CobroRoutes --> AuthMiddleware
    CajaRoutes --> AuthMiddleware
    GastoRoutes --> AuthMiddleware
    TrabajoRoutes --> AuthMiddleware
    UserRoutes --> AuthMiddleware

    AuthRoutes --> AuthCtrl
    ClienteRoutes --> ClienteCtrl
    VentaRoutes --> VentaCtrl
    CobroRoutes --> CobroCtrl
    CajaRoutes --> CajaCtrl
    GastoRoutes --> GastoCtrl
    TrabajoRoutes --> TrabajoCtrl
    UserRoutes --> UserCtrl

    AuthCtrl --> ModelsDir
    ClienteCtrl --> ModelsDir
    VentaCtrl --> ModelsDir
    CobroCtrl --> ModelsDir
    CajaCtrl --> ModelsDir
    GastoCtrl --> ModelsDir
    TrabajoCtrl --> ModelsDir
    UserCtrl --> ModelsDir

    ModelsDir --> Assoc
    ModelsDir --> DB
    ConfigDB --> DB
    Server --> ConfigSrv
    Server --> ConfigDB
    Server --> RenderCfg
    Server --> AuthRoutes
    UtilsBE --> AuthCtrl
    UtilsBE --> ClienteCtrl

    %% Click Events
    click MainJS "https://github.com/jhan7two/sistema_vidrieria/blob/main/frontend/src/main.js"
    click Router "https://github.com/jhan7two/sistema_vidrieria/blob/main/frontend/src/router/index.js"
    click Components "https://github.com/jhan7two/sistema_vidrieria/tree/main/frontend/src/components"
    click AuthLoginForm "https://github.com/jhan7two/sistema_vidrieria/blob/main/frontend/src/components/auth/login-form.vue"
    click AuthLayout "https://github.com/jhan7two/sistema_vidrieria/blob/main/frontend/src/layouts/auth-layout.vue"
    click AuthView "https://github.com/jhan7two/sistema_vidrieria/blob/main/frontend/src/views/auth/login-user.vue"
    click MainLayout "https://github.com/jhan7two/sistema_vidrieria/blob/main/frontend/src/layouts/main-layout.vue"
    click StoreAuth "https://github.com/jhan7two/sistema_vidrieria/blob/main/frontend/src/store/auth.js"
    click APIService "https://github.com/jhan7two/sistema_vidrieria/blob/main/frontend/src/services/api.js"
    click ClienteService "https://github.com/jhan7two/sistema_vidrieria/blob/main/frontend/src/services/clienteService.js"
    click VentaService "https://github.com/jhan7two/sistema_vidrieria/blob/main/frontend/src/services/ventasService.js"
    click CobroService "https://github.com/jhan7two/sistema_vidrieria/blob/main/frontend/src/services/cobroService.js"
    click CajaService "https://github.com/jhan7two/sistema_vidrieria/blob/main/frontend/src/services/cajaService.js"
    click GastoService "https://github.com/jhan7two/sistema_vidrieria/blob/main/frontend/src/services/gastosService.js"
    click TrabajoService "https://github.com/jhan7two/sistema_vidrieria/blob/main/frontend/src/services/trabajoService.js"
    click UserService "https://github.com/jhan7two/sistema_vidrieria/blob/main/frontend/src/services/user.service.js"
    click DashboardService "https://github.com/jhan7two/sistema_vidrieria/blob/main/frontend/src/services/dashboardService.js"
    click UtilsFE "https://github.com/jhan7two/sistema_vidrieria/blob/main/frontend/src/utils/dateUtils.js"

    click Server "https://github.com/jhan7two/sistema_vidrieria/blob/main/backend/server.js"
    click ConfigSrv "https://github.com/jhan7two/sistema_vidrieria/blob/main/backend/config/config.js"
    click ConfigDB "https://github.com/jhan7two/sistema_vidrieria/blob/main/backend/config/database.js"
    click RenderCfg "https://github.com/jhan7two/sistema_vidrieria/blob/main/backend/render.yaml"
    click AuthMiddleware "https://github.com/jhan7two/sistema_vidrieria/blob/main/backend/middlewares/authMiddleware.js"
    click ModelsDir "https://github.com/jhan7two/sistema_vidrieria/tree/main/backend/models"
    click Assoc "https://github.com/jhan7two/sistema_vidrieria/blob/main/backend/models/associations.js"
    click AuthCtrl "https://github.com/jhan7two/sistema_vidrieria/blob/main/backend/controllers/authController.js"
    click ClienteCtrl "https://github.com/jhan7two/sistema_vidrieria/blob/main/backend/controllers/clienteController.js"
    click VentaCtrl "https://github.com/jhan7two/sistema_vidrieria/blob/main/backend/controllers/ventaController.js"
    click CobroCtrl "https://github.com/jhan7two/sistema_vidrieria/blob/main/backend/controllers/cobroController.js"
    click CajaCtrl "https://github.com/jhan7two/sistema_vidrieria/blob/main/backend/controllers/cajaController.js"
    click GastoCtrl "https://github.com/jhan7two/sistema_vidrieria/blob/main/backend/controllers/gastoController.js"
    click TrabajoCtrl "https://github.com/jhan7two/sistema_vidrieria/blob/main/backend/controllers/trabajoController.js"
    click UserCtrl "https://github.com/jhan7two/sistema_vidrieria/blob/main/backend/controllers/userController.js"
    click AuthRoutes "https://github.com/jhan7two/sistema_vidrieria/blob/main/backend/routes/authRoutes.js"
    click ClienteRoutes "https://github.com/jhan7two/sistema_vidrieria/blob/main/backend/routes/clienteRoutes.js"
    click VentaRoutes "https://github.com/jhan7two/sistema_vidrieria/blob/main/backend/routes/ventaRoutes.js"
    click CobroRoutes "https://github.com/jhan7two/sistema_vidrieria/blob/main/backend/routes/cobroRoutes.js"
    click CajaRoutes "https://github.com/jhan7two/sistema_vidrieria/blob/main/backend/routes/cajaRoutes.js"
    click GastoRoutes "https://github.com/jhan7two/sistema_vidrieria/blob/main/backend/routes/gastoRoutes.js"
    click TrabajoRoutes "https://github.com/jhan7two/sistema_vidrieria/blob/main/backend/routes/trabajoRoutes.js"
    click UserRoutes "https://github.com/jhan7two/sistema_vidrieria/blob/main/backend/routes/userRoutes.js"
    click UtilsBE "https://github.com/jhan7two/sistema_vidrieria/tree/main/backend/utils"

    %% Styles
    classDef frontend fill:#1e3a8a,stroke:#60a5fa,color:#f8fafc;
    classDef backend fill:#064e3b,stroke:#34d399,color:#f8fafc;
    classDef db fill:#78350f,stroke:#fbbf24,color:#f8fafc;
    classDef external fill:#374151,stroke:#9ca3af,color:#f8fafc;
```
