Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/azahel79/Spartans-gym/llms.txt

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

The fastest path to a working local environment is to run the backend directly with Node.js and start the frontend dev server with Vite. You will have the full application — including a seeded admin account and four default membership plans — running at http://localhost:5173 in under ten minutes. If you prefer to containerise the backend, a Docker alternative is covered at the end of this page.
Never commit .env files to version control. Both backend/.env and frontend-spartans-gym/.env contain secrets. They are already listed in .gitignore — do not remove those entries.

Prerequisites

Before you begin, make sure the following are available on your machine:
RequirementVersionNotes
Node.js20 or higherUsed by both backend and frontend
MySQL8 or higherMust be running before you start the backend
Docker DesktopOptionalOnly needed for the Docker backend alternative
Cloudinary accountOptionalOnly needed if you want to test image uploads locally

Local Setup

1

Clone the repository

Clone the project and navigate into the monorepo root:
git clone https://github.com/azahel79/Spartans-gym.git
cd Spartans-gym/spartans-gym
2

Configure the backend environment

Copy the example file and fill in your local MySQL password:
cp backend/.env.example backend/.env
Open backend/.env and set the variables. A working local configuration looks like this:
PORT=3000
NODE_ENV=development
DATABASE_URL=mysql://root:TU_PASSWORD@localhost:3306/gym_database
JWT_SECRET=mi_clave_secreta_super_segura_para_jwt_2025
JWT_EXPIRES_IN=7d
FRONTEND_URL=http://localhost:5173
ALLOWED_ORIGINS=http://localhost:5173
CLOUDINARY_CLOUD_NAME=
CLOUDINARY_API_KEY=
CLOUDINARY_API_SECRET=
Replace TU_PASSWORD with your actual MySQL root (or user) password. Cloudinary variables can be left blank while developing locally — image uploads will simply be unavailable.
3

Install backend dependencies and set up the database

From the spartans-gym/ root, run all backend setup commands in sequence:
cd backend
npm install
npm run prisma:generate
npm run prisma:migrate
npm run seed
  • prisma:generate — builds the Prisma Client from your schema.
  • prisma:migrate — creates the gym_database schema and applies all migrations.
  • seed — creates the default admin user and four starter membership plans (Mensual, Trimestral, Semestral, Anual).
If the database does not exist yet, Prisma will create it automatically as long as the MySQL user in DATABASE_URL has CREATE DATABASE privileges.
4

Start the backend development server

Still inside backend/, start the API with hot-reload via nodemon:
npm run dev
The server will be available at http://localhost:3000. Verify it is healthy:
curl http://localhost:3000/api/health
You should receive a JSON response with "success": true.
5

Configure the frontend environment

Open a new terminal, navigate back to the monorepo root, then set up the frontend:
cd frontend-spartans-gym
cp ../.env.example .env 2>/dev/null || true
Create frontend-spartans-gym/.env with the following content:
VITE_API_URL=http://localhost:3000/api
If you are running the backend Docker container on port 3001, change this to VITE_API_URL=http://localhost:3001/api instead.
6

Install frontend dependencies and start Vite

npm install
npm run dev
Vite will print a local URL — by default http://localhost:5173.
7

Log in with the seeded admin account

Open http://localhost:5173 in your browser. Log in using the credentials created by the seed script:
FieldValue
Emailadmin@spartansgym.com
PasswordChangeMe123!
Change this password immediately after your first login — both locally and especially in production environments.

Verify Everything Is Working

Once logged in, confirm the following baseline functionality:
  • The Dashboard loads and shows charts.
  • The Clients module is accessible.
  • The Configuration → Plans module lists the four seeded plans: Mensual, Trimestral, Semestral, and Anual.
  • GET http://localhost:3000/api/health returns { "success": true }.

Docker Backend Alternative

If you prefer to run the backend inside a container while keeping MySQL on your host machine, use the following commands from the spartans-gym/ root:
1

Build the Docker image

docker build --no-cache -t spartans-backend ./backend
The multi-stage Dockerfile produces a lean node:20-alpine image. It runs npx prisma migrate deploy automatically on container start before launching npm start.
2

Update DATABASE_URL for Docker networking

When MySQL is running on your host and the backend is inside Docker, localhost inside the container points to the container itself — not your machine. Update backend/.env:
DATABASE_URL=mysql://root:TU_PASSWORD@host.docker.internal:3306/gym_database
3

Run the container

Map container port 3000 to host port 3001 (in case 3000 is already in use):
docker run --rm --env-file ./backend/.env -p 3001:3000 spartans-backend
Test the containerised backend:
curl http://localhost:3001/api/health
4

Point the frontend at port 3001

Update frontend-spartans-gym/.env to match the container’s exposed port:
VITE_API_URL=http://localhost:3001/api
Restart the Vite dev server for the change to take effect.

Available URLs

ServiceURL
Frontend (Vite)http://localhost:5173
Backend API (Node)http://localhost:3000/api/health
Backend API (Docker)http://localhost:3001/api/health
Prisma StudioRun npm run prisma:studio inside backend/

Build docs developers (and LLMs) love