Skip to content

Global Context

System that manages shared configuration and state — the "command center" that coordinates all of schepta.

Provider

Provider Pattern centralizes configurations that all components need to share:

🔧 What It Does:

ConfigurationScopeBenefitExample
Component RegistryGlobalStandardized componentsMUI as default
Middleware StackGlobalConsistent behaviorUniform validation
Context ProvidersGlobalShared stateUser, permissions, locale

📊 Configuration Hierarchy:

Provider Hierarchy:

text
scheptaProvider (App Level)
    ├── Global Component Registry
    ├── Global Middleware  
    └── Context Providers
        └── FormFactory/MenuFactory (Local)
            ├── Local Component Overrides
            └── Local Middleware Overrides

Quick Example:

jsx
<scheptaProvider
  components={{ InputText: MUITextField, Button: MUIButton }}
  middleware={{ withValidation, withAnalytics }}
>
  <App />
</scheptaProvider>

💡 Result: Configure once → Available throughout the application.

🚀 Provider Types

Each provider manages a specific aspect of the system:

🎨 scheptaProvider - Master Provider:

ConfigurationPurposeDefaultOverride Level
componentsGlobal component registryBuilt-in componentsLocal factory props
middlewareGlobal middleware stackBasic middlewareLocal factory props
debugDebug panel configurationAuto (dev mode)Environment variables

🎛️ Component Registry Provider:

Registration TypeScopePriorityUse Case
Default RegistrySystem-wideLowestBuilt-in components
Global RegistryApplication-wideMediumConsistent UI library
Local RegistryFactory-specificHighestComponent overrides
Dynamic RegistryRuntimeVariableA/B testing, themes

🔧 Middleware Provider:

Middleware TypeScopeExecutionPurpose
Core MiddlewareSystemAlways executedEssential functionality
Global MiddlewareApplicationConfigurableConsistent behavior
Local MiddlewareFactoryOverride/extendSpecific functionality
Conditional MiddlewareContext-basedConditionalRole/tenant specific

⚙️ Provider Architecture

How the provider system works:

📋 Provider Initialization:

PhaseProcessResultDependencies
1. Provider SetupInitialize provider contextContext availableNone
2. Registry RegistrationRegister global componentsGlobal registry populatedComponent definitions
3. Middleware RegistrationRegister global middlewareMiddleware stack readyMiddleware functions
4. Context PropagationPropagate to child componentsProviders activeReact/Vue context

🎯 Context Propagation:

React Context Usage:

typescript
// Provider contexts
const scheptaContext = createContext<scheptaConfig>();
const ComponentRegistryContext = createContext<ComponentRegistry>();
const MiddlewareContext = createContext<MiddlewareStack>();

// Hook access
const useschepta = () => useContext(scheptaContext);
const useComponentRegistry = () => useContext(ComponentRegistryContext);
const useMiddleware = () => useContext(MiddlewareContext);

Configuration Inheritance:

typescript
const mergedConfig = {
  // Default configuration
  ...defaultscheptaConfig,
  
  // Provider configuration  
  ...providerConfig,
  
  // Runtime overrides
  ...runtimeConfig
};

📊 Configuration Patterns

Common provider configuration patterns:

🎯 Application-Level Patterns:

PatternUse CaseConfigurationBenefits
Component LibraryDesign systemConsistent componentsDevelopment speed
Micro-frontendsDistributed appScoped configurationsTeam independence

🔧 Component Library Integration:

Material-UI Integration:

typescript
<scheptaProvider
  components={{
    InputText: MuiTextField,
    Button: MuiButton,
    Select: MuiSelect,
    Checkbox: MuiCheckbox
  }}
>
  <App />
</scheptaProvider>

Ant Design Integration:

typescript
<scheptaProvider
  components={{
    InputText: AntInput,
    Button: AntButton,
    Select: AntSelect,
    Checkbox: AntCheckbox
  }}
>
  <App />
</scheptaProvider>

🎨 Multi-Tenant Configuration:

Tenant-Specific Providers:

typescript
const TenantProvider = ({ tenant, children }) => {
  const tenantConfig = getTenantConfig(tenant);
  
  return (
    <scheptaProvider
      components={tenantConfig.components}
      middleware={tenantConfig.middleware}
    >
      {children}
    </scheptaProvider>
  );
};

Provider Pattern manages configuration for all other concepts: