Ordervista follows a classic three-tier web architecture: a React single-page application handles all presentation logic in the browser, a Node.js/Express REST API encapsulates business logic and data access on the server, and a MySQL relational database provides persistent storage. The tiers communicate exclusively over HTTP — the browser sends JSON requests with a JWT bearer token, Express validates the token and role before dispatching to the appropriate controller, and the controller queries MySQL through parameterized statements before returning a JSON response. This separation keeps each tier independently deployable and testable.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/ytabeloved/ordervista/llms.txt
Use this file to discover all available pages before exploring further.
Frontend Architecture
The frontend is a React 19 single-page application built and served by Vite. All navigation happens client-side through React Router DOM v7 — the server never performs server-side rendering. API communication is handled entirely by Axios, which is pre-configured with the base URL fromVITE_API_URL. User sessions are maintained in localStorage: after a successful login, the JWT and user profile are stored there and attached as Authorization: Bearer <token> headers on every protected request.
Frontend Routes
All routes are defined inAppRoutes.jsx. Public routes (/login, /register) render directly. Every other route is wrapped in a <ProtectedRoute> component that checks for a valid token before rendering the page.
| Route | Page Component | Access |
|---|---|---|
/login | Login | Public |
/register | Register | Public |
/ | Dashboard | Admin (AdminLayout) |
/usuarios | Users | Admin (AdminLayout) |
/categorias | Categories | Admin (AdminLayout) |
/productos | Products | Admin (AdminLayout) |
/reportes | Reports | Admin (AdminLayout) |
/operator | OrderManagement | Operator (AdminLayout) |
/operator/new-order | CreateInPersonOrder | Operator (AdminLayout) |
/kitchen | KitchenCommands | Operator (AdminLayout) |
/receipts | Receipts | Operator (AdminLayout) |
/menu | Menu | Customer (ProtectedRoute) |
/cart | Cart | Customer (ProtectedRoute) |
/addresses | Addresses | Customer (ProtectedRoute) |
/orders | Orders | Customer (ProtectedRoute) |
<AdminLayout>, which renders the shared sidebar and topbar navigation shell.
Backend Architecture
The backend is a Node.js + Express 5 API organized around the MVC pattern. The entry point isserver.js, which mounts all route modules and starts the HTTP listener. Application-level configuration (CORS, JSON parsing, core routes) lives in src/app.js.
Directory Structure
API Route Modules
Each resource is handled by a dedicated Express router registered under/api:
Authentication and Authorization Middleware
Protected routes use two middleware layers applied in sequence:verifyToken— Extracts theBearertoken from theAuthorizationheader, verifies it againstJWT_SECRET, and attaches the decoded payload toreq.user. Requests with missing or invalid tokens receive a401 Unauthorizedresponse.authorizeRoles(...roles)— Receives one or more role IDs. AfterverifyTokenruns, it comparesreq.user.id_rolagainst the allowed list and returns403 Forbiddenif the role is not permitted.
id_rol | Role Label | Access Level |
|---|---|---|
1 | Administrator | Full system access |
2 | Operator | Order and kitchen management |
3 | Customer | Menu, cart, and personal orders |
Database Schema
Ordervista uses a MySQL relational schema with 10 tables. Foreign key relationships enforce referential integrity across the entire order lifecycle. Table names are uppercase to ensure consistent behavior on case-sensitive Linux database hosts.Tables and Relationships
PEDIDOS.id_direccionis nullable so that in-person (operator-created) orders do not require a delivery address.COMANDAS.id_pedidohas aUNIQUEconstraint, enforcing a one-to-one relationship between an order and its kitchen command ticket.activoboolean flags onUSUARIOS,CATEGORIAS,PRODUCTOS, andDIRECCIONESenable soft-deletion without breaking foreign key references.
Request Flow
The following steps trace the journey of a typical authenticated API request — for example, an operator fetching the active order list fromGET /api/orders.
Client initiates request
The React component calls an Axios service function. Axios attaches the JWT stored in
localStorage as the Authorization: Bearer <token> header and dispatches the HTTP request to VITE_API_URL.Express router receives the request
server.js receives the request and matches it to the /api/orders router. The router passes the request down its middleware chain before invoking the controller.verifyToken middleware runs
verifyToken extracts the bearer token, calls jwt.verify() against JWT_SECRET, and — if valid — attaches the decoded payload (including id_usuario and id_rol) to req.user. An invalid or missing token immediately returns 401 Unauthorized.authorizeRoles middleware runs
authorizeRoles checks that req.user.id_rol is in the set of roles permitted for this route. If the role is not authorized, the middleware returns 403 Forbidden before the controller is ever called.Controller handles the request
The controller function receives the validated
req object, extracts any query parameters or body fields, and calls the appropriate model function.Model queries MySQL
The model executes a parameterized SQL query through the
mysql2 connection pool and returns the result rows to the controller.