Documentation Index Fetch the complete documentation index at: https://mintlify.com/Celaya55/app-cr/llms.txt
Use this file to discover all available pages before exploring further.
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
Docker (Recommended)
Existing PostgreSQL
Use Docker for the easiest setup with isolated database. Step 1: Clone the Repository git clone < your-repository-ur l >
cd app-cr
Step 2: Review Docker Configuration The included docker-compose.yml configures PostgreSQL: version : '3.8'
services :
postgres :
image : postgres:15
restart : always
environment :
POSTGRES_USER : user_admin
POSTGRES_PASSWORD : password123
POSTGRES_DB : mi_db_crud
ports :
- "5432:5432"
volumes :
- postgres_data:/var/lib/postgresql/data
volumes :
postgres_data :
The volume postgres_data persists your database data between container restarts.
Step 3: Start PostgreSQL Verify the container is running: Navigate to the backend directory: Create a .env file: DATABASE_URL = "postgresql://user_admin:password123@localhost:5432/mi_db_crud"
JWT_SECRET = "your-super-secret-jwt-key-change-this"
PORT = 3000
Step 5: Install Dependencies Step 6: Setup Database npx prisma generate
npx prisma migrate dev --name init
Step 7: Start the Server Use an existing PostgreSQL installation instead of Docker. Step 1: Clone the Repository git clone < your-repository-ur l >
cd app-cr/backend
Step 2: Create Database Connect to your PostgreSQL instance and create a database: CREATE DATABASE mi_db_crud ;
CREATE USER user_admin WITH PASSWORD 'password123' ;
GRANT ALL PRIVILEGES ON DATABASE mi_db_crud TO user_admin;
Create .env file with your database connection: DATABASE_URL = "postgresql://user_admin:password123@localhost:5432/mi_db_crud"
JWT_SECRET = "your-super-secret-jwt-key-change-this"
PORT = 3000
Replace the credentials with your actual PostgreSQL username and password.
Step 4: Install and Setup npm install
npx prisma generate
npx prisma migrate dev --name init
node index.js
Configuration
Environment Variables
App CR uses the following environment variables:
Variable Required Default Description DATABASE_URLYes - PostgreSQL connection string JWT_SECRETYes - Secret key for signing JWT tokens PORTNo 3000Port for the Express server
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:password@host.region.rds.amazonaws.com: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
Prisma Studio
Visual database browser:
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: 'admin@example.com' ,
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:
Production Deployment
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
Install Production Dependencies
Run Migrations
npx prisma migrate deploy
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.
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
Database connection refused
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 < PI D >
# Or use a different port
PORT = 3001 node index.js
Regenerate Prisma client:
Next Steps
API Reference Explore available endpoints
Authentication Implement JWT authentication