Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/RoyGeova07/Credith/llms.txt

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

Credith ships with two Docker Compose files: docker-compose.yml for local development (database only, no service or website containers) and docker-compose-prod.yml for a fully self-contained production deployment. The production file builds all three services from source — credith_db (PostgreSQL 17), credith_service (Express API), and credith_website (Vite-compiled React SPA) — and wires them together with health checks and dependency ordering so the stack comes up cleanly in a single command.

Production Deployment

1

Build and Start the Production Stack

From the repository root, build all images and start every service in detached mode:
docker compose -f docker-compose-prod.yml up --build -d
The --build flag forces Docker to rebuild the credith_service and credith_website images even if cached layers exist. Use this on every deployment to pick up code changes.You can follow the startup logs to monitor progress:
docker compose -f docker-compose-prod.yml logs -f
2

Wait for the Database Health Check

The credith_service container will not start until credith_db passes its health check. The check runs pg_isready -U postgres every 5 seconds, with a timeout of 5 seconds and up to 10 retries (50 seconds maximum wait). Once PostgreSQL is accepting connections you will see the service and website containers start automatically.To verify the database is healthy:
docker inspect --format='{{.State.Health.Status}}' credith_db
Expected output: healthy
3

Migrations and Base Data Run Automatically

The credith_service container’s startup command runs pnpm migrate and pnpm seed:prd automatically before the API process launches. No manual migration or seeding steps are required on a fresh deployment.On startup the container will:
  1. Run sequelize-cli db:migrate — creates the cd schema and all tables.
  2. Run the 20260516000000-prd-base-data.js seeder — inserts the three roles (OWNER, ADMIN, EMPLOYEE), the initial company record, one store, one checkout machine, five product categories, and a default admin user.
  3. Start the Express server on port 3000.
The default admin account seeded is:
FieldValue
Emailadmin@credith.hn
Password123456
RoleOWNER
Change the default admin password immediately after your first login. The seeded password 123456 is for bootstrapping only and must not be used in a live environment.
4

Access the Running Application

Once the credith_service container finishes its startup sequence (migrations, seeding, and server launch), Credith is ready:
ServiceURLNotes
React Frontendhttp://your-host:4173Vite preview server serving the production build
Express APIhttp://your-host:3000Health check: GET / returns { "message": "Hello from the backend!" }
Swagger UIhttp://your-host:3000/api-docsAvailable while NODE_ENV=development; disable by setting NODE_ENV=production
To check all three containers are running:
docker compose -f docker-compose-prod.yml ps

Environment Variables

All environment variables for the production stack are defined in docker-compose-prod.yml. Replace the placeholder values — especially JWT_SECRET, DB_PASSWORD, and any Cloudinary credentials — before deploying to a live server.

credith_service — Express API

VariableValue in docker-compose-prod.ymlDescription
NODE_ENVdevelopmentSet to production to disable Swagger UI and enable production-mode logging.
PORT3000Port the Express server listens on inside the container.
JWT_SECRETvisca_barca_visca_catalunyaMust be changed. Secret key used to sign and verify JWT tokens.
DB_HOSTcredith_dbHostname of the PostgreSQL container (Docker service name).
DB_PORT5432PostgreSQL port.
DB_NAMEcredithName of the database.
DB_USERpostgresPostgreSQL user.
DB_PASSWORD123456Must be changed. PostgreSQL password. Must match POSTGRES_PASSWORD on credith_db.
DB_DIALECTpostgresSequelize dialect — always postgres for this project.
CORS_ORIGINhttp://localhost:4173The frontend origin that the API will accept cross-origin requests from. Update to your production domain.

credith_website — React Frontend (Build Arguments)

Build ArgumentValue in docker-compose-prod.ymlDescription
VITE_BASE_ROUTEhttp://localhost:3000Base URL for all API requests made by the frontend. Update to your API’s public URL.
VITE_CLOUDINARY_CLOUD_NAME(commented out)Optional. Your Cloudinary cloud name for product image uploads.
VITE_CLOUDINARY_UPLOAD_PRESET(commented out)Optional. Your Cloudinary unsigned upload preset.
Always replace the default JWT_SECRET value (visca_barca_visca_catalunya) before going live. Any attacker who knows your JWT secret can forge authentication tokens for any user in your system.

Docker Services

The production Compose file defines three services that together form the complete Credith stack:

credith_db — PostgreSQL 17

image: postgres:17
container_name: credith_db
ports:
  - 5432:5432
healthcheck:
  test: ["CMD-SHELL", "pg_isready -U postgres"]
  interval: 5s
  timeout: 5s
  retries: 10
Runs the official postgres:17 image. The database is initialized with POSTGRES_DB=credith, POSTGRES_USER=postgres, and POSTGRES_PASSWORD=123456. A pg_isready health check gates the startup of all dependent services. Port 5432 is exposed to the host for direct access with tools like psql or TablePlus.

credith_service — Express REST API

build:
  context: ./Service
  dockerfile: dockerfile
container_name: credith_service
ports:
  - 3000:3000
depends_on:
  credith_db:
    condition: service_healthy
Built from Service/dockerfile. The container starts only after credith_db reports a healthy status. On first launch the container’s startup command automatically runs pnpm migrate (creates all tables) and pnpm seed:prd (inserts the production baseline) before starting the Express server. All business logic, authentication (JWT + bcrypt), CAI validation, invoice generation, and payment plan management live in this service. The API is reachable at port 3000.

credith_website — React SPA (Vite)

build:
  context: ./Website
  dockerfile: dockerfile
  args:
    VITE_BASE_ROUTE: http://localhost:3000
container_name: credith_website
ports:
  - 4173:4173
depends_on:
  - credith_service
Built from Website/dockerfile. During the Docker build, Vite compiles the React application with VITE_BASE_ROUTE and any Cloudinary arguments baked into the static bundle. The compiled assets are served via vite preview on port 4173. Because Vite environment variables are inlined at build time, you must rebuild the image whenever VITE_BASE_ROUTE or the Cloudinary settings change.

Cloudinary Integration (Optional)

Credith supports uploading product images to Cloudinary. This is entirely optional — products without images display a placeholder in the frontend. To enable image uploads:
  1. Create a free Cloudinary account and note your Cloud Name.
  2. In the Cloudinary dashboard, create an unsigned upload preset and note its name.
  3. In docker-compose-prod.yml, uncomment and populate the two build args for the credith_website service:
credith_website:
  build:
    context: ./Website
    dockerfile: dockerfile
    args:
      VITE_BASE_ROUTE: http://your-api-domain:3000
      VITE_CLOUDINARY_CLOUD_NAME: your_cloud_name
      VITE_CLOUDINARY_UPLOAD_PRESET: your_upload_preset
  1. Rebuild the website image for the new environment variables to take effect:
docker compose -f docker-compose-prod.yml up --build -d credith_website
Because VITE_CLOUDINARY_CLOUD_NAME and VITE_CLOUDINARY_UPLOAD_PRESET are Vite build-time variables, they are embedded directly into the compiled JavaScript bundle. Changing them requires a full image rebuild — they cannot be injected at runtime.
Swagger UI (/api-docs) is only enabled when NODE_ENV=development. In production, set NODE_ENV=production in the credith_service environment block to disable the interactive API explorer and reduce the attack surface.

Build docs developers (and LLMs) love