Jeen optimized kyri his code backend+front.
Some checks failed
CI Pipeline / Setup Dependencies (push) Has been cancelled
CI Pipeline / Check Dependency Updates (push) Has been cancelled
CI Pipeline / Lint & Format Check (push) Has been cancelled
CI Pipeline / Unit Tests (push) Has been cancelled
CI Pipeline / Integration Tests (push) Has been cancelled
CI Pipeline / Build Application (push) Has been cancelled
CI Pipeline / Docker Build & Test (push) Has been cancelled
CI Pipeline / Security Scan (push) Has been cancelled
CI Pipeline / Deployment Readiness (push) Has been cancelled

This commit is contained in:
Jeen Koster 2025-08-05 21:44:32 +02:00
parent 6be97672f9
commit 09c983d605
42 changed files with 22403 additions and 1981 deletions

View file

@ -0,0 +1,3 @@
# Please do not edit this file manually
# It should be added in your version-control system (i.e. Git)
provider = "postgresql"

View file

@ -20,8 +20,8 @@ enum Plan {
// Enum for batch processing status
enum BatchStatus {
PROCESSING
DONE
ERROR
COMPLETED
FAILED
}
// Enum for individual image processing status
@ -51,13 +51,15 @@ model User {
quotaRemaining Int @default(50) @map("quota_remaining") // Monthly quota
quotaResetDate DateTime @default(now()) @map("quota_reset_date") // When quota resets
isActive Boolean @default(true) @map("is_active")
stripeCustomerId String? @unique @map("stripe_customer_id") // Stripe customer ID
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @updatedAt @map("updated_at")
// Relations
batches Batch[]
payments Payment[]
apiKeys ApiKey[]
batches Batch[]
payments Payment[]
apiKeys ApiKey[]
downloads Download[]
@@map("users")
@@index([emailHash])
@ -69,6 +71,7 @@ model User {
model Batch {
id String @id @default(uuid())
userId String @map("user_id")
name String? // Batch name
status BatchStatus @default(PROCESSING)
totalImages Int @default(0) @map("total_images")
processedImages Int @default(0) @map("processed_images")
@ -79,8 +82,9 @@ model Batch {
completedAt DateTime? @map("completed_at")
// Relations
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
images Image[]
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
images Image[]
downloads Download[]
@@map("batches")
@@index([userId])
@ -101,6 +105,9 @@ model Image {
dimensions Json? // Width/height as JSON object
mimeType String? @map("mime_type")
s3Key String? @map("s3_key") // S3 object key for storage
originalImageUrl String? @map("original_image_url") // URL to original image
processedImageUrl String? @map("processed_image_url") // URL to processed image
generatedFilename String? @map("generated_filename") // AI-generated filename
processingError String? @map("processing_error") // Error message if processing failed
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @updatedAt @map("updated_at")
@ -176,4 +183,30 @@ model ApiKeyUsage {
@@map("api_key_usage")
@@index([apiKeyId])
@@index([createdAt])
}
// Downloads table - Track ZIP file downloads
model Download {
id String @id @default(uuid())
batchId String @map("batch_id")
userId String @map("user_id")
zipPath String @map("zip_path") // Path to generated ZIP file
fileSize Int @map("file_size") // ZIP file size in bytes
totalSize Int? @map("total_size") // Total size of all files
fileCount Int? @map("file_count") // Number of files in ZIP
downloadUrl String? @map("download_url") // Pre-signed download URL
status String @default("PENDING") // PENDING, READY, EXPIRED, FAILED
expiresAt DateTime @map("expires_at") // When download link expires
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @updatedAt @map("updated_at")
// Relations
batch Batch @relation(fields: [batchId], references: [id], onDelete: Cascade)
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
@@map("downloads")
@@index([batchId])
@@index([userId])
@@index([status])
@@index([expiresAt])
}

View file

@ -49,7 +49,7 @@ async function main() {
const completedBatch = await prisma.batch.create({
data: {
userId: users[0].id,
status: BatchStatus.DONE,
status: BatchStatus.COMPLETED,
totalImages: 5,
processedImages: 4,
failedImages: 1,
@ -89,7 +89,7 @@ async function main() {
const errorBatch = await prisma.batch.create({
data: {
userId: users[2].id,
status: BatchStatus.ERROR,
status: BatchStatus.FAILED,
totalImages: 3,
processedImages: 0,
failedImages: 3,