Internal ticketing app with CTI routing, severity levels, and n8n integration. Stack: Express + TypeScript + Prisma + PostgreSQL / React + Vite + Tailwind - JWT auth for users, API key auth for service accounts (Goddard/n8n) - CTI hierarchy (Category > Type > Item) for ticket routing - Severity 1-5, auto-close resolved tickets after 14 days - Gitea Actions CI/CD building separate server/client images - Production docker-compose.yml with Traefik integration Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
101 lines
2.3 KiB
Plaintext
101 lines
2.3 KiB
Plaintext
generator client {
|
|
provider = "prisma-client-js"
|
|
}
|
|
|
|
datasource db {
|
|
provider = "postgresql"
|
|
url = env("DATABASE_URL")
|
|
}
|
|
|
|
enum Role {
|
|
ADMIN
|
|
AGENT
|
|
SERVICE
|
|
}
|
|
|
|
enum TicketStatus {
|
|
OPEN
|
|
IN_PROGRESS
|
|
RESOLVED
|
|
CLOSED
|
|
}
|
|
|
|
model User {
|
|
id String @id @default(cuid())
|
|
username String @unique
|
|
email String @unique
|
|
passwordHash String
|
|
displayName String
|
|
role Role @default(AGENT)
|
|
apiKey String? @unique
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
assignedTickets Ticket[] @relation("AssignedTickets")
|
|
createdTickets Ticket[] @relation("CreatedTickets")
|
|
comments Comment[]
|
|
}
|
|
|
|
model Category {
|
|
id String @id @default(cuid())
|
|
name String @unique
|
|
types Type[]
|
|
tickets Ticket[]
|
|
}
|
|
|
|
model Type {
|
|
id String @id @default(cuid())
|
|
name String
|
|
categoryId String
|
|
category Category @relation(fields: [categoryId], references: [id], onDelete: Cascade)
|
|
items Item[]
|
|
tickets Ticket[]
|
|
|
|
@@unique([categoryId, name])
|
|
}
|
|
|
|
model Item {
|
|
id String @id @default(cuid())
|
|
name String
|
|
typeId String
|
|
type Type @relation(fields: [typeId], references: [id], onDelete: Cascade)
|
|
tickets Ticket[]
|
|
|
|
@@unique([typeId, name])
|
|
}
|
|
|
|
model Ticket {
|
|
id String @id @default(cuid())
|
|
title String
|
|
overview String
|
|
severity Int
|
|
status TicketStatus @default(OPEN)
|
|
categoryId String
|
|
typeId String
|
|
itemId String
|
|
assigneeId String?
|
|
createdById String
|
|
|
|
resolvedAt DateTime?
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
category Category @relation(fields: [categoryId], references: [id])
|
|
type Type @relation(fields: [typeId], references: [id])
|
|
item Item @relation(fields: [itemId], references: [id])
|
|
assignee User? @relation("AssignedTickets", fields: [assigneeId], references: [id])
|
|
createdBy User @relation("CreatedTickets", fields: [createdById], references: [id])
|
|
comments Comment[]
|
|
}
|
|
|
|
model Comment {
|
|
id String @id @default(cuid())
|
|
body String
|
|
ticketId String
|
|
authorId String
|
|
createdAt DateTime @default(now())
|
|
|
|
ticket Ticket @relation(fields: [ticketId], references: [id], onDelete: Cascade)
|
|
author User @relation(fields: [authorId], references: [id])
|
|
}
|