lib/generated/prisma and uses the @prisma/adapter-pg driver for a serverless-compatible connection.
Setting up the database
Provision a PostgreSQL database
ForgeAI recommends Neon for serverless PostgreSQL. Create a project in the Neon dashboard and copy the connection string.
Data models
The schema defines three models:Project, Message, and CodeFragment. Each project contains messages, and each message may have an associated code fragment produced by the AI.
Project
Represents a single app-building session owned by a user.| Field | Type | Description |
|---|---|---|
id | String (uuid) | Primary key, auto-generated. |
name | String | Human-readable project name. |
sandboxId | String? | E2B sandbox ID associated with this project (optional, max 64 chars). |
imageUrl | String? | Optional cover image URL. |
userId | String | Clerk user ID of the project owner. |
createdAt | DateTime | Timestamp of creation. |
updatedAt | DateTime | Timestamp of last update. |
Project has many Message records. Deleting a project cascades and deletes all its messages.
Message
Represents a single turn in the conversation — either a user prompt or an AI response.| Field | Type | Description |
|---|---|---|
id | String (uuid) | Primary key, auto-generated. |
content | String | Text content of the message. |
role | MessageRole | USER or ASSISTANT. |
type | MessageType | RESULT (successful AI output) or ERROR (failed generation). |
userId | String | Clerk user ID associated with this message. |
imageUrl | String? | Optional image attached to the message (e.g. a design screenshot). |
projectId | String | Foreign key linking to the parent Project. |
createdAt | DateTime | Timestamp of creation. |
updatedAt | DateTime | Timestamp of last update. |
Message optionally has one CodeFragment. Deleting a message cascades and deletes its code fragment.
CodeFragment
Stores the generated code and sandbox details produced by an AI response.| Field | Type | Description |
|---|---|---|
id | String (uuid) | Primary key, auto-generated. |
messageId | String (unique) | Foreign key linking to the parent Message. One-to-one relationship. |
sandboxUrl | String | URL of the live E2B sandbox preview. |
sandboxId | String? | E2B sandbox ID (optional, max 64 chars). |
title | String | Title of the generated app. |
files | Json | Map of file paths to file contents for the generated app. |
imageUrl | String? | Optional screenshot of the generated app. |
designSpec | Json? | Optional design specification extracted from an uploaded screenshot. |
createdAt | DateTime | Timestamp of creation. |
updatedAt | DateTime | Timestamp of last update. |
Schema overview
schema.prisma
Related pages
Environment Variables
Set DATABASE_URL and other required secrets.
E2B Sandbox
Learn how sandboxes are created and managed for live previews.