Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/15aozzz/Lab-Nova-Salud/llms.txt

Use this file to discover all available pages before exploring further.

Botica Nova Salud is a three-tier web application. The React frontend communicates exclusively with a REST API built on Express.js, and that API layer delegates all data operations to MySQL stored procedures. No ad-hoc SQL queries are issued from application code — every database interaction goes through a named stored procedure.

Request flow

Every user action follows the same path through the system:
1

User interaction

The React frontend (served by Vite) renders a page and captures user input — a login form, a product search, a sale registration, and so on.
2

HTTP request

The frontend calls the Express REST API over HTTP using Axios. Protected routes include an Authorization: Bearer <token> header with the JWT obtained at login.
3

Authentication check

The Express middleware verifies the JWT before the request reaches the route handler. Unauthenticated requests are rejected with 401.
4

Stored procedure call

The route handler calls a MySQL stored procedure via the mysql2 connection pool. The backend never constructs raw SQL strings against application tables.
5

Database execution

MySQL executes the stored procedure. Triggers on Detalle_Ventas enforce stock validation and deduction automatically within the same transaction.
6

Response

The stored procedure result set is returned to the route handler, serialised as JSON, and sent back to the React frontend.

Tech stack

LayerTechnology
FrontendReact 19 + Vite 8 + Tailwind CSS v4
HTTP clientAxios
ChartsRecharts
IconsLucide React
BackendNode.js + Express 5
AuthenticationJWT (jsonwebtoken) + SHA-256 password hashing
DatabaseMySQL 8 — stored procedures + triggers
The MySQL connection pool is configured with multipleStatements: true. This is required because some stored procedures (notably sp_get_venta_detalle) return more than one result set in a single call.

All endpoints call stored procedures

The backend contains no direct SQL queries against application tables. Every route handler issues a CALL sp_name(...) statement. This means:
  • Business logic lives in the database layer, not in application code.
  • The API surface is thin: validate input, call the procedure, return the result.
  • Triggers inside MySQL handle side-effects (stock validation and deduction) automatically — the API does not orchestrate those steps manually.

Project directory structure

Lab-Nova-Salud/
├── boticanovasalud_final.sql     ← Full database dump (tables, SPs, triggers, seed data)

├── backend/
│   ├── index.js                  ← Express server entry point
│   ├── db.js                     ← mysql2 connection pool
│   ├── .env.example              ← Environment variable template
│   ├── middleware/
│   │   └── auth.js               ← JWT authentication middleware
│   └── routes/
│       ├── auth.routes.js        ← POST /api/auth/login
│       ├── comprobantes.routes.js
│       ├── clientes.routes.js
│       ├── productos.routes.js
│       ├── ventas.routes.js
│       ├── dashboard.routes.js
│       └── usuarios.routes.js

└── fn/                           ← React + Vite frontend
    └── src/
        ├── api/client.js         ← Configured Axios instance
        ├── services/api.js       ← All frontend service calls
        ├── context/AuthContext.jsx
        ├── router/ProtectedRoute.jsx
        ├── components/
        │   ├── Layout/
        │   ├── Navbar/
        │   └── Sidebar/
        └── pages/
            ├── Login/
            ├── Dashboard/
            ├── NuevaVenta/
            ├── Comprobantes/
            ├── Productos/
            ├── Clientes/
            └── Usuarios/

Explore further

Database design

Stored procedures, triggers, and the MySQL connection configuration.

Authentication

How to obtain and use a JWT token to call protected API endpoints.

Build docs developers (and LLMs) love