# antonioperezblanco/proyecto architecture

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

- Interactive diagram: https://gitdiagram.com/antonioperezblanco/proyecto
- Repository: https://github.com/antonioperezblanco/proyecto

## Overview

##### Main Components
- Frontend: This is represented by the “frontend” directory and includes HTML pages, CSS styles, and static parts (e.g., the header).
- Backend: The “backend” directory contains the controllers, routes, models, and database connection (in “backend/database/db.js”). This is clearly a Node.js application serving RESTful endpoints.
- Database: The README instructs to install MongoDB, so this is your persistent storage.
- Node Server: “server.js” is the entry point that ties the front and back together.
- Scripts: The “scripts” folder contains client-side JavaScript (or possibly some coordination scripts) for handling interactions like search, creating events or users, and managing login sessions.

##### Establish Relationships and Data Flow
- The Frontend sends HTTP requests (likely via forms/Scripts) to the backend endpoints defined in “backend/routes” (e.g., fiestaRoutes.js and usuarioRoutes.js).
- The routes then invoke their respective controllers (in “backend/Controllers”) such as “busquedaController.js,” “crearUsuarioController.js,” “fiestaController.js,” and “inicioSesionController.js.”
- The controllers interact with the models (in “backend/models”) that represent entities like Fiesta, FiestaPrivada, Discoteca, and Usuario.
- The models finally communicate with MongoDB via the database connection defined in “backend/database/db.js.”
- The server in “server.js” coordinates these processes using middleware (likely built upon Express, given the structure) and handles the overall HTTP request lifecycle.

##### Architectural Patterns and Design Principles
- MVC Pattern: The separation between controllers, models, and routes suggests a Model-View-Controller (MVC) or a similar pattern on the backend.
- Layered Architecture: The design separates concerns between the presentation layer (frontend), the business logic layer (controllers, routes), and the data access layer (models and database).
- RESTful Communications: The use of routes and controllers indicates that RESTful API principles are in play.

##### Specify Technologies, Frameworks, and Libraries
- Node.js: Since the backend is structured with “server.js” and typical directories like controllers and routes.
- Express (assumed): Most Node.js web applications with this pattern use Express for routing and middleware.
- MongoDB: As noted by the README, MongoDB is used as a database.
- HTML/CSS/JavaScript: For the frontend, along with modular CSS and independent script files.

##### Putting It All Together
- Optionally, illustrate that the “scripts” folder contains JavaScript files that enhance the interactivity of the frontend.

## Diagram (Mermaid)

