Quick Start Guide
Get Sistema de Productos running on your local machine in just a few minutes. This guide walks you through the essential steps from cloning to running the application.This quickstart assumes you have Node.js (v18 or higher) and PostgreSQL installed. If not, see the Installation Guide for prerequisites.
Step-by-Step Setup
Install Dependencies
Install all required npm packages:This will install:
- Vue.js and related frontend dependencies
- Express and backend packages
- PostgreSQL driver (pg)
- Authentication libraries (jsonwebtoken, bcrypt)
- Development tools (Vite, Nodemon, Concurrently)
Set Up PostgreSQL Database
Create the PostgreSQL database:Run the database schema script:This will create:
- Tables: Categorias, Productos, Usuarios
- Views: ProductosView, CategoriasView, UsuariosView
- Sample data: 4 categories, 19 products, and 1 admin user
- Extensions: pgcrypto for password encryption
View Database Schema
View Database Schema
The schema includes three main tables:Categorias Table:Productos Table:Usuarios Table:
Configure Environment Variables
Create a Add the following configuration (adjust values for your setup):
.env file in the project root:Generate a Secure JWT Secret
Generate a Secure JWT Secret
You can generate a secure random string for Copy the output and use it as your
JWT_SECRET using Node.js:JWT_SECRET value.Start the Development Servers
Run both frontend and backend servers concurrently:This command uses concurrently to run:
- Frontend (Vite dev server):
http://localhost:5173 - Backend (Express API):
http://localhost:3000
Available NPM Scripts
Thepackage.json includes several useful scripts:
Script Descriptions
| Script | Command | Description |
|---|---|---|
dev | npm run dev | Runs both frontend and backend in development mode |
dev:frontend | npm run dev:frontend | Runs only the Vite frontend server |
dev:backend | npm run dev:backend | Runs only the Express backend server with Nodemon |
build | npm run build | Builds the frontend for production |
preview | npm run preview | Preview the production build locally |
Verify Installation
Test that everything is working correctly:1. Check API Health
Visit the API health endpoint:2. Test Database Connection
The backend console should display:3. Verify Frontend Access
Navigate tohttp://localhost:5173 in your browser. You should see the application’s login page.
API Endpoints Overview
Once running, the following API endpoints are available:Base URL
Available Routes
-
Categories:
/api-productos/categorias- GET - List all categories
- POST - Create new category
- PUT - Update category
- DELETE - Delete category
-
Products:
/api-productos/productos- GET - List all products
- POST - Create new product
- PUT - Update product
- DELETE - Delete product
-
Users:
/api-productos/usuarios- GET - List all users (admin only)
- POST - Create new user
- PUT - Update user
- DELETE - Delete user
Most endpoints require authentication. Include the JWT token in cookies or headers when making requests.
Common Issues
Database Connection Failed
Database Connection Failed
If you see “Database connection failed” or similar errors:
-
Verify PostgreSQL is running:
-
Check your
.envfile has correct database credentials -
Ensure the database
ejercicio_productosexists - Verify your PostgreSQL user has permissions to access the database
Port Already in Use
Port Already in Use
If port 3000 or 5173 is already in use:
- Change the
PORTin.envfor the backend - For frontend, Vite will automatically try the next available port
- Or, stop the process using the port:
Module Not Found Errors
Module Not Found Errors
If you encounter module import errors:
-
Delete
node_modulesandpackage-lock.json: -
Reinstall dependencies:
-
Verify you’re using Node.js v18 or higher:
Next Steps
Now that you have Sistema de Productos running:- Explore the product management features
- Create and organize categories
- Test the API endpoints using tools like Postman or curl
- Review the Installation Guide for production deployment tips
- Examine the source code to understand the architecture
For detailed installation instructions, troubleshooting, and production deployment guidance, see the Installation Guide.
