Buildml uses PostgreSQL as its primary database and Prisma ORM for schema management, migrations, and type-safe queries. The Prisma client is initialised once as a singleton inDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/Praashh/buildml/llms.txt
Use this file to discover all available pages before exploring further.
src/db/client.ts using the @prisma/adapter-pg driver adapter, which provides a native pg connection pool rather than Prisma’s default query engine binary.
The Prisma client is generated to
../generated/prisma (relative to the schema file), not the default node_modules/@prisma/client. Import it as import { PrismaClient } from "../../generated/prisma/client" or via the ~/db path alias which re-exports the singleton prisma instance.Prisma Configuration
The data source and generator are declared at the top ofprisma/schema.prisma:
prisma/schema.prisma
Database Client Singleton
The filesrc/db/client.ts creates the single shared PrismaClient instance used across the entire application:
src/db/client.ts
PrismaPg from @prisma/adapter-pg connects directly via the pg Node.js driver, bypassing the Rust query engine binary. This improves cold-start performance in serverless environments such as Vercel.
Schema Models
Buildml’s schema defines six models. Three (Account, Session, VerificationToken) are required by the NextAuth.js Prisma adapter. The remaining three (ProblemSet, Problem, Submission) model the core challenge platform data.
User
Represents an authenticated user. Extended with asubmissions relation beyond the standard NextAuth.js fields.
prisma/schema.prisma
| Field | Type | Notes |
|---|---|---|
id | String | CUID, primary key |
name | String? | Display name from Google OAuth |
email | String? | Unique; sourced from Google account |
emailVerified | DateTime? | Set automatically in the createUser NextAuth event |
image | String? | Profile photo URL from Google |
accounts | Account[] | Linked OAuth provider accounts |
sessions | Session[] | Active sessions |
submissions | Submission[] | All code submissions by this user |
ProblemSet
A named collection of related coding problems (e.g. “NumPy Fundamentals”, “Neural Networks”).prisma/schema.prisma
| Field | Type | Notes |
|---|---|---|
id | String | CUID, primary key |
title | String | Human-readable name (e.g. "NumPy Fundamentals") |
slug | String | URL-safe unique identifier (e.g. "numpy") |
description | String? | Stored as TEXT; markdown supported |
problems | Problem[] | Problems belonging to this set |
createdAt | DateTime | Auto-set on creation |
updatedAt | DateTime | Auto-updated on every write |
Problem
A single coding challenge, containing the template shown to the user and the test suite used for evaluation.prisma/schema.prisma
| Field | Type | Notes |
|---|---|---|
id | String | CUID, primary key |
title | String | Display title |
slug | String | Unique slug; used as task_id when calling the executor |
description | String | Problem statement in markdown (TEXT) |
difficulty | String | One of Easy, Medium, or Hard |
templateCode | String | Starter Python code shown in the editor (TEXT) |
testCode | String | Pytest-style test script run by the executor (TEXT) |
order | Int | Position within the problem set; defaults to 0 |
problemSetId | String? | Foreign key to ProblemSet |
submissions | Submission[] | All submissions for this problem |
Submission
Persists the result of a user’s code submission. Created withstatus: "PENDING" and updated asynchronously by the QStash webhook handler.
prisma/schema.prisma
| Field | Type | Notes |
|---|---|---|
id | String | CUID, primary key |
problemId | String | Foreign key to Problem |
userId | String | Foreign key to User |
code | String | The submitted Python code (TEXT) |
status | String | PENDING → PASS | FAIL | ERROR |
output | String? | Human-readable test result summary (TEXT) |
createdAt | DateTime | Submission timestamp |
Account, Session, VerificationToken
These three models are required by the NextAuth.js Prisma Adapter and must not be removed or renamed.prisma/schema.prisma
CLI Commands
The following commands are available viabun run <script> (defined in package.json):
db:push
Introspects the current
schema.prisma and pushes all changes directly to the database without creating a migration file. Best suited for rapid iteration during development.db:migrate
Generates a new SQL migration file in
prisma/migrations/ without applying it. Use this to review the SQL before applying to a production database.db:generate
Runs
prisma migrate dev, which creates and applies a new migration, then regenerates the Prisma client in ../generated/prisma. Run this after every schema change.db:studio
Opens Prisma Studio — a local web-based GUI for browsing and editing database records.
Seeding Sample Data
Theprisma/ directory contains three seed scripts for populating the database with starter problems:
| Script | Content |
|---|---|
prisma/seed.ts | Base seed — creates the initial problem sets and shared configuration |
prisma/seed-numpy.ts | Populates the NumPy Fundamentals problem set with array manipulation challenges |
prisma/seed-nn.ts | Populates the Neural Networks problem set with deep learning implementation challenges |
bun:
Seed scripts use the same
prisma singleton from src/db/client.ts. Make sure DATABASE_URL is set in your .env before running them, and that bun run db:generate has been run at least once so the Prisma client exists at generated/prisma/.