# enriquepabon/entrada_proveedores_oleo architecture

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

- Interactive diagram: https://gitdiagram.com/enriquepabon/entrada_proveedores_oleo
- Repository: https://github.com/enriquepabon/entrada_proveedores_oleo

## Overview

##### Project type and purpose
- TiquetesApp is a full-stack Flask web application for managing vehicle entry: registration (Entrada), weighing (Pesaje), classification (Clasificación), ticket/PDF generation, admin UI, and API/webhooks for integration.

##### File structure
- Top-level “app” folder uses Flask Blueprints (“entrada”, “pesaje”, “clasificacion”, “admin”, “api”, “misc”).
- “static” and “templates” for front-end assets and Jinja HTML templates.
- “app/utils” and “app/models” for business logic/helpers and SQLAlchemy models.
- Configuration in “config.py” and environment file.
- “run.py” / Makefile start the Flask server.
- External integration code under “scripts”, “utility_scripts” (webhooks, monitoring, migrations).

##### Key README insights
- Stack: Python 3.8+, Flask, SQLAlchemy, Pillow, possibly external image-classification service (e.g., Roboflow).
- Features: web UI + REST API + webhooks.
- Blueprints improve modularity and scalability.

##### Main components and interactions (to include
A. Client Layer
- Web Browser (users/admin) – submits HTTP(S) to web UI.
- External systems – consume/provide webhooks, REST API calls.
B. Web/API Layer
- Nginx (optional) → Gunicorn/WSGI → Flask App.
- Flask Blueprints:
– Entrada Blueprint (routes for entry registration)
– Pesaje Blueprint (vehicle weighing)
– Clasificación Blueprint (image capture & auto-classification logic)
– Admin Blueprint (user management, stats)
– API Blueprint (REST endpoints)
– Misc Blueprint (webhook listeners, auxiliary routes)
C. Business Logic & Data
- app/utils: image_processing, pdf_generator, db_operations, auth_utils, common helpers
- app/models: SQLAlchemy ORM mapping → Database
- File storage: uploads (images, temporary files), static assets, generated PDFs, templates
D. Persistence
- Relational Database (PostgreSQL/MySQL/SQLite via SQLAlchemy)
- File system or object store for images/PDFs
E. External Services
- Image classification service / ML model (local or external API)
- Webhook targets (third-party systems) for ticket, classification, weighing notifications

