classDiagram
    class User {
        +int id
        +string name
        +string email
        +string role  // HR, CANDIDATE, ADMIN
        +datetime createdAt
    }

    class Company {
        +int id
        +string name
        +string industry
        +string size
    }

    class CandidateProfile {
        +int id
        +int userId
        +string degree
        +int yearsExperience
        +string skillTags
        +string resumeUrl
    }

    class JobPosition {
        +int id
        +int companyId
        +string title
        +string level
        +string requiredSkills
        +string description
        +string examPolicyId
    }

    class ExamPolicy {
        +string id
        +int totalQuestions
        +float easyRatio
        +float mediumRatio
        +float hardRatio
        +string typeRatio  // JSON: 单选/多选/编程 等比例
    }

    class Question {
        +int id
        +string content
        +string type
        +string skillTag
        +int difficulty
        +string source   // 企业题/通用题
        +bool isActive
    }

    class QuestionStats {
        +int questionId
        +int usedCount
        +float avgScore
        +float correctRate
        +float discrimination
        +float feedbackScore
        +datetime lastUsedAt
    }

    class ExamTemplate {
        +int id
        +int jobId
        +string policyId
        +string questionSlots  // JSON: 题目占位信息
    }

    class ExamSession {
        +int id
        +int candidateId
        +int jobId
        +int templateId
        +datetime startTime
        +datetime submitTime
        +float totalScore
        +string status  // ONGOING / DONE
    }

    class Answer {
        +int id
        +int sessionId
        +int questionId
        +string content
        +float score
        +float timeTaken
    }

    class QuestionFeedback {
        +int id
        +int questionId
        +int fromUserId
        +int sessionId
        +int rating  // 1~5
        +string comment
        +datetime createdAt
    }

    Company "1" o-- "0..*" User : employs
    User "1" o-- "0..1" CandidateProfile : has
    Company "1" o-- "0..*" JobPosition : posts
    JobPosition "1" o-- "0..*" ExamTemplate : uses
    ExamPolicy "1" o-- "0..*" ExamTemplate : governs

    Question "1" o-- "1" QuestionStats : has
    ExamTemplate "1" o-- "0..*" ExamSession : instantiates
    CandidateProfile "1" o-- "0..*" ExamSession : takes
    ExamSession "1" o-- "0..*" Answer : contains
    Question "1" o-- "0..*" Answer : answeredIn
    Question "1" o-- "0..*" QuestionFeedback : receives
    User "1" o-- "0..*" QuestionFeedback : writes
