Skip to main content

Documentation Index

Fetch the complete documentation index at: https://grantmaster.dev/llms.txt

Use this file to discover all available pages before exploring further.

shared/platform

Extension system runtime services. Handles module installation, activation, health monitoring, policy enforcement, and the platform-wide gamification and dashboard preset systems.

Module Map

FileRole
ExtensionRegistry.tsCompile-time module manifest catalog (ModuleRegistry)
ExtensionInstallationService.tsInstall / uninstall module per org
ExtensionActivationService.tsActivate / deactivate installed modules
ExtensionHealthService.tsPeriodic health checks per installed module
ExtensionMigrationService.tsSchema migration runner on module version upgrades
ExtensionRuntimePolicyService.tsEnforces extensionPolicy quotas at runtime
GamificationService.tsPlatform-wide gamification (points, badges, leaderboards)
PlatformPolicyService.tsPlatform-level policy document management
PolicyService.tsPer-organization policy enforcement
ScheduledReportService.tsScheduled report job management
activityFeedService.tsCross-feature activity feed aggregation
dashboardPresetService.tsDashboard widget preset configurations

ModuleRegistry API

ExtensionRegistry is the compile-time manifest catalog — it does not interact with Firestore.
import { ModuleRegistry } from '@/shared/platform/ExtensionRegistry';

// Initialize once at app startup (loads all manifests)
await ModuleRegistry.init();

// Lookup
const manifest = ModuleRegistry.get('compliance-vault');
const all = ModuleRegistry.getAll();
const grants = ModuleRegistry.getByCategory(ModuleCategory.GRANTS);

// Lazy-load the module's main React component
const Component = await ModuleRegistry.resolveComponent('impact');

Installation API

import { ExtensionInstallationService } from '@/shared/platform/ExtensionInstallationService';

// Install a module
await ExtensionInstallationService.install(moduleId, orgId, installedBy);
// → Checks entitlements → writes moduleInstallations/{moduleId} → emits MODULE_INSTALLED

// Uninstall
await ExtensionInstallationService.uninstall(moduleId, orgId, uninstalledBy);
// → Respects uninstallPolicy per collection → emits MODULE_UNINSTALLED

Health Service

ExtensionHealthService runs periodic checks (heartbeat pings to extension entry points) and writes health status to organizations/{orgId}/moduleInstallations/{moduleId}.healthStatus. Emits MODULE_HEALTH_DEGRADED when a check fails consecutively.

Runtime Policy Enforcement

ExtensionRuntimePolicyService intercepts extension EventBus operations and enforces:
  • maxEventSubscriptions — max active subscriptions per extension
  • maxEventEmitsPerMinute — rate limit on event emission
  • maxAgentToolCallsPerHour — throttles agent tool usage
  • maxAgentCreditsPerHour — caps AI credit consumption

Gamification

GamificationService manages the platform’s points-and-badges system used by features/mission:
  • awardPoints(userId, orgId, action, points) — award points for an action
  • checkBadges(userId, orgId) — evaluate and award any newly unlocked badges
  • getLeaderboard(orgId, limit) — returns ranked user list by points

Dashboard Preset Service

dashboardPresetService.ts manages per-role default widget layouts:
  • getPresetsForRole(orgId, role) — returns ordered widget list for a role
  • savePreset(orgId, role, widgets[]) — saves a custom preset
  • getCuratedOrdering(role) — returns the opinionated default widget order per role

Firestore Collections

CollectionOwnerDescription
organizations/{id}/moduleInstallations/{moduleId}InstallationServicePer-org installation records
platform/modules/definitions/{moduleId}SuperAdmin catalogOverride records for module catalog
gamificationBadgesGamificationServiceBadge definitions
userBadgesGamificationServiceAwarded badges per user
platformPoliciesPlatformPolicyServicePlatform-wide policy documents