Plataforma Social persists all of its data — users, posts, comments, ratings, and follower relationships — in a MySQL database managed through Prisma ORM. The Prisma schema lives atDocumentation 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.
server/prisma/schema.prisma and uses the mysql provider. Before starting the server for the first time you need a running MySQL instance, a dedicated database, and a successful migration run.
Requirements
- MySQL 8+ running locally (e.g. via Homebrew, Docker, or a native installer) or hosted remotely (e.g. PlanetScale, Railway, or AWS RDS).
- Node.js 18+ with the server dependencies installed (
npm installinsideserver/). - A
DATABASE_URLvalue configured inserver/.env— see the Environment Variables page for the correct format.
Setup steps
Create the MySQL database
Connect to your MySQL instance and create a dedicated database for the project. The name can be anything —
plataforma_social is used throughout this guide.Set DATABASE_URL in server/.env
Open (or create)
server/.env and add your connection string, replacing the placeholder values with your actual MySQL credentials and host.server/.env
Generate the Prisma client
From inside the This executes
server/ directory, run the generate script to compile the Prisma client from your schema. You must re-run this step any time you modify schema.prisma.npx prisma generate and writes the typed client into node_modules/@prisma/client.Run the initial migration
Apply the initial migration to create all tables in your database:This runs
npx prisma migrate dev --name init, which reads the SQL in server/prisma/migrations/20240611205243_init/migration.sql, applies it to the database, and records the migration in the _prisma_migrations table. On subsequent schema changes you can run the same command with a new --name value.Available npm scripts
All database-related commands (and the other server lifecycle scripts) are defined inserver/package.json:
| Script | Command | Purpose |
|---|---|---|
npm run generate | npx prisma generate | Regenerates the Prisma client after schema changes |
npm run migrate | npx prisma migrate dev --name init | Applies pending migrations to the development database |
npm run dev | nodemon | Starts the dev server with hot-reload via ts-node/esm (config: server/nodemon.json) |
npm run build | tsc | Compiles TypeScript source to dist/ |
npm run start | npm run build && node dist/index.js | Builds then starts the production server |
Database schema overview
The schema defines eight models acrossserver/prisma/schema.prisma. Every model uses a UUID primary key generated with @default(uuid()).
| Model | Description |
|---|---|
User | Platform account. Stores email (unique), username (unique), bcrypt-hashed password, optional bio, and avatar URL. |
Setting | One-to-one privacy and notification preferences per user. Controls profile visibility and in-app/email notification toggles. |
Post | A shared UI component entry authored by a User. Contains a title, description, and timestamps. |
Comment | A text comment left by a User on a Post. |
Technology | A named technology tag (e.g. “React”, “Tailwind”). Names are globally unique. |
Stack | Join table linking a Post to one or more Technology entries. Composite primary key (idPost, idTechnology). |
Rating | A numeric (Float) rating given by a User to a Post. |
Follower | Directed follow relationship between two User records. Composite primary key (idFollower, idFollowing). |
Cascade behavior
Most child records are configured withonDelete: Cascade, meaning they are automatically removed when their parent is deleted:
- Deleting a User cascades to:
Setting,Post,Comment,Rating. - Deleting a Post cascades to:
Comment,Stack,Rating. - The
Stackjoin table also cascades onTechnologydeletion. - Follower records use
RESTRICT— a user with followers or following relationships cannot be deleted until those rows are removed first.
The exact foreign-key constraints are defined in the initial migration file at
server/prisma/migrations/20240611205243_init/migration.sql. You can inspect that file to see the raw ALTER TABLE … ADD CONSTRAINT statements applied to MySQL.