Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/edgar2420/QrPermision/llms.txt

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

By the end of this guide you will have a fully running PermisosQR instance on your local machine: the PostgreSQL database seeded with two test users and 20 sample QR codes, the Express backend listening on port 4000, the React/TypeScript frontend on port 3000, and a verified login token you can use to explore the rest of the API.
Change JWT_SECRET before going to production. The default value in .env.example is a placeholder. Anyone who knows it can forge valid tokens for your instance. Replace it with a long, random string before deploying to a public server.
1

Create the database

Open a psql session and run the following commands to create the database, apply the schema (three tables: users, qr_codes, permissions), and load the seed data (two test accounts and 20 available QR codes):
CREATE DATABASE permisosqr;
\c permisosqr
\i base/schema.sql
\i base/seed.sql
The SQL files live in the base/ directory at the root of the repository. The npm run db:migrate and npm run db:seed scripts in backend/package.json reference ../database/schema.sql and ../database/seed.sql respectively — that path does not match the actual file locations. Use the manual \i commands above (with base/) when setting up the database from a fresh psql session.
The schema creates indexed tables for users, qr_codes, and permissions, along with update_updated_at_column triggers that automatically maintain the updated_at timestamps on every row change.
2

Configure and start the backend

Copy the example environment file, fill in your PostgreSQL credentials, install dependencies, and start the development server:
cd backend
cp .env.example .env
# Edit .env with your PostgreSQL credentials
npm install
npm run dev
# Runs on http://localhost:4000
Your .env file should look like this after editing:
PORT=4000
NODE_ENV=development

DB_HOST=localhost
DB_PORT=5432
DB_NAME=permisosqr
DB_USER=postgres
DB_PASSWORD=root

JWT_SECRET=your_super_secret_jwt_key_change_in_production
JWT_EXPIRES_IN=8h
The npm run dev script uses Node’s built-in --watch flag, so the server restarts automatically whenever you edit a source file.
3

Start the frontend

In a second terminal, install frontend dependencies and launch the Vite dev server:
cd frontend
npm install
npm run dev
# Runs on http://localhost:3000
The frontend is a React 18 + TypeScript application built with Vite. It uses html5-qrcode for camera-based scanning, qrcode for generating printable QR images, and Tailwind CSS for styling.
4

Verify connectivity and log in

First, confirm the backend is up and the database connection is healthy:
curl http://localhost:4000/api/health
# {"status":"ok","database":"connected","timestamp":"..."}
Then authenticate with the seeded super-admin account:
curl -X POST http://localhost:4000/api/auth/login \
  -H "Content-Type: application/json" \
  -d '{"email":"admin@permisosqr.com","password":"admin123"}'
A successful login returns a JWT and the user object:
{
  "success": true,
  "data": {
    "token": "<jwt>",
    "user": {
      "id": 1,
      "name": "Edgar Rojas Apaza",
      "email": "admin@permisosqr.com",
      "role": "super_admin"
    }
  }
}
Copy the token value. Pass it as Authorization: Bearer <token> on every subsequent request to protected endpoints.
Default test credentials seeded by seed.sql:
RoleEmailPassword
super_adminadmin@permisosqr.comadmin123
admin_operatoroperador@permisosqr.comadmin123
Both accounts are active immediately after running seed.sql. You can create additional users via POST /api/users while authenticated as super_admin.

Build docs developers (and LLMs) love