Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/MateoNavarroMN/Balsamoa-Backend/llms.txt

Use this file to discover all available pages before exploring further.

Balsamoa Backend is a Node.js REST API built with Express 5 that serves as the complete backend for the Balsamoa clothing store. It manages a product catalog with size and color variant inventory, handles image uploads through Multer, and exposes two distinct API surfaces: a public read-only store API for the storefront and a full CRUD admin API for the management panel. The database layer runs on PostgreSQL hosted by Supabase, accessed through a connection pool managed by the pg driver.

Key features

Full CRUD for products

Create, read, update, and delete products through the admin API at /api/v1/admin/productos. Includes logical activation and deactivation so products can be hidden without permanent deletion.

Size and color variant inventory

Every product supports granular stock tracking per size (talles) and color (colores) combination via the variantes table, with a pre-loaded catalog of 5 sizes and 8 colors.

Image upload via Multer

Upload product images directly to the server’s public folder through POST /api/v1/admin/imagenes/subir. Images are served as static assets under /recursos and can be removed via DELETE /api/v1/admin/imagenes/:id.

Public store API with censored stock

The tienda routes at /api/v1/tienda/productos expose product data suitable for the storefront — full catalog details including variant availability — without surfacing raw admin fields. Supports an optional ?destacados=true query parameter to return only featured products.

Admin panel at /admin

A static HTML admin panel is served directly by Express at the /admin route, allowing store managers to browse products, create new entries, and manage inventory from a web UI with no separate frontend server required.

PostgreSQL via Supabase connection pool

Database connections are managed through a pg.Pool with SSL enforced (rejectUnauthorized: false), pointing at Supabase’s transaction pooler on port 6543 for reliable serverless-compatible connections.

Tech stack

TechnologyRole
Node.js (ES Modules)Runtime; all source files use .mjs extensions and native import/export syntax
Express 5HTTP framework for routing, middleware, and static file serving
PostgreSQL via pg driverRelational database access with a Pool for connection reuse
SupabaseHosted PostgreSQL database with a pooler endpoint for production connections
MulterMultipart form-data middleware for handling product image uploads
dotenvLoads DATABASE_URL and PUERTO from a .env file into process.env
nodemonDevelopment-time file watcher that restarts the server on source changes

Project structure

The repository follows a module-per-domain layout inside src/modulos/, keeping routes, controllers, and models co-located for each resource.
Balsamoa-Backend/
├── inicializar/
│   ├── .env.example          # Environment variable template
│   └── balsamoa.sql          # Database schema + seed data
├── src/
│   ├── server.mjs            # Express app entry point
│   ├── config/
│   │   └── conexion.bd.mjs   # pg.Pool setup with SSL
│   ├── modulos/
│   │   ├── productos/
│   │   │   ├── rutas.productos.mjs
│   │   │   ├── controlador.productos.mjs
│   │   │   └── modelo.productos.mjs
│   │   ├── categorias/
│   │   │   ├── rutas.categorias.mjs
│   │   │   ├── controlador.categorias.mjs
│   │   │   └── modelo.categorias.mjs
│   │   ├── talles/
│   │   │   ├── rutas.talles.mjs
│   │   │   ├── controlador.talles.mjs
│   │   │   └── modelo.talles.mjs
│   │   └── colores/
│   │       ├── rutas.colores.mjs
│   │       ├── controlador.colores.mjs
│   │       └── modelo.colores.mjs
│   └── public/
│       ├── admin/            # Static admin panel (index.html)
│       ├── tienda/           # Static store frontend (HTML pages)
│       └── recursos/         # Shared CSS, JS, fonts, and product images
├── package.json
├── pnpm-lock.yaml
└── vercel.json

API base URL

All API routes are versioned under the /api/v1/ prefix. Admin routes live under /api/v1/admin/ and public store routes under /api/v1/tienda/.
http://localhost:3003/api/v1/
Port 3003 is the value set in .env.example. The server code defaults to port 3000 when PUERTO is not set — set PUERTO=3003 in your .env file to match the configured default.

Build docs developers (and LLMs) love