<aside> <img src="/icons/checklist_green.svg" alt="/icons/checklist_green.svg" width="40px" />

</aside>

Persistence Model

// [ Role-Based Access Control (RBAC) ]
Table roles [note: 'Danh sách các vai trò trong hệ thống'] 
{
  id                int                      [pk, increment, note: 'Khóa chính role']  
  name              varchar                  [not null, note: 'Tên vai trò (learner/instructor/admin)']  
  description       text                     [note: 'Mô tả quyền của role']  
}
Table permissions [note: 'Danh sách quyền hạn chi tiết'] 
{
  id                int                      [pk, increment, note: 'Khóa chính permission']  
  name              varchar                  [unique, not null, note: 'Tên quyền (create_course, enroll, ...)']  
  description       text                     [note: 'Giải thích quyền hạn']  
}
Table role_permissions [note: 'Mapping giữa role và permission'] 
{
  role_id           int                      [ref: > roles.id, note: 'Role được gán quyền']  
  permission_id     int                      [ref: > permissions.id, note: 'Permission thuộc role']  
  indexes {
    (role_id, permission_id) [unique]
  } 
}
Table user_roles [note: 'Mapping giữa người dùng và role'] 
{
  user_id           uuid                      [ref: > users.id, note: 'Người dùng được gán role']  
  role_id           int                       [ref: > roles.id, note: 'Role gán cho người dùng']  
  assigned_at       timestamp                 [default: `now()`, note: 'Thời điểm gán role']  
  assigned_by       uuid                      [ref: > users.id, note: 'Ai gán role']  
  
  indexes { (user_id, role_id) [unique] } 
}

Domain Rules

Domain Use Cases

Create Role Command

Update Role Command

Delete Role Command

Create Permission Command

Update Permission Command

Remove Permission Command

Assign Permission To Role Command

Remove Permission From Role Command

Assign Role To User Command

Remove Role From User Command

List Roles Query

Get Role Detail Query