Skip to main content

Quick Start Guide

Get your CUIDO Backend instance running quickly with this streamlined guide.

Prerequisites

Before you begin, ensure you have:
  • Node.js >= 18.0.0
  • npm >= 8.0.0
  • MongoDB >= 5.0 (running locally or remotely)
  • Anthropic API Key from console.anthropic.com
You can check your Node.js version with node --version and npm version with npm --version.

Installation Steps

1

Clone the Repository

Clone the CUIDO Backend repository to your local machine:
git clone https://github.com/JuanMartinezL/CUIDO_Back.git
cd CUIDO_Back
2

Install Dependencies

Install all required npm packages:
npm install
This will install 20+ production dependencies including Express, Mongoose, Anthropic SDK, and more.
3

Configure Environment

Create your environment configuration file:
cp .env.example .env
Edit the .env file with your settings:
# Server Configuration
PORT=3000
NODE_ENV=development

# Database
MONGODB_URI=mongodb://localhost:27017/claude-prompt-db

# Authentication
JWT_SECRET=your_jwt_secret_super_secure_256_bits_minimum
JWT_EXPIRES_IN=7d

# Anthropic Claude AI
ANTHROPIC_API_KEY=sk-ant-api03-your-api-key-here
CLAUDE_MODEL=claude-3-sonnet-20240229
Replace your_jwt_secret_super_secure_256_bits_minimum with a strong random string for production use.
4

Start MongoDB

Ensure MongoDB is running on your system:
# macOS (with Homebrew)
brew services start mongodb-community

# Linux (systemd)
sudo systemctl start mongod

# Or use Docker
docker run -d -p 27017:27017 --name mongodb mongo:5.0
5

Seed the Database (Optional)

Populate the database with initial data:
npm run seed
This creates default prompt templates and test data.
6

Start the Server

Launch the development server:
npm run dev
You should see output similar to:
✓ Variables de entorno cargadas:
ANTHROPIC_API_KEY configurada: true
✓ Conectado exitosamente a la base de datos
✓ Conexión con Claude API validada exitosamente
✓ Servidor corriendo en puerto 3000 (development)
Módulo de Diagnóstico Inteligente activado
✓ Notificaciones en tiempo real habilitadas
✓ Tareas programadas iniciadas

Verify Installation

Test that your server is running correctly:
curl http://localhost:3000/health
Expected response:
{
  "success": true,
  "message": "Servicio funcionando correctamente",
  "timestamp": "2024-03-05T10:30:00.000Z",
  "environment": "development"
}

Make Your First API Call

Now let’s register a user and make a chat completion request.

1. Register a User

curl -X POST http://localhost:3000/api/auth/register \
  -H "Content-Type: application/json" \
  -d '{
    "name": "John Doe",
    "email": "[email protected]",
    "password": "SecurePass123!"
  }'
Response:
{
  "success": true,
  "message": "Usuario registrado exitosamente",
  "data": {
    "user": {
      "_id": "65f8a9b2c1234567890abcde",
      "name": "John Doe",
      "email": "[email protected]",
      "role": "user"
    },
    "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
  }
}
Save the token value - you’ll need it for authenticated requests.

2. Login

curl -X POST http://localhost:3000/api/auth/login \
  -H "Content-Type: application/json" \
  -d '{
    "email": "[email protected]",
    "password": "SecurePass123!"
  }'

3. Get Your Profile

curl -X GET http://localhost:3000/api/auth/profile \
  -H "Authorization: Bearer YOUR_TOKEN_HERE"

4. List Prompt Templates

curl -X GET http://localhost:3000/api/prompts \
  -H "Authorization: Bearer YOUR_TOKEN_HERE"

5. Chat with Claude AI

curl -X POST http://localhost:3000/api/chat/complete \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN_HERE" \
  -d '{
    "templateId": "TEMPLATE_ID_FROM_PREVIOUS_STEP",
    "userPrompt": "Explain how the immune system works",
    "temperature": 0.7,
    "maxTokens": 1000
  }'
Response:
{
  "success": true,
  "message": "Respuesta generada exitosamente",
  "data": {
    "response": "El sistema inmunológico es...",
    "conversationId": "65f8a9b2c1234567890abcdf",
    "tokenUsage": {
      "input": 245,
      "output": 512,
      "total": 757
    },
    "metadata": {
      "model": "claude-3-sonnet-20240229",
      "responseTime": 1234,
      "temperature": 0.7,
      "maxTokens": 1000,
      "template": "Medical Explanation"
    }
  }
}

Available Scripts

# Start with auto-reload
npm run dev

Rate Limiting

Be aware of the built-in rate limits:
EndpointLimitWindow
Authentication (/api/auth/login, /api/auth/register)5 requests15 minutes
Chat (/api/chat/complete)10 requests1 minute (per user)
General API100 requests15 minutes (per IP)
Exceeding rate limits will result in a 429 Too Many Requests response. Plan your API usage accordingly.

Next Steps

Configuration Guide

Learn about all environment variables

API Reference

Explore detailed API documentation

Authentication

Deep dive into auth system

Chat System

Master the Claude AI integration

Troubleshooting

Ensure MongoDB is running and the MONGODB_URI in your .env file is correct. Check the connection string format:
mongodb://localhost:27017/claude-prompt-db
Your API key must:
  • Start with sk-ant-
  • Be from a valid Anthropic account
  • Have sufficient credits
Get a key from console.anthropic.com.
Change the port in your .env file:
PORT=3001
Rate limits are per-IP and per-user. Wait for the window to reset or temporarily disable rate limiting in development by modifying src/app.js.

Build docs developers (and LLMs) love