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:- Docker (Recommended)
- Manual Setup
- Docker Desktop - Install Docker Desktop
- Git - For cloning the repository
- Clerk Account - Sign up at clerk.com
- Supabase Account - Sign up at supabase.com
Docker is the recommended approach as it handles all dependencies and database setup automatically.
Installation Methods
- Docker Installation
- Manual Installation
Quick Start with Docker
Docker is the easiest way to run the project. Everything is configured automatically.Create .env file
Copy the example environment file:Edit
.env and add your Clerk and Supabase credentials:Other variables like
DATABASE_URL and PORT are pre-configured for Docker.Start with Docker Compose
Launch the entire stack:Or use Docker Compose directly:Docker will automatically:
- ✅ Set up PostgreSQL database
- ✅ Run Prisma migrations
- ✅ Install dependencies
- ✅ Start the server with hot reload
Verify installation
Your API is now running at:
- Backend: http://localhost:4000
- API Docs: http://localhost:4000/api-docs
- PostgreSQL: localhost:5432
Docker Management Commands
Environment Variables Setup
The API requires several environment variables to function properly. Here’s a comprehensive overview:Required Variables
| Variable | Description | Example |
|---|---|---|
CLERK_SECRET_KEY | Clerk secret key for authentication | sk_test_... |
CLERK_PUBLISHABLE_KEY | Clerk publishable key | pk_test_... |
SUPABASE_URL | Supabase project URL | https://xxx.supabase.co |
SUPABASE_ANON_KEY | Supabase anonymous key | eyJhbG... |
DATABASE_URL | PostgreSQL connection string | postgresql://user:pass@localhost:5432/db |
Optional Variables
| Variable | Description | Default |
|---|---|---|
PORT | Server port | 4000 |
NODE_ENV | Environment mode | development |
FRONTEND_URL | Frontend URL for CORS | http://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:- Install PostgreSQL 14 or higher
- Create a database named
los_inmaduros(or your preferred name) - Update
DATABASE_URLin your.envfile - Run migrations:
npx prisma migrate dev
Useful Prisma Commands
Verification
Health Check
Verify the server is running:Test API Endpoints
Get all routes:Access Swagger Documentation
Open your browser and visit: http://localhost:4000/api-docs This provides an interactive interface to test all endpoints.Troubleshooting
Database connection errors
Database connection errors
Symptoms: “Database connection failed” or Prisma errorsSolutions:
- Verify PostgreSQL is running
- Check
DATABASE_URLis correct in.env - Ensure the database exists:
psql -l - Run migrations:
npx prisma migrate dev - For Docker:
docker-compose logs db
Port already in use
Port already in use
Symptoms: “Port 4000 is already in use”Solutions:
- Change
PORTin.envto 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
Clerk authentication errors
Clerk authentication errors
Symptoms: 401 errors or “Invalid Clerk token”Solutions:
- Verify
CLERK_SECRET_KEYandCLERK_PUBLISHABLE_KEYare 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)
Supabase storage errors
Supabase storage errors
Symptoms: Photo upload fails or storage errorsSolutions:
- Verify
SUPABASE_URLandSUPABASE_ANON_KEYare correct - Check your Supabase project is active
- Ensure storage bucket is created in Supabase dashboard
- Verify bucket permissions allow public uploads
TypeScript compilation errors
TypeScript compilation errors
Symptoms: Build fails with type errorsSolutions:
- Run
npm installto ensure all dependencies are installed - Delete
node_modulesandpackage-lock.json, thennpm installagain - Run
npx prisma generateto 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
