# acarias11/proyecto_disenio architecture

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

- Interactive diagram: https://gitdiagram.com/acarias11/proyecto_disenio
- Repository: https://github.com/acarias11/proyecto_disenio

## Overview

##### Main Components
- Entry Point: app.js (the server's main file that initializes the application).
- Configuration: The config directory contains database.js which handles database configuration/connection.
- Routing Layer: The routes directory (with auth.js and books.js) defines the endpoints and maps them to the right controllers.
- Controllers: The controllers directory (with auth.js and books.js) manages business logic.
- Models: The models directory (e.g., books.js) represents data schemas and interacts with the database.
- Middlewares: The middlewares folder (is_auth.js and is_admin.js) provides security/authorization checks.
- Schemas: The schemas folder defines additional validation or structure (schema.js).
- Utilities: The utils folder (response.js) likely provides helper functions to standardize API responses.
- Environment & Versioning: Files like .env.structure, .gitignore, package.json, and package-lock.json support configuration management and dependency tracking.
- API Testing: The file api.http suggests pre-configured HTTP requests for testing endpoints.

##### Relationships and Interactions
- app.js initializes the server, loads the configuration (database connection from config/database.js), and sets up the routes.
- The routes (in routes/auth.js and routes/books.js) define the URL endpoints and direct the requests to their corresponding controllers.
- Middlewares (is_auth.js and is_admin.js) are applied to relevant routes to enforce security, ensuring that only properly authenticated or authorized requests reach the controllers.
- Controllers (auth.js, books.js in the controllers directory) process the incoming requests, interact with models to read or write data, and finally send back a response formatted using the utilities (e.g., utils/response.js).
- Models (e.g., models/books.js) interact with the database, which is configured through config/database.js.

##### Architectural Patterns and Technologies
- MVC or Layered Architecture: Clearly separate routes, controllers, and models.
- Middleware Usage: Security and validation layers are built using middlewares.
- API Testing: The api.http file hints at integrated API testing and possibly using tools like REST Client in VSCode.
- Environment Configuration: Use of .env.structure suggests environment variable management.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph " "
        client["Client (API Consumer)"]:::clientClass
    end

    subgraph " "
        appEntry["Server: app.js (Entry Point)"]:::serverClass
    end

    client --> appEntry

    %% Configuration Branch
    appEntry --> configNode["Config: config/database.js"]:::configClass
    configNode --> db["Database"]:::dbClass

    %% Routing Branch
    appEntry --> authRoute["Auth Route: routes/auth.js"]:::routeClass
    appEntry --> booksRoute["Books Route: routes/books.js"]:::routeClass

    authRoute --> isAuthMiddle["Middleware: is_auth.js"]:::middlewareClass
    booksRoute --> isAdminMiddle["Middleware: is_admin.js"]:::middlewareClass

    isAuthMiddle --> authController["Controller: controllers/auth.js"]:::controllerClass
    isAdminMiddle --> booksController["Controller: controllers/books.js"]:::controllerClass

    %% Controllers Relationships
    booksController --> booksModel["Model: models/books.js"]:::modelClass
    booksModel --> db

    authController --> utilsComp["Utilities: utils/response.js"]:::utilClass
    booksController --> utilsComp

    authController --> schemaComp["Schemas: schemas/schema.js"]:::schemaClass
    booksController --> schemaComp

    %% Response Flow
    authController -->|"response"| appEntry
    booksController -->|"response"| appEntry
    appEntry -->|"response"| client

    %% Project Configuration and Testing Support
    subgraph "Project Config"
        envConf["Env Config (.env.structure)"]:::supportClass
        gitIgnore["Git Ignore (.gitignore)"]:::supportClass
        pkgJson["Package.json"]:::supportClass
        pkgLock["Package-lock.json"]:::supportClass
        apiTest["API Testing (api.http)"]:::supportClass
    end
    appEntry ---|"Uses"| pkgJson

    %% Click Events
    click appEntry "https://github.com/acarias11/proyecto_disenio/blob/main/app.js"
    click configNode "https://github.com/acarias11/proyecto_disenio/blob/main/config/database.js"
    click authRoute "https://github.com/acarias11/proyecto_disenio/blob/main/routes/auth.js"
    click booksRoute "https://github.com/acarias11/proyecto_disenio/blob/main/routes/books.js"
    click authController "https://github.com/acarias11/proyecto_disenio/blob/main/controllers/auth.js"
    click booksController "https://github.com/acarias11/proyecto_disenio/blob/main/controllers/books.js"
    click booksModel "https://github.com/acarias11/proyecto_disenio/blob/main/models/books.js"
    click isAuthMiddle "https://github.com/acarias11/proyecto_disenio/blob/main/middlewares/is_auth.js"
    click isAdminMiddle "https://github.com/acarias11/proyecto_disenio/blob/main/middlewares/is_admin.js"
    click schemaComp "https://github.com/acarias11/proyecto_disenio/blob/main/schemas/schema.js"
    click utilsComp "https://github.com/acarias11/proyecto_disenio/blob/main/utils/response.js"
    click envConf "https://github.com/acarias11/proyecto_disenio/blob/main/.env.structure"
    click gitIgnore "https://github.com/acarias11/proyecto_disenio/blob/main/.gitignore"
    click pkgJson "https://github.com/acarias11/proyecto_disenio/blob/main/package.json"
    click pkgLock "https://github.com/acarias11/proyecto_disenio/blob/main/package-lock.json"
    click apiTest "https://github.com/acarias11/proyecto_disenio/blob/main/api.http"

    %% Styles
    classDef clientClass fill:#AED6F1,stroke:#1B4F72,stroke-width:2px;
    classDef serverClass fill:#F9E79F,stroke:#B7950B,stroke-width:2px;
    classDef configClass fill:#D5F5E3,stroke:#1E8449,stroke-width:2px;
    classDef routeClass fill:#FAD7A0,stroke:#D35400,stroke-width:2px;
    classDef middlewareClass fill:#F5B7B1,stroke:#C0392B,stroke-width:2px;
    classDef controllerClass fill:#D2B4DE,stroke:#8E44AD,stroke-width:2px;
    classDef modelClass fill:#A9CCE3,stroke:#2471A3,stroke-width:2px;
    classDef utilClass fill:#FDEBD0,stroke:#E67E22,stroke-width:2px;
    classDef schemaClass fill:#D6EAF8,stroke:#2E86C1,stroke-width:2px;
    classDef dbClass fill:#FADBD8,stroke:#922B21,stroke-width:2px;
    classDef supportClass fill:#E8DAEF,stroke:#8E44AD,stroke-width:2px;
```
