The Plataforma Social backend uses Prisma ORM with a MySQL database. Every primary key across all models is a UUID generated automatically by Prisma’sDocumentation 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.
@default(uuid()) directive, ensuring globally unique identifiers without relying on auto-incrementing integers. The schema is defined in server/prisma/schema.prisma and the initial database state is established via a single migration generated with npm run migrate.
Full Schema
Model Overview
The schema contains 8 models that together represent users, their content, social interactions, and notification preferences.| Model | Description |
|---|---|
| User | Core account entity storing credentials, profile info, and timestamps. |
| Setting | Per-user privacy and notification preferences; one-to-one with User. |
| Post | A piece of content published by a user, containing a title and description. |
| Comment | A text comment left by a user on a specific post. |
| Technology | A named technology tag (e.g. “React”, “Node.js”) that can be applied to posts. |
| Stack | Join table linking a Post to one or more Technology entries (tech tags). |
| Rating | A numeric rating (Float) given by a user to a post. |
| Follower | Self-referential join table on User representing follow relationships. |
GraphQL API Coverage
Not all Prisma models are currently exposed through the GraphQL API. The Apollo Server schema inserver/src/graphql/typeDefs.ts defines only four object types:
| GraphQL Type | Backed by Prisma model |
|---|---|
User | User |
Setting | Setting |
UserWithSettings | User + Setting (joined at login) |
ResponseID | — (generic mutation confirmation envelope) |
The
Post, Comment, Technology, Stack, Rating, and Follower models exist in the database and are fully migrated, but they are not yet exposed as GraphQL types. They are ready for future API development. See the Types reference for the full SDL of what is currently available.Key Relationships
User → Setting
EachUser has at most one Setting record (Setting?). The Setting row is created automatically when a new user registers, using sensible defaults for all notification toggles.
User → Posts
AUser has many Post records (Post[]). Each post stores the author’s idUser as a foreign key.
Post → Comments, Ratings, and Stacks
APost has three child collections:
Comment[]— text comments submitted by any user.Rating[]— numeric score entries submitted by any user.Stack[]— technology tag entries linking the post toTechnologyrecords.
Stack — Post ↔ Technology (join table)
Stack is a pure join table with a composite primary key of [idPost, idTechnology]. It has no surrogate UUID — the combination of the two foreign keys is itself the unique identifier. This means a given technology can only be tagged once per post.
Follower — Self-referential User relationship
Follower is a self-referential join table on User with a composite primary key of [idFollower, idFollowing]. It models directed follow relationships using two named Prisma relations:
UserFollowers— the set of users who follow a given user (followersfield onUser).UserFollowing— the set of users that a given user follows (followingfield onUser).
The
Follower foreign keys use onDelete: Restrict (the MySQL default applied by Prisma when no onDelete is specified for self-referential relations). This means you must unfollow before deleting either the follower or the followed account, or handle deletion order in application logic.Cascade Delete Behavior
Prisma enforces referential integrity at the database level throughON DELETE CASCADE constraints, defined in onDelete: Cascade on the relation fields.
| Deleted record | Automatically deletes |
|---|---|
User | Setting, all Post records, all Comment records, all Rating records |
Post | all Comment records on that post, all Rating records on that post, all Stack entries for that post |
Technology | all Stack entries referencing that technology |
Migrations
The initial database structure lives at:schema.prisma, apply and record the change as a new migration with: