# sandrac123/proyecto-de-desarrollo-de-aplicaciones-web architecture

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

- Interactive diagram: https://gitdiagram.com/sandrac123/proyecto-de-desarrollo-de-aplicaciones-web
- Repository: https://github.com/sandrac123/proyecto-de-desarrollo-de-aplicaciones-web

## Overview

##### Project Type and Purpose
- This is a full-stack web survey application (“Proyecto de Encuestas Web”) whose goal is to present survey forms in the browser, collect responses, authenticate users, and persist results in an SQL database.

##### Analysis of File Structure
- The actual file tree is flat (HTML forms, PHP scripts, a JS file, a CSS file, and a SQL dump).
- The README describes a more modular structure (separate `backend/`, `frontend/`, `database/` folders) built on Node.js/Express for the API and a modern JS front end—so be aware there’s a mismatch. Realize that:
- Frontend assets: `.html`, `style.css`, `uno.js`
- Backend endpoints: `.php` scripts (`guardarrespuestas.php`, etc.)
- Database schema: `web.sql`

##### Key Insights from the README
- Architecture goals: modularity, scalability, security, responsive UI.
- Tech stack: HTML5/CSS3/ES6+, optional React-style structure in theory, Node.js/Express (though sample code uses PHP), MySQL (or MongoDB/PostgreSQL), phpMyAdmin for admin.
- Intended layers:
- Frontend (client)
- Backend API (controllers, routes, business logic)
- Database layer (models, schema)
- Config & security (auth middleware, env vars)

a) Main Components
- Client Browser (mobile + desktop)
- Frontend Layer (HTML/CSS/JS or React components)
- Backend Application Server (Express.js + PHP scripts)
- Database Server (MySQL)
- External Services (e.g., phpMyAdmin, email gateway, third-party analytics)
b) Relationships & Data Flows
- Browser → HTTP(S) → Frontend (static assets)
- Frontend → AJAX/API calls → Backend Server
- Backend Server → SQL queries → Database
- Backend → External Services (e.g., send confirmation emails)
- Admin Tools (phpMyAdmin) → Database
c) Architectural Patterns & Principles
- MVC or layered architecture (separate controllers, models, routes).
- Modular file separation (`controllers/`, `models/`, `routes/`, `middlewares/`).
- Environment-based configuration (via `.env`).
- Secure authentication middleware before protected routes.
d) Technologies & Frameworks
- Frontend: HTML5, CSS3, JavaScript (ES6+), optionally React/Bootstrap
- Backend: Node.js with Express (and/or PHP runtime)
- Database: MySQL (script in `web.sql`)
- DevOps: Git, `.gitignore`, environment variables

