feat: initial CodeBoard monorepo scaffold
Turborepo monorepo with npm workspaces: - apps/web: Next.js 14 frontend with Tailwind v4, SSE progress, doc viewer - apps/worker: BullMQ job processor (clone → parse → LLM generate) - packages/shared: TypeScript types - packages/parser: Babel-based AST parser (JS/TS) + regex (Python) - packages/llm: OpenAI/Anthropic provider abstraction + prompt pipeline - packages/diagrams: Mermaid architecture & dependency graph generators - packages/database: Prisma schema (PostgreSQL) - Docker multi-stage build (web + worker targets) All packages compile successfully with tsc and next build.
This commit is contained in:
24
packages/database/package.json
Normal file
24
packages/database/package.json
Normal file
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"name": "@codeboard/database",
|
||||
"version": "0.0.1",
|
||||
"private": true,
|
||||
"main": "./src/client.ts",
|
||||
"types": "./src/client.ts",
|
||||
"exports": {
|
||||
".": "./src/client.ts"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "echo 'database package uses prisma generate'",
|
||||
"db:generate": "prisma generate",
|
||||
"db:push": "prisma db push",
|
||||
"db:migrate": "prisma migrate dev",
|
||||
"clean": "rm -rf generated"
|
||||
},
|
||||
"dependencies": {
|
||||
"@prisma/client": "^6.3.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"prisma": "^6.3.0",
|
||||
"typescript": "^5.7"
|
||||
}
|
||||
}
|
||||
50
packages/database/prisma/schema.prisma
Normal file
50
packages/database/prisma/schema.prisma
Normal file
@@ -0,0 +1,50 @@
|
||||
datasource db {
|
||||
provider = "postgresql"
|
||||
url = env("DATABASE_URL")
|
||||
}
|
||||
|
||||
generator client {
|
||||
provider = "prisma-client-js"
|
||||
}
|
||||
|
||||
model Generation {
|
||||
id String @id @default(cuid())
|
||||
repoUrl String
|
||||
repoName String
|
||||
commitHash String
|
||||
status Status @default(QUEUED)
|
||||
progress Int @default(0)
|
||||
result Json?
|
||||
error String?
|
||||
costUsd Float?
|
||||
duration Int?
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
userId String?
|
||||
user User? @relation(fields: [userId], references: [id])
|
||||
viewCount Int @default(0)
|
||||
|
||||
@@unique([repoUrl, commitHash])
|
||||
@@index([repoUrl])
|
||||
@@index([status])
|
||||
}
|
||||
|
||||
model User {
|
||||
id String @id @default(cuid())
|
||||
githubId String @unique
|
||||
login String
|
||||
email String?
|
||||
avatarUrl String?
|
||||
createdAt DateTime @default(now())
|
||||
generations Generation[]
|
||||
}
|
||||
|
||||
enum Status {
|
||||
QUEUED
|
||||
CLONING
|
||||
PARSING
|
||||
GENERATING
|
||||
RENDERING
|
||||
COMPLETED
|
||||
FAILED
|
||||
}
|
||||
12
packages/database/src/client.ts
Normal file
12
packages/database/src/client.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
import { PrismaClient } from "@prisma/client";
|
||||
|
||||
const globalForPrisma = globalThis as unknown as { prisma: PrismaClient };
|
||||
|
||||
export const prisma =
|
||||
globalForPrisma.prisma ?? new PrismaClient();
|
||||
|
||||
if (process.env.NODE_ENV !== "production") {
|
||||
globalForPrisma.prisma = prisma;
|
||||
}
|
||||
|
||||
export { PrismaClient } from "@prisma/client";
|
||||
Reference in New Issue
Block a user