This project uses Prisma with PostgreSQL. The authoritative schema lives in prisma/schema.prisma. This file explains the intent behind the current models.
- Model definitions: prisma/schema.prisma
- Migration history: prisma/migrations
- Prisma client setup: src/server/db.ts
Represents an authenticated app user.
Important fields:
idPrimary key. Comes from the auth system.emailUnique user email.githubUsernameOptional connected GitHub username.githubConnectedWhether GitHub has been connected for the user.
Relations:
projectsRepositories imported by this user.chatSessionsIssue chat sessions owned by this user.sandboxSessionsProject sandbox sessions owned by this user.
Represents one imported GitHub repository for one user.
Important fields:
idApp-level project id.repoOwnerGitHub repository owner.repoNameGitHub repository name.userIdOwner of the imported project.
Constraint:
@@unique([userId, repoOwner, repoName])Prevents the same user from importing the same repository more than once.
Relations:
chatSessionsPersistent issue chat sessions for this project.sandboxSessionsSandbox registry rows for this project.
Represents the persistent chat thread for one project issue.
Important fields:
projectIdThe project this issue chat belongs to.issueNumberGitHub issue number for the thread.statusCurrent logical status of the chat session.
Constraint:
@@unique([projectId, issueNumber])One stored chat session per project issue.
Why it exists:
- The issue workspace needs persistent history when the user refreshes or comes back later.
Represents one stored message inside a ChatSession.
Important fields:
sessionIdParent chat session.roleMessage role such as user, assistant, or system.bodyStored message text.toneOptional metadata for UI rendering.
Index:
@@index([sessionId, createdAt])Helps fetch a session's messages in creation order.
Why it exists:
- The issue workspace needs durable transcript storage, not just client-side state.
Represents the durable registry row for one project sandbox.
Important fields:
sessionIdApp-level sandbox session id used by routes and UI.sandboxIdE2B sandbox id used for reconnecting after memory loss.projectIdThe project that owns the sandbox.userIdThe user that owns the sandbox.previewUrlCurrent preview URL for the sandbox app.lastHeartbeatAtLast time the session was touched.startedAtReal sandbox start time.isStoppedLightweight stop marker instead of a full lifecycle enum.
Constraint:
projectId @uniqueThe app currently allows one sandbox row per project.
Why it exists:
- Sandbox ownership should survive server restarts.
- The app should be able to restore a live E2B sandbox from persisted metadata.
- Issue pages and project pages now share the same project sandbox.
schema.prisma is where Prisma models are defined and mapped to database tables. The app and generated Prisma client both depend on it, so model changes should start there.
The schema file is authoritative, but it is not the best place to explain product intent, tradeoffs, or higher-level relationships in prose. This document exists for that.
- Put actual model changes in prisma/schema.prisma
- Put migration history in prisma/migrations
- Put explanation and reasoning in this file