##### Detail Is Key
- Every module or script that handles a distinct responsibility (e.g., `guardarrespuestas.php` for response storage, `resultados.php` for analytics).
- Environment/config files (`.env`) feeding into the backend.
- Don’t overcomplicate—separate into as many meaningful components as the project contains: static server, API logic, data persistence, and external integrations.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Layer
    Client["Client Browser\n(mobile & desktop)"]:::external

    %% Presentation Layer
    subgraph "Presentation Layer" 
        direction TB
        HTML_INDEX["index.html"]:::frontend
        HTML_INDEX2["index2.html"]:::frontend
        HTML_INDEX3["index3.html"]:::frontend
        HTML_PRINCIPAL["paginaprincipal.html"]:::frontend
        HTML_CREATE["formcrearenquisa.html"]:::frontend
        HTML_LOGIN["formlogin.html"]:::frontend
        HTML_QUESTIONS["formpreguntas.html"]:::frontend
        HTML_REGISTER["formrexistrousuarios.html"]:::frontend
        CSS["style.css"]:::frontend
        JS["uno.js"]:::frontend
    end

    %% Application Layer
    subgraph "Application Layer" 
        direction TB
        ENV[".env\n(config & secrets)"]:::backend
        Auth["Auth Middleware"]:::backend
        F_RESP["formularioderesposta.php"]:::backend
        G_RESP["guardarrespuestas.php"]:::backend
        G_RESP_EV["guardarrespuestas_evento.php"]:::backend
        G_RESP_ALT["guardarrespustas.php"]:::backend
        RESULTS["resultados.php"]:::backend
    end

    %% Data Layer
    subgraph "Data Layer"
        direction TB
        SQL_SCHEMA["web.sql\n(schema & seed)"]:::database
        MySQL["MySQL Database"]:::database
    end

    %% External Services
    subgraph "External Services"
        direction TB
        PHPADMIN["phpMyAdmin"]:::external
        EMAIL["Email Gateway"]:::external
        ANALYTICS["Third-Party Analytics"]:::external
    end

    %% Connections
    Client -->|"GET HTML/CSS/JS"| HTML_INDEX
    Client --> HTML_INDEX2
    Client --> HTML_INDEX3
    Client --> HTML_PRINCIPAL
    Client --> HTML_CREATE
    Client --> HTML_LOGIN
    Client --> HTML_QUESTIONS
    Client --> HTML_REGISTER
    Client --> CSS
    Client --> JS

    HTML_INDEX -->|"AJAX API Calls"| Auth
    HTML_INDEX2 --> Auth
    HTML_INDEX3 --> Auth
    HTML_PRINCIPAL --> Auth
    HTML_CREATE --> Auth
    HTML_LOGIN --> Auth
    HTML_QUESTIONS --> Auth
    HTML_REGISTER --> Auth
    JS --> Auth

    ENV --> Auth
    Auth --> F_RESP
    F_RESP --> G_RESP
    F_RESP --> G_RESP_EV
    F_RESP --> G_RESP_ALT
    G_RESP --> RESULTS
    G_RESP_EV --> RESULTS
    G_RESP_ALT --> RESULTS

    RESULTS -->|"SQL SELECT"| MySQL
    G_RESP -->|"SQL INSERT"| MySQL
    G_RESP_EV --> MySQL
    G_RESP_ALT --> MySQL
    F_RESP --> MySQL

    MySQL -->|"manage DB"| PHPADMIN

    Auth -.->|"send email"| EMAIL
    Auth -.->|"send analytics"| ANALYTICS
    F_RESP -.-> EMAIL
    RESULTS -.-> ANALYTICS

    %% Click Events for Frontend
    click HTML_INDEX "https://github.com/sandrac123/proyecto-de-desarrollo-de-aplicaciones-web/blob/main/formcrearenquisa.html"
    click HTML_CREATE "https://github.com/sandrac123/proyecto-de-desarrollo-de-aplicaciones-web/blob/main/formcrearenquisa.html"
    click HTML_LOGIN "https://github.com/sandrac123/proyecto-de-desarrollo-de-aplicaciones-web/blob/main/formlogin.html"
    click HTML_QUESTIONS "https://github.com/sandrac123/proyecto-de-desarrollo-de-aplicaciones-web/blob/main/formpreguntas.html"
    click HTML_REGISTER "https://github.com/sandrac123/proyecto-de-desarrollo-de-aplicaciones-web/blob/main/formrexistrousuarios.html"
    click HTML_INDEX "https://github.com/sandrac123/proyecto-de-desarrollo-de-aplicaciones-web/blob/main/index.html"
    click HTML_INDEX2 "https://github.com/sandrac123/proyecto-de-desarrollo-de-aplicaciones-web/blob/main/index2.html"
    click HTML_INDEX3 "https://github.com/sandrac123/proyecto-de-desarrollo-de-aplicaciones-web/blob/main/index3.html"
    click HTML_PRINCIPAL "https://github.com/sandrac123/proyecto-de-desarrollo-de-aplicaciones-web/blob/main/paginaprincipal.html"
    click CSS "https://github.com/sandrac123/proyecto-de-desarrollo-de-aplicaciones-web/blob/main/style.css"
    click JS "https://github.com/sandrac123/proyecto-de-desarrollo-de-aplicaciones-web/blob/main/uno.js"

    %% Click Events for Backend
    click F_RESP "https://github.com/sandrac123/proyecto-de-desarrollo-de-aplicaciones-web/blob/main/formularioderesposta.php"
    click G_RESP "https://github.com/sandrac123/proyecto-de-desarrollo-de-aplicaciones-web/blob/main/guardarrespuestas.php"
    click G_RESP_EV "https://github.com/sandrac123/proyecto-de-desarrollo-de-aplicaciones-web/blob/main/guardarrespuestas_evento.php"
    click G_RESP_ALT "https://github.com/sandrac123/proyecto-de-desarrollo-de-aplicaciones-web/blob/main/guardarrespustas.php"
    click RESULTS "https://github.com/sandrac123/proyecto-de-desarrollo-de-aplicaciones-web/blob/main/resultados.php"

    %% Click Events for Database
    click SQL_SCHEMA "https://github.com/sandrac123/proyecto-de-desarrollo-de-aplicaciones-web/blob/main/web.sql"

    %% Styles
    classDef frontend fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef backend fill:#90EE90,stroke:#333,stroke-width:1px
    classDef database fill:#FFA500,stroke:#333,stroke-width:1px
    classDef external fill:#D3D3D3,stroke:#333,stroke-width:1px
```