##### Architectural patterns & principles
- Modular MVC-style pattern via Flask Blueprints
- Separation of concerns:
- Presentation (templates/static)
- Controllers (routes in blueprints)
- Business logic (utils, models)
- Layered architecture:
- HTTP layer → Application layer → Data layer → External services

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Client Layer
    Browser["Web Browser"]:::frontend
    ExternalSystems["External Systems"]:::external

    %% HTTP Entry Point
    Nginx["Nginx / Gunicorn"]:::backend

    %% Application Layer
    subgraph "Flask App"
        direction TB
        Entrada["Entrada Blueprint"]:::backend
        Pesaje["Pesaje Blueprint"]:::backend
        PesajeNeto["Pesaje Neto Blueprint"]:::backend
        Clasificacion["Clasificación Blueprint"]:::backend
        Admin["Admin Blueprint"]:::backend
        API["API Blueprint"]:::backend
        Misc["Misc Blueprint"]:::backend
        Auth["Auth Blueprint"]:::backend

        subgraph "Utils & Models"
            direction TB
            Utils_image["image_processing"]:::backend
            Utils_pdf["pdf_generator"]:::backend
            Utils_db["db_operations"]:::backend
            Utils_auth["auth_utils"]:::backend
            Utils_common["common"]:::backend
            Models["User Model"]:::backend
        end
    end

    %% Data & Storage
    DB["Database (SQLAlchemy)"]:::storage
    FileStorage["File Storage\n(images, PDFs)"]:::storage

    %% External Services
    MLService["External ML Service"]:::external
    WebhookClients["Webhook Clients"]:::external

    %% Connections
    Browser -->|"HTTP request"| Nginx
    ExternalSystems -->|"REST API call / Webhook POST"| API
    Nginx -->|"WSGI call"| Entrada
    Nginx --> Pesaje
    Nginx --> PesajeNeto
    Nginx --> Clasificacion
    Nginx --> Admin
    Nginx --> API
    Nginx --> Misc
    Nginx --> Auth

    %% DB interactions
    Entrada -->|"SQL queries"| Utils_db
    Pesaje -->|"SQL queries"| Utils_db
    PesajeNeto -->|"SQL queries"| Utils_db
    API -->|"SQL queries"| Models
    Models -->|"ORM operations"| DB

    %% File I/O
    Entrada -->|"Read/write files"| FileStorage
    Clasificacion -->|"Capture image"| Utils_image
    Utils_image -->|"REST/SDK call"| MLService
    MLService -->|"Classification result"| Utils_image
    Clasificacion -->|"Generate PDF"| Utils_pdf
    Utils_pdf -->|"Write PDF"| FileStorage

    %% Auth & Common
    Auth --> Utils_auth
    Entrada --> Utils_common
    Pesaje --> Utils_common
    Clasificacion --> Utils_common

    %% Webhooks
    Misc -->|"Webhook POST"| WebhookClients

    %% Click Events
    click Entrada "https://github.com/enriquepabon/entrada_proveedores_oleo/blob/main/app/blueprints/entrada/routes.py"
    click Pesaje "https://github.com/enriquepabon/entrada_proveedores_oleo/blob/main/app/blueprints/pesaje/routes.py"
    click PesajeNeto "https://github.com/enriquepabon/entrada_proveedores_oleo/blob/main/app/blueprints/pesaje_neto/routes.py"
    click Clasificacion "https://github.com/enriquepabon/entrada_proveedores_oleo/blob/main/app/blueprints/clasificacion/routes.py"
    click Admin "https://github.com/enriquepabon/entrada_proveedores_oleo/blob/main/app/blueprints/admin/routes.py"
    click API "https://github.com/enriquepabon/entrada_proveedores_oleo/blob/main/app/blueprints/api/routes.py"
    click Misc "https://github.com/enriquepabon/entrada_proveedores_oleo/blob/main/app/blueprints/misc/routes.py"
    click Auth "https://github.com/enriquepabon/entrada_proveedores_oleo/blob/main/app/blueprints/auth/routes.py"
    click Utils_image "https://github.com/enriquepabon/entrada_proveedores_oleo/blob/main/app/utils/image_processing.py"
    click Utils_pdf "https://github.com/enriquepabon/entrada_proveedores_oleo/blob/main/app/utils/pdf_generator.py"
    click Utils_db "https://github.com/enriquepabon/entrada_proveedores_oleo/blob/main/app/utils/db_operations.py"
    click Utils_auth "https://github.com/enriquepabon/entrada_proveedores_oleo/blob/main/app/utils/auth_utils.py"
    click Utils_common "https://github.com/enriquepabon/entrada_proveedores_oleo/blob/main/app/utils/common.py"
    click Models "https://github.com/enriquepabon/entrada_proveedores_oleo/blob/main/app/models/user_model.py"
    click Browser "https://github.com/enriquepabon/entrada_proveedores_oleo/blob/main/run.py"
    click FileStorage "https://github.com/enriquepabon/entrada_proveedores_oleo/tree/main/app/static/"
    click DB "https://github.com/enriquepabon/entrada_proveedores_oleo/blob/main/config.py"

    %% Styles
    classDef frontend fill:#D0E8FF,stroke:#70A9E0,color:#000
    classDef backend fill:#DFFFD0,stroke:#70D040,color:#000
    classDef storage fill:#FFE5B4,stroke:#E09E45,color:#000
    classDef external fill:#E0E0E0,stroke:#A0A0A0,color:#000
```
