Installation Guide
This guide provides comprehensive installation instructions for the SSP Backend API, including all dependencies and system requirements.System Requirements
Required Software
- Node.js: v18.0.0 or higher
- npm: v9.0.0 or higher (comes with Node.js)
- PostgreSQL: v12.0 or higher
- Git: Latest version
Operating System
The SSP Backend API works on:- Linux (Ubuntu 20.04+, Debian 10+, etc.)
- macOS (10.15+)
- Windows (with WSL2 recommended)
Installing Dependencies
1. Install Node.js and npm
2. Install PostgreSQL
3. Install Git
Project Installation
1. Clone the Repository
2. Install Project Dependencies
Install all npm packages defined inpackage.json:
Core Framework
@nestjs/corev11.0.1 - NestJS framework core@nestjs/commonv11.0.1 - Common utilities and decorators@nestjs/platform-expressv11.0.1 - Express adapter for NestJS
Database
typeormv0.3.28 - TypeScript ORM for PostgreSQL@nestjs/typeormv11.0.0 - NestJS TypeORM integrationpgv8.19.0 - PostgreSQL client for Node.js
Authentication & Security
@nestjs/jwtv11.0.2 - JWT utilities@nestjs/passportv11.0.5 - Passport integrationpassportv0.7.0 - Authentication middlewarepassport-jwtv4.0.1 - JWT strategy for Passportbcryptv6.0.0 - Password hashing
Validation
class-validatorv0.14.3 - Decorator-based validationclass-transformerv0.5.1 - Object transformation
Utilities
dotenvv17.3.1 - Environment variable managementreflect-metadatav0.2.2 - Metadata reflection APIrxjsv7.8.1 - Reactive extensions
Development dependencies (TypeScript, Jest, ESLint, etc.) are also installed automatically.
3. Configure PostgreSQL Database
Create a dedicated database and user for the SSP API:4. Environment Configuration
Create a.env file in the project root:
5. Build the Application
Compile the TypeScript code:dist/ directory with compiled JavaScript files.
Database Setup
Running Migrations
The application is configured to run migrations automatically on startup (seesrc/app.module.ts:24):
Seeding Initial Data
Create the initial admin user:src/seeds/seed-admin.ts) creates:
- Username:
Admin - Password: Value from
SEED_ADMIN_PASSWORDenv var (default:Admin1234) - Role: Admin
- Name: Admin Principal
Verification
1. Verify Database Connection
Test the database connection:usuarios, beneficiarios, actividades, salud_perfil_general, etc.
2. Start the Application
Start the development server:3. Test API Endpoint
Test the login endpoint:Additional Tools (Optional)
TypeScript Node (ts-node)
Already included as a dev dependency for running TypeScript files directly:Database GUI Tools
Consider installing a PostgreSQL GUI for easier database management:- pgAdmin - Official PostgreSQL GUI
- DBeaver - Universal database tool
- TablePlus - Modern database GUI (macOS/Windows)
API Testing Tools
Next Steps
Database Setup
Learn about TypeORM configuration and database schema
Running Locally
Learn about development workflow and debugging
Environment Variables
Complete reference of all configuration options
Quickstart
Jump to the quickstart guide
Troubleshooting
npm install fails
npm install fails
Try clearing npm cache and reinstalling:
PostgreSQL connection refused
PostgreSQL connection refused
Ensure PostgreSQL is running:Check that your
.env credentials match your PostgreSQL setup.TypeORM migration errors
TypeORM migration errors
If migrations fail, check:
- Database exists:
psql -l | grep ssp_db - User has permissions:
psql -U ssp_user -d ssp_db - Environment variables are correct
- Migration files exist in
src/migrations/
