Repository navigation
User Management System
PersonalLearningPro’s user management system has evolved from a simple role-based model to a robust, multi-tenant workspace architecture. This system governs identity, tenancy, and access control across the entire platform.
The platform is structured around "Workspaces". A workspace is a logical container for students, teachers, content, and collaboration.
-
Isolation: Data is scoped to a specific
workspace_id. - Ownership: Every workspace has a single "Owner" who has full billing and management rights.
- Membership: Users can be members of multiple workspaces, each with a different role.
Users sign up by creating their first workspace. This process simultaneously creates:
- A global
Useraccount. - A new
Workspaceentry. - A
WorkspaceMembershiplinking the two with theownerrole.
New members are brought into workspaces via a secure invitation system:
- Admins send an invite to an email address.
- A tokenized link is generated and sent via email.
- Upon clicking, the user joins the workspace and completes their profile.
Sessions are tracked in the sessions table in PostgreSQL, allowing for remote logout and session revocation.
Roles are enforced at two levels:
-
System Level:
admin,teacher,student,parent. -
Workspace Level:
owner,admin,member.
This dual-layer approach allows for flexible institutional structures (e.g., a "Teacher" who is a "Workspace Admin").
The system uses a unified PostgreSQL database for all identity and tenancy data, ensuring transactional consistency.
graph TD
Client["Frontend App"] --> AuthCtx["AuthProvider"]
AuthCtx --> API["Auth API<br/>(/api/auth/*)"]
API --> PG["PostgreSQL<br/>(Users, Workspaces)"]
API --> Mailer["Nodemailer<br/>(Invites, Verification)"]
By centralizing user management in a relational PostgreSQL schema, PersonalLearningPro provides a secure and scalable foundation for multi-tenant educational environments. The system balances global identity with granular, workspace-scoped access control.