# victorniby/pixel-y-tinta architecture

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

- Interactive diagram: https://gitdiagram.com/victorniby/pixel-y-tinta
- Repository: https://github.com/victorniby/pixel-y-tinta

## Overview

##### Main Components
- Backend (API Service)
- MVC Structure: Show the segregation between controllers, models, and routes.
- Controllers (located in back/controllers): Responsible for processing requests, e.g., user and publication actions.
- Models (in back/models): Represent data entities like “usuario” (user), “publicacion” (publication), and “bd_conexion” (database connection logic).
- Routes (in back/routes): Define API endpoints that delegate work to controllers.
- Utility/Configuration: Files like back/index.js for server startup, using middleware packages (Nodemon, Cors, Jsonwebtoken, Bcryptjs, Multer) and the configuration (jsdoc.json) for documenting the API.
- Frontend
- Static HTML Files (in the “front” directory): Login, sign up, upload profile picture (pfp) pages.
- The “src” folder contains additional styling (CSS) and JavaScript functionalities (for login, sign up, and publication interactions), plus image assets.
- Documentation & Dev Tools
- The “back/docs” directory contains JSDoc-generated documentation along with CSS and scripts for styling the docs.

##### Component Interactions and Relationships
- Data Flow:
- Client (front-end HTML/CSS/JS) sends requests (e.g., log in, sign up, upload profile data) to the backend REST endpoints.
- The API routes defined in back/routes receive requests and pass them to the corresponding controllers.
- Controllers process the requests using business logic, interacting with the models for database operations.
- Responses are then sent back to the frontend.
- Database Interaction:
- Though not explicitly shown in a database directory, the presence of mongoose, bd_conexion, and related model files indicates integration with a MongoDB database.
- Authentication & Security:
- Use of Jsonwebtoken and Bcryptjs indicates that user authentication and password hashing are integral parts of the back-end logic.
- File Upload:
- The Multer package implies that parts of the backend are responsible for handling file uploads (e.g., profile picture uploads).

##### Highlighting Architectural Patterns/Design Principles
- RESTful API Architecture oriented around services.
- MVC Pattern for the backend—different layers (controllers, models, routes) are clearly segregated.
- Separation of Concerns: Distinct folders for backend logic, frontend presentations (both static and JS/CSS in “front” and “src”), and documentation.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Tier
    subgraph "Frontend Tier"
        subgraph "Static HTML"
            FE_index["Index Page"]:::frontend
            FE_login["Login Page"]:::frontend
            FE_sign["Sign Up Page"]:::frontend
            FE_upload["Upload PFP Page"]:::frontend
        end
        subgraph "Assets"
            FE_css["CSS Assets"]:::frontend
            FE_js["JavaScript Assets"]:::frontend
            FE_img["Image Assets"]:::frontend
        end
    end

    %% Client Browser Node
    CB["Client Browser"]:::frontend

    %% Backend Tier
    subgraph "Backend Tier"
        BA["Backend API Service"]:::backend
        subgraph "MVC Structure"
            subgraph "Routes"
                BR_usuario["User Routes"]:::backend
                BR_publicacion["Publication Routes"]:::backend
            end
            subgraph "Controllers"
                BC_usuario["User Controller"]:::backend
                BC_publicacion["Publication Controller"]:::backend
            end
            subgraph "Models"
                BM_usuario["Usuario Model"]:::backend
                BM_publicacion["Publication Model"]:::backend
                BM_bd["Database Connection"]:::backend
            end
        end
        UT["Utilities & Config"]:::backend
        subgraph "Documentation"
            DOC["API Documentation"]:::docs
            DOC_conf["JSDoc Config"]:::docs
        end
    end

    %% External Database
    D[("MongoDB Database")]:::database

    %% Connections between Frontend and Backend
    CB -->|"sendsRequest"| BR_usuario
    CB -->|"sendsRequest"| BR_publicacion

    %% Backend API Service mounts routes
    BA -->|"mounts"| BR_usuario
    BA -->|"mounts"| BR_publicacion

    %% Routes delegate to Controllers
    BR_usuario -->|"delegates"| BC_usuario
    BR_publicacion -->|"delegates"| BC_publicacion

    %% Controllers call Models
    BC_usuario -->|"calls"| BM_usuario
    BC_publicacion -->|"calls"| BM_publicacion

    %% Models interact with Database
    BM_usuario -->|"CRUD"| D
    BM_publicacion -->|"CRUD"| D
    BM_bd -->|"connectsTo"| D

    %% Utilities and Documentation
    BA -.->|"utilizes"| UT
    UT -.->|"generates"| DOC
    DOC -->|"includes"| DOC_conf

    %% Styles
    classDef frontend fill:#FDEDEC,stroke:#C0392B,stroke-width:2px;
    classDef backend fill:#EBF5FB,stroke:#2874A6,stroke-width:2px;
    classDef docs fill:#FCF3CF,stroke:#B7950B,stroke-width:2px;
    classDef database fill:#DEF3E5,stroke:#27AE60,stroke-width:2px;

    %% Click Events
    click BA "https://github.com/victorniby/pixel-y-tinta/blob/master/back/index.js"
    click BC_usuario "https://github.com/victorniby/pixel-y-tinta/blob/master/back/controllers/usuario.js"
    click BC_publicacion "https://github.com/victorniby/pixel-y-tinta/blob/master/back/controllers/publicacion.js"
    click BM_usuario "https://github.com/victorniby/pixel-y-tinta/blob/master/back/models/usuario.js"
    click BM_publicacion "https://github.com/victorniby/pixel-y-tinta/blob/master/back/models/publicacion.js"
    click BM_bd "https://github.com/victorniby/pixel-y-tinta/blob/master/back/models/bd_conexion.js"
    click BR_usuario "https://github.com/victorniby/pixel-y-tinta/blob/master/back/routes/usuario.js"
    click BR_publicacion "https://github.com/victorniby/pixel-y-tinta/blob/master/back/routes/publicacion.js"
    click DOC "https://github.com/victorniby/pixel-y-tinta/tree/master/back/docs"
    click DOC_conf "https://github.com/victorniby/pixel-y-tinta/blob/master/back/jsdoc.json"
    click FE_index "https://github.com/victorniby/pixel-y-tinta/blob/master/front/index.html"
    click FE_login "https://github.com/victorniby/pixel-y-tinta/blob/master/front/login/login.html"
    click FE_sign "https://github.com/victorniby/pixel-y-tinta/blob/master/front/sign_up/sign_up.html"
    click FE_upload "https://github.com/victorniby/pixel-y-tinta/blob/master/front/upload_pfp/upload_pfp.html"
    click FE_css "https://github.com/victorniby/pixel-y-tinta/tree/master/src/css"
    click FE_js "https://github.com/victorniby/pixel-y-tinta/tree/master/src/js"
    click FE_img "https://github.com/victorniby/pixel-y-tinta/tree/master/src/img"
```
