Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: ERD and schema update #13

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
113 changes: 113 additions & 0 deletions ERD.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
```mermaid
erDiagram
COMPANY {
int id PK
string name
string location
text company_description
string contact_info
}
EMPLOYEE {
int id PK
int company_id FK
string name
string email
string role
boolean is_active
}
POSITION {
int id PK
int company_id FK
int interview_flow_id FK
string title
text description
string status
boolean is_visible
text job_description
text requirements
text responsibilities
numeric salary_min
numeric salary_max
string employment_type
text benefits
date application_deadline
}
INTERVIEW_FLOW {
int id PK
string description
}
INTERVIEW_STEP {
int id PK
int interview_flow_id FK
int interview_type_id FK
string name
int order_index
}
INTERVIEW_TYPE {
int id PK
string name
text description
}
CANDIDATE {
int id PK
string firstName
string lastName
string email
string phone
string address
}
APPLICATION {
int id PK
int position_id FK
int candidate_id FK
date application_date
string status
text notes
timestamp created_at
timestamp updated_at
}
APPLICATION_STATUS_HISTORY {
int id PK
int application_id FK
string status
timestamp changed_at
}
INTERVIEW {
int id PK
int application_id FK
int interview_step_id FK
date interview_date
string result
int score
text notes
timestamp created_at
timestamp updated_at
}
INTERVIEW_EMPLOYEE {
int id PK
int interview_id FK
int employee_id FK
}
INTERVIEW_FEEDBACK {
int id PK
int interview_id FK
int employee_id FK
text feedback
timestamp created_at
}

COMPANY ||--o{ EMPLOYEE : employs
COMPANY ||--o{ POSITION : offers
POSITION ||--|| INTERVIEW_FLOW : assigns
INTERVIEW_FLOW ||--o{ INTERVIEW_STEP : contains
INTERVIEW_STEP ||--|| INTERVIEW_TYPE : uses
POSITION ||--o{ APPLICATION : receives
CANDIDATE ||--o{ APPLICATION : submits
APPLICATION ||--o{ INTERVIEW : has
APPLICATION ||--o{ APPLICATION_STATUS_HISTORY : tracks
INTERVIEW ||--|| INTERVIEW_STEP : consists_of
INTERVIEW ||--o{ INTERVIEW_EMPLOYEE : involves
INTERVIEW ||--o{ INTERVIEW_FEEDBACK : receives
EMPLOYEE ||--o{ INTERVIEW_EMPLOYEE : participates
EMPLOYEE ||--o{ INTERVIEW_FEEDBACK : provides
```
154 changes: 123 additions & 31 deletions backend/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -6,52 +6,144 @@

generator client {
provider = "prisma-client-js"
binaryTargets = ["native", "debian-openssl-3.0.x"]
}

datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}

model Company {
id Int @id @default(autoincrement())
name String
location String
companyDescription String
contactInfo String
employees Employee[]
positions Position[]
}

model Employee {
id Int @id @default(autoincrement())
companyId Int
name String
email String
role String
isActive Boolean
company Company @relation(fields: [companyId], references: [id])
interviews InterviewEmployee[]
feedbacks InterviewFeedback[]
}

model Position {
id Int @id @default(autoincrement())
companyId Int
interviewFlowId Int
title String
description String
status String
isVisible Boolean
jobDescription String
requirements String
responsibilities String
salaryMin Float
salaryMax Float
employmentType String
benefits String
applicationDeadline DateTime
company Company @relation(fields: [companyId], references: [id])
interviewFlow InterviewFlow @relation(fields: [interviewFlowId], references: [id])
applications Application[]
}

model InterviewFlow {
id Int @id @default(autoincrement())
description String
steps InterviewStep[]
positions Position[]
}

model InterviewStep {
id Int @id @default(autoincrement())
interviewFlowId Int
interviewTypeId Int
name String
orderIndex Int
interviewFlow InterviewFlow @relation(fields: [interviewFlowId], references: [id])
interviewType InterviewType @relation(fields: [interviewTypeId], references: [id])
interviews Interview[]
}

model InterviewType {
id Int @id @default(autoincrement())
name String
description String
steps InterviewStep[]
}

model Candidate {
id Int @id @default(autoincrement())
firstName String @db.VarChar(100)
lastName String @db.VarChar(100)
email String @unique @db.VarChar(255)
phone String? @db.VarChar(15)
address String? @db.VarChar(100)
educations Education[]
workExperiences WorkExperience[]
resumes Resume[]
}

model Education {
id Int @id @default(autoincrement())
firstName String
lastName String
email String
phone String
address String
applications Application[]
}

model Application {
id Int @id @default(autoincrement())
institution String @db.VarChar(100)
title String @db.VarChar(250)
startDate DateTime
endDate DateTime?
positionId Int
candidateId Int
applicationDate DateTime
status String
notes String
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
position Position @relation(fields: [positionId], references: [id])
candidate Candidate @relation(fields: [candidateId], references: [id])
interviews Interview[]
statusHistory ApplicationStatusHistory[]
}

model ApplicationStatusHistory {
id Int @id @default(autoincrement())
applicationId Int
status String
changedAt DateTime @default(now())
application Application @relation(fields: [applicationId], references: [id])
}

model Interview {
id Int @id @default(autoincrement())
applicationId Int
interviewStepId Int
interviewDate DateTime
result String
score Int
notes String
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
application Application @relation(fields: [applicationId], references: [id])
interviewStep InterviewStep @relation(fields: [interviewStepId], references: [id])
employees InterviewEmployee[]
feedbacks InterviewFeedback[]
}

model WorkExperience {
model InterviewEmployee {
id Int @id @default(autoincrement())
company String @db.VarChar(100)
position String @db.VarChar(100)
description String? @db.VarChar(200)
startDate DateTime
endDate DateTime?
candidateId Int
candidate Candidate @relation(fields: [candidateId], references: [id])
interviewId Int
employeeId Int
interview Interview @relation(fields: [interviewId], references: [id])
employee Employee @relation(fields: [employeeId], references: [id])
}

model Resume {
model InterviewFeedback {
id Int @id @default(autoincrement())
filePath String @db.VarChar(500)
fileType String @db.VarChar(50)
uploadDate DateTime
candidateId Int
candidate Candidate @relation(fields: [candidateId], references: [id])
interviewId Int
employeeId Int
feedback String
createdAt DateTime @default(now())
interview Interview @relation(fields: [interviewId], references: [id])
employee Employee @relation(fields: [employeeId], references: [id])
}
Loading