# dan1el-m/tarea-programada-2-bd1 architecture

> Architecture diagram of the GitHub repository dan1el-m/tarea-programada-2-bd1, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-10-22). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/dan1el-m/tarea-programada-2-bd1
- Repository: https://github.com/dan1el-m/tarea-programada-2-bd1

## Overview

##### Project type and purpose
- This is a full-stack web application for employee and movement tracking with user authentication.
- The frontend is built in Vue.js (SPA), the backend is a Python API (likely Flask or FastAPI), and the database logic lives in SQL Server (stored procedures under the SPs/ directory).

##### File structure
- Top-level folders:
- SPs/ – SQL stored procedures for all CRUD operations, login/logout, bitacora logging.
- backend/ – Python API entrypoint (main.py) and dependencies (requirements.txt).
- frontend/ – Vue.js application (components, views, router, assets, package.json, Vite config).

##### Main components
a. Client (Web Browser)
- Renders the Vue.js SPA (index.html, App.vue, views: login, empleados, movimientos, components: EmpleadosForm, MovementModal, etc.)
- Uses axios.js to send HTTP requests.
b. Frontend Application
- Vue Router manages URL-to-view mapping.
- Components dispatch API calls to the backend.
c. API Layer (Backend)
- main.py exposes REST endpoints (e.g. /login, /empleados, /movimientos).
- Implements business logic and input validation.
- Translates HTTP requests into stored procedure calls.
d. Database Layer
- SQL Server (or compatible) hosting tables and SPs: SP_Login, SP_InsertarEmpleado, SP_ListarMoviminetosPorEmpleado, SP_Bitacora_Add, etc.
- Encapsulates all data operations in stored procedures.
e. (Optional) Logging/Auditing
- Bitacora stored procedures capture user actions.

##### Relationships and interactions
- Browser → Vue.js SPA (static assets loaded over HTTP/HTTPS).
- SPA → Backend API (over HTTP/HTTPS via axios).
- API → Database (calls stored procedures via a DB driver).
- Database → API (returns result sets / status codes).
- API → SPA (JSON responses for rendering).

##### Architectural patterns & design principles
- Separation of concerns: UI (Vue) vs. API (Python) vs. Data (DB).
- RESTful API design (endpoints map to CRUD operations).
- Stored-procedure-centric data layer for security and performance.
- Optional: token-based authentication or session management (SP_Login / SP_Logout).

##### Relevant technologies/frameworks
- Frontend: Vue.js 3, Vite, Vue Router, Axios
- Backend: Python (Flask or FastAPI, inferred), pip dependencies in requirements.txt
- Database: MS SQL Server or similar (T-SQL SPs)

