@iprep/db
v1.1.4
Published
Database layer for iPrep (Prisma ORM + SQLite)
Readme
@iprep/db
Database layer for iPrep using Prisma ORM with SQLite (via libsql adapter).
Database Location
The database file lives at ~/.iprep/database/iprep.db by default (created automatically on first run). Override by setting the DATABASE_URL environment variable.
Setup
# Generate Prisma client
pnpm run generate
# Push schema to DB (creates DB file if missing)
pnpm run migrate
# Open Prisma Studio (visual DB browser)
pnpm run studioSchema
| Model | Description |
| -------------- | ------------------------------------------------------------- |
| Tutor | Tutor registry (id, name, description) |
| Session | User–tutor session tracking (unique per userId + tutorId) |
| Conversation | A conversation thread belonging to a session |
| Message | Individual messages within a conversation (role + content) |
| Document | Uploaded documents per tutor (.md / .txt), stored in aitutors |
Usage
import prisma from '@iprep/db';
import { getConversationsByUser, createMessage } from '@iprep/db';
// Direct Prisma client
const tutors = await prisma.tutor.findMany();
// Query helpers
const conversations = await getConversationsByUser(userId, tutorId);
await createMessage({ conversationId, role: 'user', content: 'Hello' });Notes
- Uses Prisma 7 with the
@prisma/adapter-libsqldriver adapter - SQLite only — no Postgres/MySQL support currently
- The
@iprep/dbclient is a lazy singleton (safe to import anywhere)
