Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/Avendaosander/Plataforma-social/llms.txt

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

Plataforma Social is split into two independent applications — the Express + Apollo Server backend and the Next.js 14 frontend — and each one reads its own set of environment variables from a separate file. The server reads from server/.env and the frontend reads from frontend/.env.local. Neither file is committed to version control, so you must create both locally before starting the project.

Server environment variables

The server application (server/.env) requires a database connection string and accepts an optional port override. These values are consumed at startup by Prisma and Express respectively.
DATABASE_URL
string
required
MySQL connection string used by Prisma to connect to your database. Follow the format mysql://USER:PASSWORD@HOST:PORT/DATABASE, replacing each segment with your actual credentials and host details.
PORT
number
HTTP port on which the Express server listens. Defaults to 4005 when not set — this is defined in server/src/index.ts as const PORT = process.env.PORT || 4005. Override this only if port 4005 is already in use on your machine.

Frontend environment variables

The Next.js frontend (frontend/.env.local) needs three variables: a secret for signing JWT session tokens, the canonical URL of the app itself, and the URL of the GraphQL API that NextAuth calls during authentication.
NEXTAUTH_SECRET
string
required
A random secret string used by NextAuth.js to sign and verify JWT session tokens. Must be set in every environment — NextAuth will throw an error and refuse to start in production if this value is missing.
NEXTAUTH_URL
string
required
The canonical base URL of your Next.js application. NextAuth uses this to build callback URLs and redirects. Set it to http://localhost:3000 for local development and to your deployed domain in production (e.g. https://plataforma-social.example.com).
API_ROUTE
string
required
The full URL of the GraphQL endpoint exposed by the backend server. This is read directly inside the NextAuth authorize function (frontend/app/api/auth/[...nextauth]/route.ts) when it calls fetch to log a user in. Set it to http://localhost:4005/graphql for local development.

Example environment files

Copy these templates into the respective directories and fill in your own values before starting either application.
server/.env
DATABASE_URL="mysql://root:password@localhost:3306/plataforma_social"
PORT=4005
frontend/.env.local
NEXTAUTH_SECRET="your-random-secret-here"
NEXTAUTH_URL="http://localhost:3000"
API_ROUTE="http://localhost:4005/graphql"
Never commit .env or .env.local files to version control. Both the server/ and frontend/ directories should have .gitignore entries covering these files. Exposing DATABASE_URL or NEXTAUTH_SECRET in a public repository is a serious security risk.
Apollo Client port mismatch — manual fix required.Both Apollo Client files in the frontend hardcode port 4000 as the GraphQL endpoint, but the server defaults to port 4005 (defined in server/src/index.ts as const PORT = process.env.PORT || 4005). This means Apollo Client queries will fail out of the box unless you update those files manually — API_ROUTE in .env.local only affects NextAuth authentication calls, not Apollo Client.frontend/app/lib/client.ts — update the uri on line 9:
// Before (incorrect):
uri: `http://localhost:4000/graphql`

// After (correct):
uri: `http://localhost:4005/graphql`
frontend/app/lib/apollo-wrapper.tsx — update the uri on line 11:
// Before (incorrect):
uri: "http://localhost:4000/graphql",

// After (correct):
uri: "http://localhost:4005/graphql",
If you have set a custom PORT in server/.env, use that port number instead of 4005 in both files above.
Generate a strong NEXTAUTH_SECRET with a single terminal command:
openssl rand -base64 32
Paste the output directly into your frontend/.env.local file. Run this command once per environment (local, staging, production) and keep each secret unique.

Build docs developers (and LLMs) love