KaroKar operates as a B2B2C mobility marketplace where Vendor organizations supply vehicles, Corporate organizations book and assign them to employees, and the KaroKar Platform organization governs the entire ecosystem. Rather than maintaining separate tables for each participant type, the platform consolidates all of them into a single unified Organization model — enabling consistent onboarding, authorization, and reporting across every tenant, while keeping the door open for future participant types such as Fleet Operators, Insurance Partners, and Government Agencies.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/Codefied-CodePix/Karokar-backend/llms.txt
Use this file to discover all available pages before exploring further.
The Unified Organization Model
Every tenant in KaroKar is anOrganization record. The OrganizationType enum determines what capabilities that organization holds within the platform.
Organization entity itself is intentionally lean. Business-domain-specific metadata is stored in the flexible metadata: Record<string, unknown> JSONB column so that the schema does not need to change as the platform grows.
The
parentOrganizationId field is present but nullable in Phase 01. It is reserved for future enterprise hierarchy support — for example, grouping ABC Logistics, ABC Transport, and ABC Holdings under a single ABC Group parent organization without requiring any schema changes.User Membership Model
Users do not hold roles globally — they earn them through organization memberships. TheOrganizationMember entity is the join between a user account, an organization, and the role that governs what that user may do inside that organization.
MemberStatus enum governs the lifecycle state of a membership record independently of the organization’s own status:
ABC Rentals and a Corporate Admin in XYZ Holdings at the same time.
Phase 01 Roles
PLATFORM_ADMIN
Belongs to the KaroKar Platform organization. Approves onboarding, reviews verifications, and manages global compliance.
VENDOR_ADMIN
Belongs to a Vendor organization. Manages the vehicle fleet, reviews and approves booking requests from Corporate organizations.
CORPORATE_ADMIN
Belongs to a Corporate organization. Creates bookings, manages employee memberships, and assigns vehicles to staff.
EMPLOYEE
Belongs to a Corporate organization. Views their own assignments, accepts or rejects trips, and reads booking details relevant to them.
Data Ownership Rules
Every domain entity carries anorganizationId (or equivalent ownership column) so that tenant boundaries are enforced at the data level, not just in application code.
| Domain Entity | Ownership Column | Belongs To |
|---|---|---|
Vehicle | organizationId | Vendor organization |
Booking | corporateOrganizationId + vendorOrganizationId | Corporate (requester) + Vendor (fulfiller) |
Assignment | corporateOrganizationId | Corporate organization |
Verification | organizationId | The organization being verified |
Tenant Isolation Strategy
Phase 01 uses logical tenant isolation: all organizations share the same application process, database, and infrastructure. Isolation is enforced exclusively throughorganizationId filtering on every query. No row escapes its tenant boundary without an explicit cross-tenant query, and those are only permitted within tightly controlled service methods.
OrganizationContextInterceptor extracts the active organizationId from the authenticated JWT payload and attaches it to the request object, making it available to all downstream guards, services, and repositories within a single request lifecycle.
Why Not Separate Vendor and Corporate Tables?
The alternative of maintaining distinctVendor and Corporate tables was considered and rejected. Separate tables would duplicate onboarding flows, permission models, and reporting pipelines for every new participant type. The unified Organization model means that adding an INSURANCE_PARTNER type in a future phase is a single enum addition — no schema migrations, no new repositories, no new onboarding controllers.