feat: Initial Diabetix application commit
- Add authentication with NextAuth v5 (credentials + email verification) - Implement dashboard with glycemia tracking and AI analysis - Add PDF report generation for Premium users - Implement Stripe integration for Premium subscriptions - Add responsive UI with Tailwind CSS and shadcn components - Database schema with Prisma ORM and PostgreSQL support - Real-time glycemia visualization with Recharts - Mobile-optimized entry form - User profile management with medical information - Subscription lifecycle management (create, cancel, webhook) - Email notifications with Resend - Feature gates for Free vs Premium plans Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
90
prisma/schema.prisma
Normal file
90
prisma/schema.prisma
Normal file
@@ -0,0 +1,90 @@
|
||||
generator client {
|
||||
provider = "prisma-client-js"
|
||||
output = "../src/generated/prisma"
|
||||
}
|
||||
|
||||
datasource db {
|
||||
provider = "sqlite"
|
||||
}
|
||||
|
||||
// ─── Auth ────────────────────────────────────────────────────────────────────
|
||||
|
||||
model User {
|
||||
id String @id @default(cuid())
|
||||
email String @unique
|
||||
emailVerified DateTime?
|
||||
name String
|
||||
passwordHash String
|
||||
plan String @default("FREE") // FREE | PREMIUM
|
||||
stripeId String? @unique
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
readings Reading[]
|
||||
patient Patient?
|
||||
dailyAnalysis DailyAnalysis?
|
||||
verifyTokens VerifyToken[]
|
||||
subscription Subscription?
|
||||
}
|
||||
|
||||
model VerifyToken {
|
||||
id String @id @default(cuid())
|
||||
token String @unique
|
||||
userId String
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
expiresAt DateTime
|
||||
createdAt DateTime @default(now())
|
||||
}
|
||||
|
||||
// ─── Domain ──────────────────────────────────────────────────────────────────
|
||||
|
||||
model Reading {
|
||||
id Int @id @default(autoincrement())
|
||||
userId String
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
measuredAt DateTime
|
||||
moment String
|
||||
value Float
|
||||
notes String?
|
||||
createdAt DateTime @default(now())
|
||||
|
||||
@@index([userId, measuredAt])
|
||||
}
|
||||
|
||||
model Patient {
|
||||
id String @id @default(cuid())
|
||||
userId String @unique
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
firstName String
|
||||
lastName String
|
||||
email String?
|
||||
birthDate DateTime?
|
||||
heightCm Int?
|
||||
weightKg Float?
|
||||
sex String?
|
||||
diabetesType String?
|
||||
treatment String?
|
||||
updatedAt DateTime @updatedAt
|
||||
}
|
||||
|
||||
model DailyAnalysis {
|
||||
id String @id @default(cuid())
|
||||
userId String @unique
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
content String
|
||||
generatedAt DateTime @default(now())
|
||||
}
|
||||
|
||||
model Subscription {
|
||||
id String @id @default(cuid())
|
||||
userId String @unique
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
stripeId String @unique
|
||||
stripePriceId String
|
||||
stripeCustomerId String
|
||||
status String // active | past_due | canceled | unpaid
|
||||
currentPeriodEnd DateTime
|
||||
canceledAt DateTime?
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
}
|
||||
Reference in New Issue
Block a user