Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/J0S3-LEON/pf_pruebasAseguramientoCalid_SDD/llms.txt

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

MindFlow’s three components — the Next.js frontend, the NestJS backend, and the PostgreSQL database — are deployed independently in production. The compose.yml file at the repository root is a local-development convenience only and is not used in any production workflow. Each component can be hosted on the platform that best suits it, and they communicate over the public internet using environment variables that are configured per deployment.
ComponentRecommended providers
FrontendVercel — native Next.js support, automatic builds on push
BackendRender or Railway — Node.js web services with build/release hooks
DatabaseNeon, Supabase, or a provider-managed PostgreSQL instance

Database setup

Set up and migrate the database before deploying the backend. All subsequent backend deployments must run migrations before new replicas start serving traffic.
1

Create a managed PostgreSQL instance

Create a PostgreSQL database on your chosen provider (Neon, Supabase, or similar). Copy the full connection URL provided by the dashboard and store it as DATABASE_URL in your deployment platform’s secret store.
2

Enable TLS/SSL

Most managed PostgreSQL providers require TLS connections. Follow your provider’s documentation to append the necessary SSL parameters to DATABASE_URL. For example, Neon connections typically include ?sslmode=require.
3

Run migrations before starting replicas

Execute the following once per release, before any new backend replicas start accepting traffic. Running migrations as a pre-deploy or release command ensures the schema is updated before code that depends on it goes live:
npm ci && npm run prisma:generate --workspace @mindflow/backend && npm run prisma:migrate:deploy --workspace @mindflow/backend
Never run prisma migrate dev in production. That command is for local development only — it generates migration files, prompts interactively, and can reset the database. In production, always use prisma migrate deploy.

Backend deployment

The NestJS backend must be built from the repository root so that the @mindflow/shared workspace package is available during compilation.
1

Set the build root to the repository root

Configure your deployment platform to use the repository root (not apps/backend) as the build directory. The backend imports from @mindflow/shared, so the full monorepo context is required at build time.
2

Configure the build command

Use the following build command, which installs dependencies, compiles the shared package, generates the Prisma client, and compiles the backend:
npm ci && npm run build --workspace @mindflow/shared && npm run prisma:generate --workspace @mindflow/backend && npm run build --workspace @mindflow/backend
3

Configure the release / pre-deploy command

Set the release or pre-deploy hook to run migrations. This runs after the build succeeds but before traffic is switched to the new version:
npm run prisma:migrate:deploy --workspace @mindflow/backend
4

Configure the start command

Start the compiled backend in production mode:
npm run start:prod --workspace @mindflow/backend
5

Deploying with Docker

If your platform uses container-based deployments, point the platform at the backend Dockerfile. The build context must be the repository root:
docker build -f apps/backend/Dockerfile -t mindflow-backend .
The multi-stage apps/backend/Dockerfile produces a minimal node:20-alpine runner image that runs the compiled backend as a non-root user and listens on port 3001.
6

Set backend environment variables

Provide the following environment variables in your platform’s secret management UI or vault:
VariableNotes
NODE_ENVSet to production
DATABASE_URLFull PostgreSQL connection string with SSL parameters
JWT_SECRETRandom string ≥ 32 characters — must differ from AUTH_SECRET
FRONTEND_URLComma-separated list of allowed CORS origins (production domain only)
PORTThe platform typically assigns this automatically
AI_SERVICE_API_KEYRequired if the Task Decomposer feature is enabled

Frontend deployment on Vercel

1

Select Next.js as the framework

When creating a new Vercel project, choose Next.js as the framework preset. Vercel will automatically detect the Next.js application and configure build settings.
2

Set the project root to the repository root

Leave the Vercel project root pointing at the repository root — do not change it to apps/frontend. This preserves the npm workspace structure and allows the build to resolve @mindflow/shared.
3

Configure the build command

Override the default build command to build the shared package first:
npm run build --workspace @mindflow/shared && npm run build --workspace @mindflow/frontend
4

Set frontend environment variables

Add the following variables in the Vercel project settings before triggering a build:
VariableNotes
NEXT_PUBLIC_API_URLPublic URL of the backend including /api/v1, e.g. https://api.example.com/api/v1
NEXT_PUBLIC_APP_URLPublic URL of the frontend, e.g. https://example.com
AUTH_SECRETRandom string ≥ 32 characters — must differ from JWT_SECRET
AUTH_DEBUGSet to false
NEXT_PUBLIC_* variables are baked into the JavaScript bundle at build time. They must be set in Vercel before the build runs — updating them in the Vercel dashboard after a build has completed requires a new build to take effect. Never store secret values in NEXT_PUBLIC_* variables; they are visible to anyone who loads the page.

Pre-deployment verification

Run the following commands from the repository root to validate that the full build pipeline works before triggering a production deployment:
1

Full build check

Run a clean install and build of all packages:
npm ci && npm run prisma:generate --workspace @mindflow/backend && npm run build --workspace @mindflow/shared && npm run build --workspace @mindflow/backend && npm run build --workspace @mindflow/frontend
2

Run backend tests

Execute the backend test suite in band (no parallel workers) to catch any regressions before deploying:
npm test --workspace @mindflow/backend -- --runInBand
3

Build Docker images

Build the Docker images from the repository root to verify the Dockerfiles resolve correctly in the monorepo context:
docker build -f apps/backend/Dockerfile -t mindflow-backend .

Production checklist

Review every item below before promoting a release to production.
Critical security and correctness requirements:
  • .env is not versioned and all secrets are stored in the provider’s secret vault — never in the repository.
  • JWT_SECRET and AUTH_SECRET are different, randomly generated, and at least 32 characters long.
  • FRONTEND_URL contains only the authorized production domain(s) — no localhost or staging URLs.
  • AUTH_DEBUG=false and NODE_ENV=production are set in the backend and frontend environments.
  • prisma migrate deploy has finished successfully before any new replica starts serving traffic.
  • Both the backend and frontend builds pass from a clean npm ci install.
  • Backups, health checks, logs, and alerts are active on the database and backend service.

Build docs developers (and LLMs) love