```mermaid
graph TD
    %% Frontend Layer
    subgraph "Frontend Layer"
        subgraph "HTML Templates"
            FE_HTML1["busqueda.html"]:::frontend
            FE_HTML2["CrearUsuario.html"]:::frontend
            FE_HTML3["InicioSesion.html"]:::frontend
        end
        subgraph "CSS Files"
            FE_CSS1["busqueda.css"]:::frontend
            FE_CSS2["fiesta.css"]:::frontend
            FE_CSS3["usuario.css"]:::frontend
        end
        subgraph "Client Scripts"
            FE_SCRIPT1["scriptBusqueda.js"]:::frontend
            FE_SCRIPT2["scriptCrearFiesta.js"]:::frontend
            FE_SCRIPT3["scriptCrearUsuario.js"]:::frontend
            FE_SCRIPT4["scriptInicioSesion.js"]:::frontend
        end
    end

    %% Backend Layer
    subgraph "Backend Layer"
        BE_Backend["Backend Directory"]:::backend
        BE_Server["Node Server (server.js)"]:::backend
        subgraph "API Layer"
            BE_Routes["API Routes"]:::backend
            subgraph "Routes"
                BE_ROUTE1["fiestaRoutes.js"]:::backend
                BE_ROUTE2["usuarioRoutes.js"]:::backend
            end
            BE_Controllers["Controllers"]:::backend
            subgraph "Controllers"
                BE_CTRL1["busquedaController.js"]:::backend
                BE_CTRL2["crearUsuarioController.js"]:::backend
                BE_CTRL3["fiestaController.js"]:::backend
                BE_CTRL4["inicioSesionController.js"]:::backend
            end
            BE_Models["Models"]:::backend
            subgraph "Models"
                BE_MODEL1["Discoteca.js"]:::backend
                BE_MODEL2["Fiesta.js"]:::backend
                BE_MODEL3["FiestaPrivada.js"]:::backend
                BE_MODEL4["Usuario.js"]:::backend
            end
            BE_DB["Database Connector"]:::backend
        end
    end

    %% Database
    DB["MongoDB"]:::database

    %% Frontend to Backend Connections
    FE_HTML1 -- "HTTP_request" --> BE_Server
    FE_HTML2 -- "HTTP_request" --> BE_Server
    FE_HTML3 -- "HTTP_request" --> BE_Server
    FE_SCRIPT1 -- "AJAX_request" --> BE_Server
    FE_SCRIPT2 -- "AJAX_request" --> BE_Server
    FE_SCRIPT3 -- "AJAX_request" --> BE_Server
    FE_SCRIPT4 -- "AJAX_request" --> BE_Server

    %% Backend Internal Flow
    BE_Backend --> BE_Server
    BE_Server -- "sends_request" --> BE_Routes
    BE_Routes -- "invokes" --> BE_Controllers
    BE_Controllers -- "queries" --> BE_Models
    BE_Models -- "accesses" --> BE_DB
    BE_DB -- "communicates_with" --> DB

    %% Click Events for Frontend
    click FE_HTML1 "https://github.com/antonioperezblanco/proyecto/blob/main/frontend/busqueda.html"
    click FE_HTML2 "https://github.com/antonioperezblanco/proyecto/blob/main/frontend/usuarios/CrearUsuario.html"
    click FE_HTML3 "https://github.com/antonioperezblanco/proyecto/blob/main/frontend/usuarios/InicioSesion.html"
    click FE_CSS1 "https://github.com/antonioperezblanco/proyecto/tree/main/frontend/css"
    click FE_SCRIPT1 "https://github.com/antonioperezblanco/proyecto/blob/main/scripts/scriptBusqueda.js"
    click FE_SCRIPT2 "https://github.com/antonioperezblanco/proyecto/blob/main/scripts/scriptCrearFiesta.js"
    click FE_SCRIPT3 "https://github.com/antonioperezblanco/proyecto/blob/main/scripts/scriptCrearUsuario.js"
    click FE_SCRIPT4 "https://github.com/antonioperezblanco/proyecto/blob/main/scripts/scriptInicioSesion.js"

    %% Click Events for Backend
    click BE_Backend "https://github.com/antonioperezblanco/proyecto/tree/main/backend"
    click BE_Server "https://github.com/antonioperezblanco/proyecto/blob/main/server.js"
    click BE_Routes "https://github.com/antonioperezblanco/proyecto/tree/main/backend/routes"
    click BE_ROUTE1 "https://github.com/antonioperezblanco/proyecto/blob/main/backend/routes/fiestaRoutes.js"
    click BE_ROUTE2 "https://github.com/antonioperezblanco/proyecto/blob/main/backend/routes/usuarioRoutes.js"
    click BE_Controllers "https://github.com/antonioperezblanco/proyecto/tree/main/backend/Controllers"
    click BE_CTRL1 "https://github.com/antonioperezblanco/proyecto/blob/main/backend/Controllers/busquedaController.js"
    click BE_CTRL2 "https://github.com/antonioperezblanco/proyecto/blob/main/backend/Controllers/crearUsuarioController.js"
    click BE_CTRL3 "https://github.com/antonioperezblanco/proyecto/blob/main/backend/Controllers/fiestaController.js"
    click BE_CTRL4 "https://github.com/antonioperezblanco/proyecto/blob/main/backend/Controllers/inicioSesionController.js"
    click BE_Models "https://github.com/antonioperezblanco/proyecto/tree/main/backend/models"
    click BE_MODEL1 "https://github.com/antonioperezblanco/proyecto/blob/main/backend/models/Discoteca.js"
    click BE_MODEL2 "https://github.com/antonioperezblanco/proyecto/blob/main/backend/models/Fiesta.js"
    click BE_MODEL3 "https://github.com/antonioperezblanco/proyecto/blob/main/backend/models/FiestaPrivada.js"
    click BE_MODEL4 "https://github.com/antonioperezblanco/proyecto/blob/main/backend/models/Usuario.js"
    click BE_DB "https://github.com/antonioperezblanco/proyecto/blob/main/backend/database/db.js"

    %% Styles
    classDef frontend fill:#a3d2ca,stroke:#000,stroke-width:1px;
    classDef backend fill:#fce38a,stroke:#000,stroke-width:1px;
    classDef database fill:#f38181,stroke:#000,stroke-width:1px;
```
