Administration, Security & Operations

2. Organization Admin and Multi-Tenancy

SamvraCore is a multi-tenant ERP, and the administration layer is where tenancy is governed. Organisations are managed through OrganizationsListPage and OrganizationDetailPage, each organisation carrying a slug (a URL-friendly identifier) and organisation-wide settings such as logo, currency and name.

The central guarantee of the platform is multi-tenant data isolation. Every entity carries an organization_id, and PostgreSQL Row-Level Security enforces separation at the database layer. The current tenant is set per transaction: the application sets app.current_tenant through DB.WithTenantTransaction(), so queries only ever see the rows belonging to the active organisation.

User management lives alongside this. The UsersPage handles inviting members, pending invitations, resending invitations, and invitation and magic-link expiration. Roles are managed on RolesPage, which distinguishes immutable system roles from custom roles built by selecting permissions.

Role-Based Access Control

RBAC is implemented in pkg/middleware/rbac.go. It uses a 5-minute permission cache and matches permissions with wildcard resource:action patterns. Authentication issues JWT access and refresh tokens from pkg/jwt/. Users have profile information and a profile photo (JPG, GIF or PNG up to 2 MB), and account recovery is supported through Security Questions and a password-reset flow. Together, organization_id plus Row-Level Security plus RBAC form layered protection: tenancy isolates data, roles constrain actions.