# Sistema de Evaluación de Desempeño - Overview

This project is a comprehensive **Employee Performance Evaluation System** built with **Flask (Python)** and **PostgreSQL**. It automates the lifecycle of goal setting, grading, and HR oversight.

## 🏗️ Architecture Stack

- **Backend**: Flask 3.1, Flask-SQLAlchemy (PostgreSQL), Flask-Login (Authentication).
- **Frontend**: Jinja2 templates, Tailwind CSS (Styling), Vanilla JS (Dynamic AJAX updates).
- **Database**: PostgreSQL (handling complex relationships and `ARRAY` types).

---

## 🧭 Core Concept: The Evaluation Lifecycle

Evaluations are triggered per **Year** and **Trimester**. They are composed of two main components:

1.  **ODIs (Individual Performance Objectives)**: Personalized goals created and weighted by Supervisors for their subordinates.
2.  **Competencies**: Standardized skills (Soft Skills, Technical Skills) defined centrally.

### 🛡️ The "Capping" Logic (Business Rule)
One of the most critical parts of the backend (`app.py:get_evaluado_data`) is the score capping mechanism:
- If a user achieves a high score but has **not** completed required training courses (PDFs uploaded to `curso_personal`), their final score is **capped** at the maximum limit defined in the `escala` table for levels that do not require courses.

---

## 👤 User Roles & Workflows

| Role | Primary Responsibilities |
| :--- | :--- |
| **Administrator** | Full system oversight, user management, and raw database editing. |
| **Gerente** | Managing the company structure (Gerencias/Divisions) and assigning users to the correct departments. |
| **Supervisor** | The "Grader". Assigns ODIs/Competencies, gives scores (Rangos), and uploads course certificates for their team. |
| **Evaluado** | The "Employee". Views their final scores, reads feedback, and marks their status as "Agree" or "Disagree". |
| **Talento Humano** | Oversight. Specifically reviews cases where an Evaluado "Disagrees" with their score to add HR-level observations. |

---

## 📂 Key Files & Functions

- `app.py`: Entry point containing all route logic and the core scoring engine.
- `models.py`: The "source of truth" for the data schema (19+ tables).
- `forms.py`: Form validation and security.
- `sftp_sync.py`: Custom background worker for live server deployment.
