# sandooo24/gestor-tareas-react architecture

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

- Interactive diagram: https://gitdiagram.com/sandooo24/gestor-tareas-react
- Repository: https://github.com/sandooo24/gestor-tareas-react

## Overview

##### Project Type and Purpose
- This is a full-stack task-management web application.
- Frontend: React (Vite) single-page app for creating, editing, listing tasks.
- Backend/API: Node.js + Express exposing REST endpoints secured by an API key middleware.
- Database: MySQL storing tasks schema defined in tareas.sql.

##### Key Components from File Structure
- Frontend (root + src + public):
- index.html, vite.config.js → Vite dev server config
- src/main.jsx → React app entry
- src/components/… → UI modules: Header, Formulario (create), FormEdit (update), CardTarea (display), Inicio (list), RequestApi (API service)
- src/css/index.css, src/assets → styling & static assets
- Backend/API (api/):
- api/index.js → Express app defining routes (GET, POST, PUT, DELETE /tasks)
- api/middleware/checkApiKey.js → API key validation layer
- api/.env → DB credentials (dotenv)
- Database:
- tareas.sql → schema + seed data for tasks table

##### Relationships & Data Flow
- Browser → (HTTP) → Vite Dev Server → serves React assets
- React components → (fetch/Axios) → Express API endpoints
- Express routes → (mysql2) → MySQL DB → return query results
- Middleware.checkApiKey sits on each API route to authorize requests

##### Architectural Patterns & Principles
- Layered Client-Server Architecture
- Presentation Layer (React SPA)
- Application Layer (Express REST API)
- Data Layer (MySQL)
- Separation of Concerns: UI components vs API logic vs DB access
- Middleware pattern in Express for cross-cutting concerns (security)
- Environment-based configuration (dotenv)

##### Detailed Elements to Capture
- React component modules & their roles (CardTarea, Formulario, etc.)
- Vite build/dev process
- Express route handlers and middleware chain
- MySQL connection pool/config via dotenv
- Data flow from user action → UI event → API call → DB transaction → UI update

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Global Entities
    Browser["User Browser"]:::external

    %% Frontend Layer
    subgraph "Frontend (React SPA)" 
        direction TB
        Vite["Vite Dev Server\n(port 5173)"]:::frontend
        IndexHTML["index.html"]:::frontend
        subgraph "React App" 
            direction TB
            Main["main.jsx"]:::frontend
            subgraph "src/components" 
                direction TB
                Header["Header.jsx"]:::frontend
                Formulario["Formulario.jsx"]:::frontend
                FormEdit["FormEdit.jsx"]:::frontend
                CardTarea["CardTarea.jsx"]:::frontend
                Inicio["Inicio.jsx"]:::frontend
                RequestApi["RequestApi.jsx"]:::frontend
            end
            CSS["src/css/index.css"]:::frontend
            Assets["src/assets"]:::frontend
        end
        Public["public/"]:::frontend
    end

    %% Backend Layer
    subgraph "Backend (Express API)" 
        direction TB
        Env[".env"]:::config
        API["index.js\n(Express App)"]:::backend
        Middleware["checkApiKey.js"]:::middleware
    end

    %% Database Layer
    MySQL["MySQL Database"]:::database
    SQLScript["tareas.sql"]:::database

    %% Connections
    Browser -->|GET /| Vite
    Vite -->|serves index.html + JS| Browser
    Vite -->|serves assets| IndexHTML
    IndexHTML --> Main
    Main --> Header
    Main --> Formulario
    Main --> FormEdit
    Main --> CardTarea
    Main --> Inicio
    Main --> RequestApi
    Main --> CSS
    Main --> Assets
    Main --> Public

    RequestApi -->|HTTP GET/POST/PUT/DELETE /api/tasks| API
    API -->|use| Middleware
    Middleware -->|proceed on valid key| API
    API -->|mysql2 TCP Query| MySQL
    MySQL -->|Result Sets| API
    API -->|JSON Response| RequestApi

    Env -->|provides DB creds| API
    SQLScript -->|initializes schema| MySQL

    %% Click Events
    click Vite "https://github.com/sandooo24/gestor-tareas-react/blob/main/vite.config.js"
    click IndexHTML "https://github.com/sandooo24/gestor-tareas-react/blob/main/index.html"
    click Main "https://github.com/sandooo24/gestor-tareas-react/blob/main/src/main.jsx"
    click CSS "https://github.com/sandooo24/gestor-tareas-react/blob/main/src/css/index.css"
    click Assets "https://github.com/sandooo24/gestor-tareas-react/tree/main/src/assets"
    click Header "https://github.com/sandooo24/gestor-tareas-react/blob/main/src/components/Header.jsx"
    click Formulario "https://github.com/sandooo24/gestor-tareas-react/blob/main/src/components/Formulario.jsx"
    click FormEdit "https://github.com/sandooo24/gestor-tareas-react/blob/main/src/components/FormEdit.jsx"
    click CardTarea "https://github.com/sandooo24/gestor-tareas-react/blob/main/src/components/CardTarea.jsx"
    click Inicio "https://github.com/sandooo24/gestor-tareas-react/blob/main/src/components/Inicio.jsx"
    click RequestApi "https://github.com/sandooo24/gestor-tareas-react/blob/main/src/components/RequestApi.jsx"
    click Public "https://github.com/sandooo24/gestor-tareas-react/tree/main/public/"
    click API "https://github.com/sandooo24/gestor-tareas-react/blob/main/api/index.js"
    click Middleware "https://github.com/sandooo24/gestor-tareas-react/blob/main/api/middleware/checkApiKey.js"
    click Env "https://github.com/sandooo24/gestor-tareas-react/blob/main/api/.env"
    click SQLScript "https://github.com/sandooo24/gestor-tareas-react/blob/main/tareas.sql"

    %% Styles
    classDef frontend fill:#D0E8FF,stroke:#0366d6,stroke-width:1px
    classDef backend fill:#DFFFE0,stroke:#28a745,stroke-width:1px
    classDef database fill:#FFE0B2,stroke:#e65100,stroke-width:1px
    classDef middleware fill:#F3E5F5,stroke:#6a1b9a,stroke-width:1px
    classDef config fill:#FFF3CD,stroke:#856404,stroke-width:1px
    classDef external fill:#E0F7FA,stroke:#006064,stroke-width:1px
```
