Skip to main content

Installation

This guide covers both Docker-based installation (recommended) and manual setup for the Los Inmaduros Backend API.

Prerequisites

Choose your installation method and ensure you have the required prerequisites:

Installation Methods

Quick Start with Docker

Docker is the easiest way to run the project. Everything is configured automatically.
1

Clone the repository

git clone https://github.com/Adriasu09/los-inmaduros-backend.git
cd los-inmaduros-backend
2

Create .env file

Copy the example environment file:
cp .env.example .env
Edit .env and add your Clerk and Supabase credentials:
# Clerk Authentication
CLERK_SECRET_KEY=your_clerk_secret_key
CLERK_PUBLISHABLE_KEY=your_clerk_publishable_key

# Supabase Storage
SUPABASE_URL=your_supabase_url
SUPABASE_ANON_KEY=your_supabase_anon_key
Other variables like DATABASE_URL and PORT are pre-configured for Docker.
3

Start with Docker Compose

Launch the entire stack:
npm run docker:dev
Or use Docker Compose directly:
docker-compose up --build
Docker will automatically:
  • ✅ Set up PostgreSQL database
  • ✅ Run Prisma migrations
  • ✅ Install dependencies
  • ✅ Start the server with hot reload
4

Verify installation

Your API is now running at:Test the health endpoint:
curl http://localhost:4000/health

Docker Management Commands

# Stop containers
npm run docker:dev:down

# View logs
npm run docker:logs

# Rebuild from scratch
docker-compose down -v && docker-compose up --build

# Stop and remove everything (including volumes)
docker-compose down -v

# Production mode
npm run docker:prod

Environment Variables Setup

The API requires several environment variables to function properly. Here’s a comprehensive overview:

Required Variables

VariableDescriptionExample
CLERK_SECRET_KEYClerk secret key for authenticationsk_test_...
CLERK_PUBLISHABLE_KEYClerk publishable keypk_test_...
SUPABASE_URLSupabase project URLhttps://xxx.supabase.co
SUPABASE_ANON_KEYSupabase anonymous keyeyJhbG...
DATABASE_URLPostgreSQL connection stringpostgresql://user:pass@localhost:5432/db

Optional Variables

VariableDescriptionDefault
PORTServer port4000
NODE_ENVEnvironment modedevelopment
FRONTEND_URLFrontend URL for CORShttp://localhost:3000
For detailed information about each environment variable, see the Environment Variables page.

Database Setup

The API uses Prisma as an ORM with PostgreSQL.

With Docker

Docker automatically sets up PostgreSQL with these credentials:
  • Host: db (internal) / localhost (external)
  • Port: 5432
  • User: postgres
  • Password: postgres
  • Database: los_inmaduros

Manual Setup

You’ll need to:
  1. Install PostgreSQL 14 or higher
  2. Create a database named los_inmaduros (or your preferred name)
  3. Update DATABASE_URL in your .env file
  4. Run migrations: npx prisma migrate dev

Useful Prisma Commands

# Run migrations
npx prisma migrate dev

# Reset database (WARNING: deletes all data)
npx prisma migrate reset

# Open Prisma Studio (database GUI)
npx prisma studio

# Generate Prisma client
npx prisma generate

# Create a new migration
npx prisma migrate dev --name migration_name

Verification

Health Check

Verify the server is running:
curl http://localhost:4000/health
Expected response:
{
  "status": "OK",
  "message": "Los Inmaduros Backend is running! 🛼",
  "timestamp": "2026-03-04T10:30:00.000Z",
  "database": "Connected ✅"
}

Test API Endpoints

Get all routes:
curl http://localhost:4000/api/routes

Access Swagger Documentation

Open your browser and visit: http://localhost:4000/api-docs This provides an interactive interface to test all endpoints.

Troubleshooting

Symptoms: “Database connection failed” or Prisma errorsSolutions:
  • Verify PostgreSQL is running
  • Check DATABASE_URL is correct in .env
  • Ensure the database exists: psql -l
  • Run migrations: npx prisma migrate dev
  • For Docker: docker-compose logs db
Symptoms: “Port 4000 is already in use”Solutions:
  • Change PORT in .env to a different value (e.g., 4001)
  • Kill the process using port 4000: lsof -ti:4000 | xargs kill -9
  • For Docker: Update port mapping in docker-compose.yml
Symptoms: 401 errors or “Invalid Clerk token”Solutions:
  • Verify CLERK_SECRET_KEY and CLERK_PUBLISHABLE_KEY are correct
  • Ensure both keys are from the same Clerk application
  • Check your Clerk dashboard for the correct keys
  • Make sure keys are properly formatted (no extra spaces)
Symptoms: Photo upload fails or storage errorsSolutions:
  • Verify SUPABASE_URL and SUPABASE_ANON_KEY are correct
  • Check your Supabase project is active
  • Ensure storage bucket is created in Supabase dashboard
  • Verify bucket permissions allow public uploads
Symptoms: Build fails with type errorsSolutions:
  • Run npm install to ensure all dependencies are installed
  • Delete node_modules and package-lock.json, then npm install again
  • Run npx prisma generate to regenerate Prisma client
  • Check TypeScript version matches package.json (5.6)

Next Steps

Quickstart Guide

Quick overview of getting started

Environment Variables

Detailed configuration reference

API Reference

Explore all available endpoints

Authentication

Learn about Clerk authentication

Build docs developers (and LLMs) love