Skip to content

Commit a92abcc

Browse files
committed
refactor(api): remove organization entity
1 parent 49f31c7 commit a92abcc

File tree

73 files changed

+109
-2714
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+109
-2714
lines changed

docs/Entity Relationship Diagram.md

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,27 @@
11
# Entity Relationship Diagram
22

3-
Here are the entity relationship diagrams for the Viraha project. The diagrams are created using the [Mermaid](https://mermaid-js.github.io/mermaid/#/) library.
3+
Here are the entity relationship diagrams for the Vidya project. The diagrams are created using the [Mermaid](https://mermaid-js.github.io/mermaid/#/) library.
44

5-
## Organization and Permission Management
5+
## School and Permission Management
66

7-
*Organization* is the top-level entity that represents a company. Each organization can have multiple schools. For example "Bhaktilata" and "Archana" can be two schools under the same organization "Prabhupada School".
7+
*School* is the top-level entity representing an educational institution. Each school can have multiple *Courses*, *Groups*, and other related entities.
88

9-
*School* is a sub-entity of Organization. School belongs to one organization. Each school can have multiple *Courses** *Groups* and so on.
9+
*Role* is a set of permissions that can be assigned to a user. Each role can have multiple permissions, for example: "create courses", "create groups", "edit lessons" etc. Roles can be defined at the school level. Users can have multiple roles in different schools.
1010

11-
*Role* is a set of permissions that can be assigned to a user. Each role can have multiple permissions, for example: "create coures", "create groups", "edit lessons" etc. Roles can be defined at the organization level or at the school level. Roles can be assigned to users. A user can have multiple roles. For example, a user can have a "teacher" role in one school and a "student" role in another school.
12-
13-
*User* is a person who can log in to the system. A user can be assigned to one or more roles. A user can be a member of one or more schools. A user can have different roles in different schools.
11+
*User* is a person who can log in to the system. A user can be assigned to one or more roles and can be a member of one or more schools.
1412

1513
```mermaid
1614
erDiagram
17-
Organization {
18-
uuid id PK
19-
string name
20-
}
21-
2215
School {
2316
uuid id PK
2417
string name
25-
string organizationId FK
2618
}
2719
2820
Role {
2921
uuid id PK
3022
string name
3123
string description
32-
string organizationId
33-
opt[string] schoolId
24+
string schoolId FK
3425
string[] permissions
3526
}
3627
@@ -42,19 +33,15 @@ erDiagram
4233
string avatarUrl
4334
}
4435
45-
4636
UserRole {
4737
uuid id PK
4838
string userId FK
4939
string roleId FK
5040
}
5141
52-
Organization ||--o{ School : ""
53-
Organization ||--o{ Role : ""
5442
School ||--o{ Role : ""
5543
User }o--o{ UserRole : ""
5644
Role }o--o{ UserRole : ""
57-
5845
```
5946

6047
## School Management
@@ -63,9 +50,9 @@ erDiagram
6350

6451
*Group* is a set of students who are studying the same course. Each *Course* can have multiple *Groups*.
6552

66-
*Lession* is a part of a course. Each course can have multiple lessons. For example, "Chapter 1", "Chapter 2" etc can be lessons in the "Bhagavad Gita" course. Each lesson can have a title and content.
53+
*Lesson* is a part of a course. Each course can have multiple lessons. For example, "Chapter 1", "Chapter 2" etc., can be lessons in the "Bhagavad Gita" course. Each lesson can have a title and content.
6754

68-
*Enrollment* is a record that links a user to a group and a rele. Each enrollment can have a status like "active", "inactive", "graduated" etc. Each enrollment can have a number of lessons opened.
55+
*Enrollment* is a record that links a user to a group and a role. Each enrollment can have a status like "active", "inactive", "graduated", etc. Each enrollment can have a number of lessons opened.
6956

7057
```mermaid
7158
erDiagram
@@ -111,3 +98,4 @@ erDiagram
11198
Enrollment }|--o| Course : ""
11299
Enrollment }|--|| Role : ""
113100
```
101+

modules/libs/domain/permissions/index.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
11
export const PermissionKeys = [
2-
// Organizations
3-
'orgs:read',
4-
'orgs:update',
5-
'orgs:delete',
6-
72
// Roles
83
'roles:create',
94
'roles:read',

modules/libs/entities/index.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { Organization } from './organization';
21
import { School } from './school';
32
import { Course, LearningType } from './course';
43
import { Group, GroupStatus } from './group';
@@ -13,7 +12,6 @@ export {
1312
GroupStatus,
1413
LearningType,
1514
Lesson,
16-
Organization,
1715
School,
1816
User,
1917
Role,
@@ -24,7 +22,6 @@ export const Entities = [
2422
Course,
2523
Group,
2624
Lesson,
27-
Organization,
2825
School,
2926
User,
3027
Role,

modules/libs/entities/organization.ts

Lines changed: 0 additions & 14 deletions
This file was deleted.

modules/libs/entities/role.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import * as domain from '@vidya/domain';
22
import { Entity, Column, PrimaryGeneratedColumn, OneToMany, OneToOne } from 'typeorm';
33
import { UserRole } from './userRole';
44
import { School } from './school';
5-
import { Organization } from './organization';
65

76
@Entity({ name: 'roles' })
87
export class Role {
@@ -16,14 +15,8 @@ export class Role {
1615
description: string;
1716

1817
@Column({ nullable: false })
19-
organizationId: string;
20-
21-
@Column({ nullable: true })
2218
schoolId: string;
2319

24-
@OneToOne(() => Organization)
25-
organization: Organization;
26-
2720
@OneToOne(() => School)
2821
school: School;
2922

modules/libs/entities/school.ts

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { Entity, Column, PrimaryGeneratedColumn, ManyToOne, JoinColumn } from 'typeorm';
2-
import { Organization } from './organization';
32

43
@Entity({ name: 'schools' })
54
export class School {
@@ -8,15 +7,4 @@ export class School {
87

98
@Column({ nullable: false })
109
name: string;
11-
12-
@Column({ nullable: false })
13-
organizationId: string;
14-
15-
@ManyToOne(
16-
() => Organization,
17-
org => org.schools,
18-
{ nullable: false }
19-
)
20-
@JoinColumn()
21-
organization: Organization;
2210
}

modules/libs/protocol/auth.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -107,17 +107,12 @@ export interface LogOutResponse {
107107
/* -------------------------------------------------------------------------- */
108108

109109
/**
110-
* Permission object. Contains the organization ID, school ID, and permission.
110+
* Permission object. Contains the school ID and the permissions.
111111
* @remarks Used short names for the properties to reduce the size of a JWT token.
112112
*/
113113
export type UserPermission = {
114-
/**
115-
* Organization ID
116-
*/
117-
oid: string,
118-
119114
/* School ID */
120-
sid?: string,
115+
sid: string,
121116

122117
/* Permissions */
123118
p: domain.PermissionKey[]

modules/libs/protocol/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,3 @@ export * from './otp'
44
export * from './routes'
55
export * from './roles'
66
export * from './userRoles'
7-
export * from './organizations'

modules/libs/protocol/organizations.ts

Lines changed: 0 additions & 40 deletions
This file was deleted.

modules/libs/protocol/roles.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ import * as crud from './crud'
77
export type RoleDetails = {
88
id: string;
99
name: string;
10-
organizationId: string;
11-
schoolId?: string;
10+
schoolId: string;
1211
description: string;
1312
permissions: string[];
1413
}
@@ -27,7 +26,6 @@ export type CreateRoleResponse = crud.CreateItemResponse<RoleDetails['id']>;
2726
/* -------------------------------------------------------------------------- */
2827

2928
export type GetRoleSummariesListQuery = {
30-
organizationId?: string;
3129
schoolId?: string;
3230
}
3331

0 commit comments

Comments
 (0)