Skip to main content

System Requirements

Before installing App CR, ensure your system meets these requirements:

Node.js

Version 14.x or higher

Docker

Docker Engine 20.x+ and Docker Compose

PostgreSQL

Version 15 (via Docker) or existing instance

Git

For cloning the repository

Installation Methods

Configuration

Environment Variables

App CR uses the following environment variables:
VariableRequiredDefaultDescription
DATABASE_URLYes-PostgreSQL connection string
JWT_SECRETYes-Secret key for signing JWT tokens
PORTNo3000Port for the Express server

Database URL Format

The DATABASE_URL follows this format:
postgresql://[USER]:[PASSWORD]@[HOST]:[PORT]/[DATABASE]
Example:
postgresql://user_admin:password123@localhost:5432/mi_db_crud
For cloud databases (e.g., Heroku, AWS RDS):
postgresql://username:[email protected]:5432/database_name

JWT Configuration

The JWT_SECRET is used to sign authentication tokens. Choose a strong, random string:
# Generate a secure random secret (Linux/Mac)
openssl rand -base64 32

# Or use Node.js
node -e "console.log(require('crypto').randomBytes(32).toString('base64'))"

Database Schema

App CR uses Prisma ORM with the following schema:
generator client {
  provider = "prisma-client-js"
}

datasource db {
  provider = "postgresql"
  url      = env("DATABASE_URL")
}

model User {
  id        Int      @id @default(autoincrement())
  email     String   @unique
  password  String
  tasks     Task[]
}

model Task {
  id          Int      @id @default(autoincrement())
  title       String
  description String?
  completed   Boolean  @default(false)
  userId      Int
  author      User     @relation(fields: [userId], references: [id])
}

Running Migrations

When you modify the schema, generate and apply migrations:
# Create a new migration
npx prisma migrate dev --name description_of_change

# Apply migrations in production
npx prisma migrate deploy

# Reset database (development only)
npx prisma migrate reset

Dependencies

App CR includes these core dependencies:
{
  "dependencies": {
    "@prisma/client": "^6.19.2",
    "bcryptjs": "^3.0.3",
    "cors": "^2.8.6",
    "express": "^5.2.1",
    "jsonwebtoken": "^9.0.3",
    "prisma": "^6.19.2"
  },
  "devDependencies": {
    "@types/node": "^25.2.3",
    "dotenv": "^17.3.1"
  }
}

Updating Dependencies

Keep dependencies up to date:
# Check for outdated packages
npm outdated

# Update all packages
npm update

# Update specific package
npm update express

Server Configuration

The Express server is configured in backend/index.js:
require('dotenv').config();
const express = require('express');
const { PrismaClient } = require('@prisma/client');
const cors = require('cors');
const bcrypt = require('bcryptjs');
const jwt = require('jsonwebtoken');

const prisma = new PrismaClient();
const app = express();
const TOKEN = process.env.JWT_SECRET;
const PORT = process.env.PORT || 3000;

// Middlewares
app.use(cors());
app.use(express.json());

app.listen(PORT, () => {
    console.log(`Servidor corriendo en: http://localhost:${PORT}`);
});

CORS Configuration

CORS is enabled by default for all origins. For production, restrict origins:
app.use(cors({
  origin: 'https://your-frontend-domain.com',
  credentials: true
}));

Port Configuration

Change the server port via environment variable or directly:
# In .env
PORT=8080

# Or when starting the server
PORT=8080 node index.js

Database Tools

Prisma Studio

Visual database browser:
npx prisma studio
Opens at http://localhost:5555 for viewing and editing data.

Database Seeding

Create a seed script prisma/seed.js:
const { PrismaClient } = require('@prisma/client');
const prisma = new PrismaClient();

async function main() {
  const user = await prisma.user.create({
    data: {
      email: '[email protected]',
      password: 'hashed_password_here',
      tasks: {
        create: [
          { title: 'Welcome task', description: 'Get started with App CR', completed: false }
        ]
      }
    }
  });
  console.log('Created user:', user);
}

main()
  .catch(console.error)
  .finally(() => prisma.$disconnect());
Add to package.json:
"prisma": {
  "seed": "node prisma/seed.js"
}
Run seed:
npx prisma db seed

Production Deployment

1

Set Environment Variables

Configure production environment variables (never commit .env files):
DATABASE_URL="your-production-database-url"
JWT_SECRET="strong-random-secret"
PORT=3000
NODE_ENV=production
2

Install Production Dependencies

npm ci --production
3

Run Migrations

npx prisma migrate deploy
4

Start Server

Use a process manager like PM2:
npm install -g pm2
pm2 start index.js --name app-cr
pm2 save
pm2 startup
The current implementation has security considerations:
  • Passwords are not hashed before storage
  • JWT authentication endpoints are not yet implemented
  • No input validation middleware
Implement these security features before deploying to production.

Verification

Verify your installation:
curl http://localhost:3000/usuarios
Should return an empty array or list of users.
npx prisma db pull
Should sync schema without errors.
Check server output for errors:
# If using PM2
pm2 logs app-cr

# If running directly
# Check console output where node index.js is running

Troubleshooting

Ensure all dependencies are installed:
rm -rf node_modules package-lock.json
npm install
Check PostgreSQL is running:
# For Docker
docker-compose ps
docker-compose logs postgres

# For system PostgreSQL
sudo systemctl status postgresql
Find and stop the process using the port:
# Find process on port 3000
lsof -i :3000

# Kill the process
kill -9 <PID>

# Or use a different port
PORT=3001 node index.js
Regenerate Prisma client:
npx prisma generate

Next Steps

API Reference

Explore available endpoints

Authentication

Implement JWT authentication

Build docs developers (and LLMs) love