Installation Guide
This guide provides detailed instructions for installing and configuring PaparcApp in both development and production environments.Prerequisites
Before installing PaparcApp, ensure your system meets these requirements:Required Software
Node.js
Version: 18.x or higherDownload Node.js
npm
Version: 9.x or higherIncluded with Node.js
PostgreSQL
Version: 14 or higherDownload PostgreSQL
System Requirements
| Component | Minimum | Recommended |
|---|---|---|
| RAM | 2 GB | 4 GB |
| Storage | 500 MB | 1 GB |
| CPU | 1 core | 2 cores |
| OS | Linux, macOS, Windows | Linux (Ubuntu 20.04+) |
Verify Prerequisites
Check that all required software is installed:Installation Steps
1. Clone the Repository
Clone the PaparcApp repository from GitHub:2. Install Dependencies
Navigate to theproyecto directory and install npm packages:
View complete dependency list
View complete dependency list
Production Dependencies:
express@4.21.2- Web frameworkpg@8.17.2- PostgreSQL clientbcrypt@6.0.0- Password hashingejs@3.1.10- Template engineexpress-session@1.18.2- Session managementdotenv@17.2.3- Environment variable loaderaxios@1.13.4- HTTP clientfirebase@12.9.0- Social authenticationcookie-parser@1.4.4- Cookie parsingmorgan@1.10.1- HTTP request loggerhttp-errors@1.6.3- Error handlingdebug@2.6.9- Debugging utility
nodemon@3.1.11- Auto-restart on file changesjest@30.2.0- Testing framework
3. Configure Environment Variables
Create .env File
Copy the example template and customize it:Environment Configuration Options
- Local Development
- Production (Neon.tech)
- All Variables
.env
For local development, use the individual
DB_* variables. The connection pool in config/database.js will use these.Generate Secure SESSION_SECRET
4. Database Setup
Option A: Local PostgreSQL
Option B: Neon.tech (Cloud PostgreSQL)
Create Neon Account
- Go to neon.tech
- Sign up for a free account
- Create a new project
Get Connection String
Copy the connection string from the Neon dashboard:Add this to your
.env file as DATABASE_URL.Database Schema Files
Understanding what each SQL file does:01_tables.sql - Table Creation
01_tables.sql - Table Creation
Creates all 13 tables with primary keys:
customer- System users (ADMIN, REGISTRADO, NO-REGISTRADO)vehicle- Vehicle registry with unique license platescustomer_vehicle- N:M relationship (virtual garage)vehicle_coefficient- Pricing multipliers by vehicle typemain_service- Three service tiers (ECO, TRANSFER, MEET)service_rate- Pricing by day ranges for each serviceadditional_service- Extra services catalog (washes, ITV, etc.)reservation- Booking records with lifecycle statesreservation_additional_service- N:M for extras per bookingphoto_evidence- Vehicle condition photosnotification- Email logcontract_plan- Subscription planscontract- Active subscriptions
Example: vehicle table
02_constraints.sql - Business Rules
02_constraints.sql - Business Rules
Adds foreign keys and CHECK constraints to enforce business logic:
- Reservation status: only PENDIENTE, EN CURSO, FINALIZADA, CANCELADA
- Payment method: only TARJETA, EFECTIVO, or NULL
- Parking spot required for IN PROGRESS and COMPLETED states
- Exit date must be after entry date
- Price must be non-negative
- Email and phone validation patterns
- Vehicle multiplier must be positive
Example: reservation constraints
03_indexes.sql - Performance Optimization
03_indexes.sql - Performance Optimization
Creates 9 additional indexes for frequently queried columns:
idx_reservation_id_vehicle- Fast vehicle lookupidx_reservation_entry_date- Filter by check-in dateidx_reservation_exit_date- Filter by check-out dateidx_reservation_id_customer- Customer’s reservationsidx_reservation_status- Filter by stateidx_photo_evidence_id_reservation- Reservation photosidx_notification_id_reservation- Notification history- And more…
Example indexes
04_initial_data.sql - Seed Data
04_initial_data.sql - Seed Data
Loads essential configuration and test data:Master Configuration:
- 5 vehicle coefficients (TURISMO ×1.0, MOTOCICLETA ×0.5, etc.)
- 3 main services (ECO, TRANSFER, MEET) with descriptions
- 12 service rate tiers (4 day ranges × 3 services)
- 3 subscription plans (Quarterly, Semiannual, Annual)
- Additional services catalog (washes, ITV, charging, etc.)
- Sample customers (including admin users)
- Test vehicles
- Sample reservations in different states
- Photo evidence examples
- Notification logs
Example: pricing configuration
5. Start the Application
- Development Mode
- Production Mode
- Testing
Start with Nodemon for auto-restart on file changes:Expected output:
Nodemon watches for file changes and automatically restarts the server. Perfect for development.
Post-Installation
Create Admin User
If the initial data script didn’t create an admin user, create one manually:Generate bcrypt hash for password
Generate bcrypt hash for password
Configure Firebase (Optional)
For social login (Google/Facebook), set up Firebase:Create Firebase Project
- Go to Firebase Console
- Create a new project
- Enable Authentication
Enable Providers
In Authentication > Sign-in method:
- Enable Google
- Enable Facebook (requires Facebook App ID)
Configure Email Notifications (Optional)
For automated emails via n8n:Set Up n8n
Deploy n8n or use n8n.cloud
Deployment Options
Deploy to Render
Create Render Account
Sign up at render.com
Create Web Service
- Connect your GitHub repository
- Select the
proyectodirectory - Set build command:
npm install - Set start command:
npm start
Configure Environment
Add environment variables in Render dashboard:
NODE_ENV=productionDATABASE_URL(from Neon.tech)SESSION_SECRETPORT=3000
Deploy to Heroku
Deploy with Docker
Dockerfile example
Dockerfile example
Dockerfile
docker-compose.yml
Troubleshooting
Cannot connect to database
Cannot connect to database
Symptoms:Solutions:
-
Check PostgreSQL is running:
-
Verify connection settings in
.env -
Test direct connection:
-
Check PostgreSQL logs:
Pricing cache initialization failed
Pricing cache initialization failed
Symptoms:Solutions:
-
Ensure initial data was loaded:
-
Check service rates exist:
-
Re-run initial data script:
- Check database connection works before starting app
Session not working / Can't login
Session not working / Can't login
Symptoms:
- Login succeeds but immediately logs out
- Session data not persisting
- “Unauthorized” errors
- Check
SESSION_SECRETis set in.env - Clear browser cookies and cache
- Verify express-session is installed:
- In production, ensure HTTPS is enabled (session cookies require secure flag)
- Check trust proxy setting in
app.js(required for Render/Heroku)
Port already in use
Port already in use
Symptoms:Solutions:
-
Change port in
.env: -
Kill the process using port 3000:
-
Or run with custom port temporarily:
bcrypt compilation errors
bcrypt compilation errors
Symptoms:Solutions:
-
Install build tools:
-
Rebuild bcrypt:
-
Or use pre-built binaries:
Security Checklist
Before deploying to production:Environment Security
- Set
NODE_ENV=production - Use strong
SESSION_SECRET(min 32 chars) - Never commit
.envto version control - Add
.envto.gitignore
Database Security
- Use SSL for database connections
- Create dedicated database user (not postgres superuser)
- Grant only necessary privileges
- Regular backups configured
Application Security
- HTTPS enabled (trust proxy configured)
- Session cookies set to secure
- All passwords use bcrypt (10+ rounds)
- SQL queries use parameterization
- Input validation on all forms
Next Steps
Architecture Guide
Learn about the MVC pattern, service layers, and data flow
API Reference
Explore REST endpoints for pricing and reservations
Database Schema
Detailed documentation of all 13 tables and relationships
Quickstart
Get started quickly with PaparcApp
Need Help? Join the discussion on GitHub Issues or check the Quick Start Guide for a faster setup.
