Skip to content

Services Layer

Location: services/*

Purpose:

  • Provide domain-oriented, tenant-aware access to data and business logic
  • Abstract Prisma/Supabase and encapsulate validation/transactions

Key entrypoints:

  • services/index.ts exports:
    • Base classes: BaseService<ModelName>, TenantBaseService<ModelName> (model name from Prisma.ModelName; entity/where/create/update types from Prisma TypeMap)
    • Global services: RootCompaniesService, RootUsersService, BrandService, PromotionsService, RootSettingsService, StripeAccountService, WidgetService, SystemService, SourceService, MessageStatusService, SignatureRequestService, SiteService, SynchronizationsService, BlacklistedService, BillableEventService, StripeServiceGlobal, etc.
    • Tenant services: TenantService, VehicleService, OrderService, ClientService, SettingsService, ExtraServiceService, VehiclePurchaseService, VehicleBalanceService, OfficeService, PartnerService, OrderAvailabilityService, ChangeOrderStatusService, ProblemService, SeasonTariffMatrixService, InsuranceService, VehicleRemindersService, VehicleReminderHistoriesService, UsersService, StripeService, CalculationService, SearchService, SignatureRequestsService, InvoiceService, InvoiceSerieService, PaymentMethodService, LogService, WebhookService, PaymentService, UserTenantsService, UserFeedbackService.
  • Factory: createTenantServices(tenantId, role, supabase, decodedToken)

Data access:

  • Uses Prisma client from services/db.ts
  • In Postgres mode, Supabase client and decoded JWT passed for RLS-secure operations

Usage:

  • Resolvers receive context.services and call methods to perform operations

Notes:

  • Unit tests under _tests_ and services/*.test.ts