Skip to main content

Prerequisites

Before running the system, ensure you have:
  • Python 3 installed
  • All dependencies installed: pip install -r requirements.txt
  • Input inventory file at data/inventario.xlsx
  • (Optional) Email credentials configured in .env file

Execution Command

From the project root directory, run:
python src/main.py
Make sure you’re in the project root directory (where src/ folder is located) before running the command.

Process Workflow

The system executes the following steps automatically (from src/main.py:14-40):
1

Load Inventory

Reads the inventory data from data/inventario.xlsx
df = cargar_inventario(RUTA_INVENTARIO)
Console Output:
✅ Inventario cargado correctamente
2

ABC Classification

Applies ABC classification based on monthly sales
df = clasificacion_abc(df)
Console Output:
✅ Clasificación ABC aplicada
3

Risk Evaluation

Evaluates stock levels and generates replenishment recommendations
df = evaluar_riesgo_y_reposicion(df)
Console Output:
✅ Riesgo evaluado y reposición recomendada
4

Generate Excel Report

Creates multi-sheet Excel report with complete inventory, critical products, and at-risk products
generar_reporte_excel(df, RUTA_REPORTE)
Console Output:
✅ Reporte Excel generado en output/reporte_inventario.xlsx
5

Generate Charts

Creates visualization charts for inventory status and ABC classification
generar_graficos(df, CARPETA_GRAFICOS)
Console Output:
✅ Gráficos generados correctamente
6

Send Email (Optional)

Sends the report via email if credentials are configured
enviar_reporte(EMAIL_REMITENTE, EMAIL_PASSWORD, 
               EMAIL_DESTINATARIO, RUTA_REPORTE)
Console Output (if configured):
✅ Reporte enviado por correo
Console Output (if not configured):
⚠️ Envío de correo omitido (credenciales no configuradas)

Complete Console Output Example

A successful execution displays:
 Inventario cargado correctamente
 Clasificación ABC aplicada
 Riesgo evaluado y reposición recomendada
 Reporte Excel generado en output/reporte_inventario.xlsx
 Gráficos generados correctamente
 Reporte enviado por correo
The checkmark (✅) emoji indicates successful completion of each step. The warning (⚠️) emoji indicates a non-critical issue (like email being skipped).

Understanding Console Messages

Success Indicators

MessageMeaningSource
✅ Inventario cargado correctamenteInventory file loaded successfullysrc/loader.py:10
✅ Clasificación ABC aplicadaABC classification completedsrc/analisis.py:30
✅ Riesgo evaluado y reposición recomendadaRisk analysis and recommendations generatedsrc/decisiones.py:29
✅ Reporte Excel generado en [path]Excel report created at specified pathsrc/reportes.py:31
✅ Gráficos generados correctamenteCharts created successfullysrc/reportes_graficos.py:32
✅ Reporte enviado por correoEmail sent successfullysrc/emailer.py:34

Warning Indicators

MessageMeaningAction Required
⚠️ Envío de correo omitido (credenciales no configuradas)Email credentials missing or invalidConfigure .env file with email credentials

Error Indicators

MessageMeaningAction Required
❌ Error al cargar inventario: [error]Failed to load input fileCheck that data/inventario.xlsx exists and is readable

Exit Codes

The system uses standard exit codes:
  • 0: Success - All operations completed successfully
  • Non-zero: Error - An exception occurred during execution
You can check the exit code in bash using echo $? immediately after running the script.

Execution Time

Typical execution times vary based on inventory size:
  • Small inventory (< 100 products): 1-2 seconds
  • Medium inventory (100-1000 products): 2-5 seconds
  • Large inventory (> 1000 products): 5-10 seconds
Email sending may add 2-5 additional seconds depending on network speed and attachment size.

Process Flow Diagram

Troubleshooting Common Issues

Cause: Input file doesn’t exist at the expected location.Solution:
  • Ensure data/inventario.xlsx exists in the project
  • Check the file path is correct
  • Verify you’re running from the project root directory
Cause: Output file is open in Excel or permissions issue.Solution:
  • Close the Excel file if it’s open
  • Check write permissions on the output/ directory
  • Try running with appropriate permissions
Cause: Required dependencies not installed.Solution:
pip install -r requirements.txt
Cause: Email credentials not properly configured.Solution:
  • Verify .env file exists and contains valid credentials
  • Check that variables don’t contain placeholder values
  • See the Email Setup Guide for detailed configuration

Automated Execution

You can automate the system execution using:

Cron (Linux/Mac)

Edit crontab:
crontab -e
Add a daily execution at 8 AM:
0 8 * * * cd /path/to/project && python src/main.py >> logs/execution.log 2>&1

Task Scheduler (Windows)

Create a scheduled task to run:
cd C:\path\to\project
python src\main.py
When scheduling automated execution, ensure the system has access to the .env file and that file paths are absolute or relative to the project root.

Next Steps

Understanding Outputs

Learn how to interpret the generated reports and charts

Email Setup

Configure email delivery for automated reporting

Build docs developers (and LLMs) love