Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/Danielings/Pasantia-Proyecto/llms.txt

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

This guide walks you through running the Sistema de Inventario Tecnológico on your local machine from scratch. By the end you will have the Express backend and the React frontend both running, a valid session cookie in hand, and a clear picture of how the two processes communicate. The entire setup should take less than 10 minutes on a machine that already has Node.js and a package manager installed.
Firebase credentials are obtained by creating a service account in the Firebase Console. Navigate to Project Settings → Service accounts → Generate new private key and download the resulting JSON file. The individual fields from that file map directly to the environment variables described in Step 3.
1

Clone the repository

Clone the project from its remote repository and enter the project root. All subsequent commands are run from within this directory.
git clone https://github.com/Danielings/Pasantia-Proyecto.git
cd Pasantia-Proyecto
2

Install backend dependencies

Move into the backend directory and install all Node.js dependencies. The project uses ES Modules ("type": "module") and Express 5, so Node.js 18 or later is required.
cd backend
pnpm install   # or: npm install
Key backend packages that will be installed:
PackagePurpose
express 5.2HTTP server and router
firebase-adminFirestore access via service account
jsonwebtokenJWT signing and verification
nodemailerSMTP email for password recovery
pdfkitPDF export generation
xlsxExcel export generation
bcrypt / bcryptjsPassword hashing
mysql2MySQL connection for password-reset tokens
cookie-parserHTTP-only cookie parsing
3

Configure environment variables

Create a .env file inside the backend/ directory. The config/env.js module resolves this file relative to itself and loads it automatically on startup using dotenv.
# backend/.env
touch .env   # then open with your editor of choice
Populate the file with all required variables:
# ── Firebase service account fields (from the downloaded JSON) ──────────
project_id=your-firebase-project-id
private_key_id=your-private-key-id
private_key="-----BEGIN RSA PRIVATE KEY-----\n...\n-----END RSA PRIVATE KEY-----\n"
client_email=firebase-adminsdk-xxxxx@your-project.iam.gserviceaccount.com
client_id=123456789012345678901
client_x509_cert_url=https://www.googleapis.com/robot/v1/metadata/x509/firebase-adminsdk-xxxxx%40your-project.iam.gserviceaccount.com

# ── JWT ──────────────────────────────────────────────────────────────────
JWT_SECRET=a-long-random-secret-string-at-least-32-chars

# ── SMTP (Gmail — for password recovery emails) ──────────────────────────
SMTP_USER=no-reply@example.com
SMTP_PASS=your-gmail-app-password

# ── Frontend origin (used in CORS + email links) ──────────────────────────
FRONTEND_URL=http://localhost:5173

# ── MySQL (password reset token storage only) ─────────────────────────────
DB_HOST=127.0.0.1
DB_USER=root
DB_PASSWORD=your-mysql-password
DB_NAME=inventario_tokens
The private_key value from the Firebase JSON contains literal \n escape sequences. Wrap the entire value in double quotes in your .env file — config/firebase.js calls .replace(/\\n/g, "\n") to convert them to real newlines before passing the key to firebase-admin.
4

Start the backend

From the backend/ directory, start the Express server. It binds to port 3001 and prints how many environment variables were loaded.
node index.js
You should see output similar to:
[env] 14 variables cargadas desde .env
The server is now listening at http://localhost:3001. All API routes are mounted under the /api prefix.
5

Install frontend dependencies

Open a second terminal, navigate to the frontend/ directory from the project root, and install dependencies.
cd frontend
pnpm install   # or: npm install
Key frontend packages that will be installed:
PackagePurpose
react 19 / react-domUI rendering
react-router-dom 7Client-side routing
react-hook-form + zodForm state and validation
axiosHTTP requests to the Express API
tailwindcss 4 + @tailwindcss/viteUtility-first styling
shadcn / radix-uiAccessible UI primitives
react-hot-toastToast notifications
rechartsDashboard charts
lucide-reactIcon library
6

Start the frontend

Run the Vite development server. It starts on port 5173 and proxies nothing — all API calls from the React app go directly to http://localhost:3001.
pnpm dev
Vite will print a local URL like http://localhost:5173. Open it in your browser; you will be redirected to the /login page automatically by the RutaProtegida component in App.jsx.
7

Log in and obtain your session token

With both servers running, authenticate by sending a POST request to /api/login with a JSON body containing correo and password. On success, the server signs a JWT with JWT_SECRET and writes it as an HTTP-only cookie named acceso_token.
curl -i -X POST http://localhost:3001/api/login \
  -H "Content-Type: application/json" \
  -c cookies.txt \
  -d '{"correo": "admin@example.com", "password": "your-password"}'
A successful response looks like:
{
  "mensaje": "Inicio de sesión exitoso",
  "usuario": {
    "uid": "abc123",
    "nombre": "Admin User",
    "correo": "admin@example.com",
    "rol": "Administrador"
  }
}
The -c cookies.txt flag tells curl to save the acceso_token cookie. Pass -b cookies.txt on subsequent requests to authenticate them:
curl http://localhost:3001/api/me \
  -b cookies.txt
In the browser, the React frontend handles this automatically — Axios is configured with withCredentials: true so the cookie is sent on every request.
CORS is pre-configured to accept requests only from http://localhost:5173. If you need to access the API from a different origin — such as a staging frontend or a different local port — update the origin value in the cors(...) configuration block at the top of backend/index.js before starting the server.

Build docs developers (and LLMs) love