Files
car-workshop/Goal.md
T
2026-11-19 22:25:26 +01:00

2.1 KiB

Goal

Car repair workshop.

DB Schemas

All prices and rates are in øre

Customer:

{
    name: string
    email: string (email constraint)
    phone: string (phone constraint)

    cars: Car[]
}

Car:

{
    licensePlate: string
    model: CarModel (can get brand from here.)
    productionYear: int

    customerId: string
    customer: Relates to customer by id

    workOrder: WorkOrder[]
}

CarModel:

{
    name: string
    brand: CarBrand
}

CarBrand:

{
    name: string
}

Mechanic:

{
    name: string
    hourlyRate: int

    skills: MechanicToSkill[]
    workOrders: WorkOrderToMechanic[]
}

MechanicToSkill:

{
    mechanicId: string
    mechanic: Relates to mechanic by id
    skillId: string
    skill: Relates to skill by id

    // Prisma only:
    @@id([mechanicId, skillId])
}

MechanicSkill:

{
    name: string
    mechanics: MechanicToSkill[]
}

WorkOrderStatus (enum):

[
    OPEN,
    IN_PROGRESS,
    DONE
]

WorkOrder:

{
    currentMilage: int
    problem: string

    carId: string
    car: Relates to car by id
    
    mechanics: WorkOrderToMechanic[]
    sparePart: WorkOrderToSparePart[]
    
    // When workOrder is set to DONE it should use a transaction.
    invoice: Invoice?
    status: WorkOrderStatus

    createdAt: Created at
}

WorkOrderToMechanic:

{
    mechanicId: string
    mechanic: Relates to mechanic by id
    workOrderId: string
    workOrder: Relates to work order by id

    minutesWorked: int

    // Prisma only:
    @@id([mechanicId, workOrderId])
}

SparePart:

{
    name: string
    partNumber: string
    supplier: Supplier
    
    workOrder: WorkOrderToSparePart[]
}

Supplier:

{
    name: string
}

WorkOrderToSparePart:

{
    sparePartId: string
    sparePart: Relates to spare part by id
    workOrderId: string
    workOrder: Relates to work order by id

    quantity: int
    pricePerUnit: int

    // Prisma only:
    @@id([sparePartId, workOrderId])
}

Invoice:

{
    workOrderId: int (unique)
    workOrder: Relates to work order by id
    
    total: int
    
    paidDate: Date?
}