# nestorso/golden-skin-api architecture

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

- Interactive diagram: https://gitdiagram.com/nestorso/golden-skin-api
- Repository: https://github.com/nestorso/golden-skin-api

## Overview

##### Project type and purpose
- This is a lightweight full-stack web application built on Node.js and Express, with Microsoft SQL Server as its data store.
- It provides user registration and login pages (public/home.html, login.html, register.html) and implements business logic in controllers (controllers/userController.js) exposed via Express routes (routes/userRoutes.js). It also sends emails using Nodemailer and reads configuration from environment variables (.env).

##### File structure
- Top-level entry point: server.js
- Configuration layer: config/db.js (database connection via mssql and dotenv)
- Routing layer: routes/userRoutes.js
- Controller layer: controllers/userController.js
- Public/static assets: public/*.html, public/style.css, public/images
- SQL artifacts: GoldenSkin.sql, Procedimientos GD.sql
- Dependencies declared in package.json (express, mssql, dotenv, nodemailer, body-parser)

##### README for additional insights
- The README confirms use of express, mssql, dotenv, nodemailer, and basic instructions to run the server

##### Elements
- Clear labels: e.g., “Client Browser,” “Express Server,” “SQL Server,” “SMTP Service”
- Browser → Express (HTTP Request)
- Express → Routes → Controllers → DB → Controllers → Express → Browser
- Controllers → Nodemailer → SMTP Service
- Express → Public Folder → Browser (static file GET)
- Rectangles for software components (Express, Routes, Controllers)

##### Detailed capture of essential elements
- Environment/config (.env) should be shown feeding into the DB connection component
- If relevant, annotate patterns: “Data Access Layer,” “Business Logic Layer,” “Presentation Layer”

## Diagram (Mermaid)

```mermaid
graph TD
    %% Frontend Layer
    subgraph "Frontend Layer"
        direction TB
        Client["Client Browser"]:::client
        Public["Static Assets\n(public/)"]:::static
    end

    %% Backend Layer
    subgraph "Backend Layer"
        direction TB
        Express["Express Server\n(server.js)"]:::backend
        Routes["Routing Module\n(routes/userRoutes.js)"]:::backend
        Controller["Controller Module\n(controllers/userController.js)"]:::backend
        ConfigDB["Data Access Layer\n(config/db.js)"]:::backend
        Env["Environment Variables\n(.env)"]:::config
        Dependencies["Dependencies\n(package.json)"]:::config
        SQLServer["SQL Server"]:::db
        GSsql["GoldenSkin.sql"]:::sql
        PDsql["Procedimientos GD.sql"]:::sql
        SMTP["SMTP Service\n(Nodemailer)"]:::external
    end

    %% Interactions
    Client -->|"HTTP Request"| Express
    Express -->|uses| Routes
    Routes -->|invokes| Controller
    Controller -->|queries| ConfigDB
    ConfigDB -->|connects to| SQLServer
    GSsql -->|schema| SQLServer
    PDsql -->|stored procs| SQLServer
    Controller -->|sends email via| SMTP
    Controller -->|responds| Express
    Express -->|"HTTP Response"| Client
    Express -->|serves| Public
    Public -->|assets| Client
    Env -->|provides config to| ConfigDB
    Dependencies -->|loaded by| Express

    %% Click Events
    click Client "https://github.com/nestorso/golden-skin-api/tree/main/public/"
    click Public "https://github.com/nestorso/golden-skin-api/tree/main/public/"
    click Express "https://github.com/nestorso/golden-skin-api/blob/main/server.js"
    click Routes "https://github.com/nestorso/golden-skin-api/blob/main/routes/userRoutes.js"
    click Controller "https://github.com/nestorso/golden-skin-api/blob/main/controllers/userController.js"
    click ConfigDB "https://github.com/nestorso/golden-skin-api/blob/main/config/db.js"
    click Env "https://github.com/nestorso/golden-skin-api/blob/main/.env"
    click GSsql "https://github.com/nestorso/golden-skin-api/blob/main/GoldenSkin.sql"
    click PDsql "https://github.com/nestorso/golden-skin-api/blob/main/Procedimientos GD.sql"
    click Dependencies "https://github.com/nestorso/golden-skin-api/blob/main/package.json"

    %% Styles
    classDef client fill:#DDEEFF,stroke:#333,stroke-width:1px
    classDef static fill:#EEFFEE,stroke:#333,stroke-width:1px,stroke-dasharray: 5 5
    classDef backend fill:#FFEEDD,stroke:#333,stroke-width:1px
    classDef config fill:#F0E68C,stroke:#333,stroke-width:1px
    classDef db fill:#FFEECC,stroke:#333,stroke-width:1px
    classDef sql fill:#FFF2CC,stroke:#333,stroke-width:1px
    classDef external fill:#E0E0E0,stroke:#333,stroke-width:1px,stroke-dasharray: 5 5
```