##### Detail without over-complicating
- Every major component and interaction path (login, data retrieval, updates, logging).
- If desired, add notes about retry, error handling, or security (input validation, auth tokens).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Layer
    subgraph "Presentation Layer" 
        direction TB
        Browser["Web Browser\n(Vue.js SPA)"]:::frontend
        Browser -->|"Loads static assets"| Static[/"Static Assets"/]:::frontend
        Static -->|Includes| Index["index.html"]:::frontend
        Static -->|Includes| AppVue["App.vue"]:::frontend
        Static -->|Bootstrap| MainJS["main.js"]:::frontend
        Static -->|Styles & Assets| Assets[/"public/, src/assets/, style.css"/]:::frontend
        Browser -->|"User navigates"| Router["Vue Router\n(router.js)"]:::frontend
        Browser -->|"Makes HTTP calls via"| Axios["Axios Wrapper\n(axios.js)"]:::frontend
        subgraph "UI Components & Views"
            direction TB
            EmpleadosForm["EmpleadosForm.vue"]:::frontend
            MovementModal["MovementModal.vue"]:::frontend
            HelloWorld["HelloWorld.vue"]:::frontend
            LoginView["login.vue"]:::frontend
            EmpleadosView["empleados.vue"]:::frontend
            MovimientosView["movimientos.vue"]:::frontend
        end
    end

    %% Application Layer
    subgraph "Application Layer" 
        direction TB
        API["Python REST API"]:::backend
        API --> AuthService["Authentication Service"]:::backend
        API --> EmpService["Employee Service"]:::backend
        API --> MovService["Movement Service"]:::backend
        API --> LogService["Logging Service"]:::backend
    end

    %% Data Layer
    subgraph "Data Layer"
        direction TB
        DB[(SQL Server)]:::database
        DB --> AuthSPs["Authentication SPs"]:::dbsp
        DB --> EmpSPs["Employee SPs"]:::dbsp
        DB --> MovSPs["Movement SPs"]:::dbsp
        DB --> BigSP["Bitacora SP"]:::dbsp
        DB --> ErrSP["Error Handling SP"]:::dbsp

        subgraph "Authentication SPs"
            direction TB
            SP_Login["SP_Login.sql"]:::dbsp
            SP_Logout["SP_Logout.sql"]:::dbsp
            SP_CheckLoginDeshabilitado["SP_CheckLoginDeshabilitado.sql"]:::dbsp
            SP_AnadirUsuario["SP_AnadirUsuario.sql"]:::dbsp
        end
        subgraph "Employee SPs"
            direction TB
            SP_InsertarEmpleado["SP_InsertarEmpleado.sql"]:::dbsp
            SP_ActualizarEmpleado["SP_ActualizarEmpleado.sql"]:::dbsp
            SP_BorrarEmpleadoLogico["SP_BorrarEmpleadoLogico.sql"]:::dbsp
            SP_ListarEmpleados["SP_ListarEmpleados.sql"]:::dbsp
            SP_ConsultarEmpleado["SP_ConsultarEmpleado.sql"]:::dbsp
        end
        subgraph "Movement SPs"
            direction TB
            SP_InsertarMovimiento["SP_InsertarMovimiento.sql"]:::dbsp
            SP_ListarMoviminetosPorEmpleado["SP_ListarMoviminetosPorEmpleado.sql"]:::dbsp
            SP_CargarTodoDesdeXML_Fijo["SP_CargarTodoDesdeXML_Fijo.sql"]:::dbsp
        end
        SP_Bitacora_Add["SP_Bitacora_Add.sql"]:::dbsp
        SP_Error_Get["SP_Error_Get.sql"]:::dbsp
    end

    %% Interactions
    Browser -->|"HTTP/JSON via Axios"| API
    API -->|"T-SQL SP calls"| DB
    DB -->|"...Result Sets/Status"| API
    API -->|"JSON Response"| Browser

    %% Click Events
    click Index "https://github.com/dan1el-m/tarea-programada-2-bd1/blob/main/frontend/index.html"
    click AppVue "https://github.com/dan1el-m/tarea-programada-2-bd1/blob/main/frontend/src/App.vue"
    click MainJS "https://github.com/dan1el-m/tarea-programada-2-bd1/blob/main/frontend/src/main.js"
    click Router "https://github.com/dan1el-m/tarea-programada-2-bd1/blob/main/frontend/src/router.js"
    click Axios "https://github.com/dan1el-m/tarea-programada-2-bd1/blob/main/frontend/src/axios.js"
    click EmpleadosForm "https://github.com/dan1el-m/tarea-programada-2-bd1/blob/main/frontend/src/components/EmpleadosForm.vue"
    click MovementModal "https://github.com/dan1el-m/tarea-programada-2-bd1/blob/main/frontend/src/components/MovementModal.vue"
    click HelloWorld "https://github.com/dan1el-m/tarea-programada-2-bd1/blob/main/frontend/src/components/HelloWorld.vue"
    click LoginView "https://github.com/dan1el-m/tarea-programada-2-bd1/blob/main/frontend/src/views/login.vue"
    click EmpleadosView "https://github.com/dan1el-m/tarea-programada-2-bd1/blob/main/frontend/src/views/empleados.vue"
    click MovimientosView "https://github.com/dan1el-m/tarea-programada-2-bd1/blob/main/frontend/src/views/movimientos.vue"
    click Assets "https://github.com/dan1el-m/tarea-programada-2-bd1/tree/main/frontend/public/"
    click Assets "https://github.com/dan1el-m/tarea-programada-2-bd1/tree/main/frontend/src/assets/"
    click Assets "https://github.com/dan1el-m/tarea-programada-2-bd1/blob/main/frontend/src/style.css"
    click Static "https://github.com/dan1el-m/tarea-programada-2-bd1/blob/main/frontend/package.json"
    click Static "https://github.com/dan1el-m/tarea-programada-2-bd1/blob/main/frontend/package-lock.json"
    click Static "https://github.com/dan1el-m/tarea-programada-2-bd1/blob/main/frontend/vite.config.js"
    click API "https://github.com/dan1el-m/tarea-programada-2-bd1/blob/main/backend/main.py"
    click API "https://github.com/dan1el-m/tarea-programada-2-bd1/blob/main/backend/requirements.txt"
    click SP_Login "https://github.com/dan1el-m/tarea-programada-2-bd1/blob/main/SPs/SP_Login.sql"
    click SP_Logout "https://github.com/dan1el-m/tarea-programada-2-bd1/blob/main/SPs/SP_Logout.sql"
    click SP_CheckLoginDeshabilitado "https://github.com/dan1el-m/tarea-programada-2-bd1/blob/main/SPs/SP_CheckLoginDeshabilitado.sql"
    click SP_AnadirUsuario "https://github.com/dan1el-m/tarea-programada-2-bd1/blob/main/SPs/SP_AnadirUsuario.sql"
    click SP_InsertarEmpleado "https://github.com/dan1el-m/tarea-programada-2-bd1/blob/main/SPs/SP_InsertarEmpleado.sql"
    click SP_ActualizarEmpleado "https://github.com/dan1el-m/tarea-programada-2-bd1/blob/main/SPs/SP_ActualizarEmpleado.sql"
    click SP_BorrarEmpleadoLogico "https://github.com/dan1el-m/tarea-programada-2-bd1/blob/main/SPs/SP_BorrarEmpleadoLogico.sql"
    click SP_ListarEmpleados "https://github.com/dan1el-m/tarea-programada-2-bd1/blob/main/SPs/SP_ListarEmpleados.sql"
    click SP_ConsultarEmpleado "https://github.com/dan1el-m/tarea-programada-2-bd1/blob/main/SPs/SP_ConsultarEmpleado.sql"
    click SP_InsertarMovimiento "https://github.com/dan1el-m/tarea-programada-2-bd1/blob/main/SPs/SP_InsertarMovimiento.sql"
    click SP_ListarMoviminetosPorEmpleado "https://github.com/dan1el-m/tarea-programada-2-bd1/blob/main/SPs/SP_ListarMoviminetosPorEmpleado.sql"
    click SP_CargarTodoDesdeXML_Fijo "https://github.com/dan1el-m/tarea-programada-2-bd1/blob/main/SPs/SP_CargarTodoDesdeXML_Fijo.sql"
    click SP_Bitacora_Add "https://github.com/dan1el-m/tarea-programada-2-bd1/blob/main/SPs/SP_Bitacora_Add.sql"
    click SP_Error_Get "https://github.com/dan1el-m/tarea-programada-2-bd1/blob/main/SPs/SP_Error_Get.sql"

    %% Styles
    classDef frontend fill:#cce5ff,stroke:#333,stroke-width:1px
    classDef backend fill:#ccffcc,stroke:#333,stroke-width:1px
    classDef database fill:#f8d7da,stroke:#333,stroke-width:1px
    classDef dbsp fill:#f5c6cb,stroke:#333,stroke-width:1px
```
