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.

This guide walks you through cloning the repository, configuring environment variables, and running both the Express/Apollo GraphQL server and the Next.js frontend locally. By the end you will have a fully working development environment with the API available at http://localhost:4005/graphql and the UI at http://localhost:3000.

Prerequisites

Before you begin, make sure the following are installed and available on your machine:
  • Node.js 18 or later — required by both the server (TypeScript/ESM) and the Next.js 14 frontend
  • MySQL database — a running instance you can connect to with a valid connection string
  • Git — to clone the repository

Setup Steps

1

Clone the repository

Clone the project from GitHub and navigate into the project root:
git clone https://github.com/Avendaosander/Plataforma-social.git
cd Plataforma-social
2

Install server dependencies

Move into the server directory and install all Node.js dependencies:
cd server && npm install
3

Configure the server environment

Create a .env file inside the server directory with your MySQL connection string:
# server/.env
DATABASE_URL="mysql://USER:PASSWORD@HOST:PORT/DATABASE"
Replace USER, PASSWORD, HOST, PORT, and DATABASE with the credentials for your MySQL instance. Then generate the Prisma client and run the initial migration:
npm run generate
npm run migrate
npm run generate creates the type-safe Prisma client from schema.prisma, and npm run migrate applies the schema to your database (creating all tables).
4

Start the server

Start the development server with hot-reload via nodemon:
npm run dev
The server listens on port 4005 by default (or the value of process.env.PORT). You should see:
Server running in port http://localhost:4005
The GraphQL endpoint is available at http://localhost:4005/graphql.
5

Install frontend dependencies

Open a new terminal, navigate to the frontend directory, and install dependencies:
cd ../frontend && npm install
6

Configure the frontend environment

Create a .env.local file inside the frontend directory:
# frontend/.env.local
NEXTAUTH_SECRET="your-random-secret-string"
NEXTAUTH_URL="http://localhost:3000"
API_ROUTE="http://localhost:4005/graphql"
  • NEXTAUTH_SECRET — a random string used to sign NextAuth session tokens (any secure random value works)
  • NEXTAUTH_URL — the canonical URL of the Next.js app, used by NextAuth for redirects
  • API_ROUTE — the full URL of the GraphQL endpoint that Apollo Client will send requests to
The Apollo Client files frontend/app/lib/apollo-wrapper.tsx and frontend/app/lib/client.ts currently hardcode http://localhost:4000/graphql as the GraphQL URI, but the server runs on port 4005 by default. The API_ROUTE env var above is correct, but it is not read by those files — they use the hardcoded value. You must manually update the uri in both files to http://localhost:4005/graphql (or your chosen PORT) before queries from the frontend will reach the running server.
7

Start the frontend

Run the Next.js development server:
npm run dev
The frontend is now available at http://localhost:3000. Navigating to /home will redirect unauthenticated users to the sign-in page (protected by Next.js middleware).
The Apollo Server GraphQL playground (Sandbox) is available in your browser at http://localhost:4005/graphql. You can use it to explore the schema, run queries, and inspect resolver responses interactively — no additional tooling required.
The default server port is 4005, defined in server/src/index.ts as const PORT = process.env.PORT || 4005. You can override it by setting a PORT variable in server/.env.

Quick Test

Once both services are running, send the following query in the GraphQL playground or any GraphQL client to confirm the server is up and the database connection is working:
query {
  getUsers {
    id
    username
    email
  }
}
A successful response returns an array of registered users (empty array [] on a fresh database). Any connection or schema error at this stage usually points to an incorrect DATABASE_URL or a skipped migration step.

Build docs developers (and LLMs) love