Skip to main content
This guide provides an overview of the various ways to extend SnackBase functionality beyond the core features.

Overview

SnackBase is designed to be extensible at multiple levels, allowing you to add custom functionality without modifying core code.

Extension Philosophy

What Can Be Extended?

Extension Methods

Best for: Business logic, event-driven automation, integrations
Pros:
  • Stable API (v1.0 contract)
  • Automatic event triggering
  • Account isolation built-in
  • No core modifications
Cons:
  • Limited to defined events
  • Can’t add new API endpoints

2. Custom API Endpoints

Best for: New features, external integrations, custom operations
Pros:
  • Full control over endpoint
  • Can access all SnackBase services
  • Leverage existing authentication
Cons:
  • Must manually handle permissions
  • Requires more code

3. Custom Database Tables

Best for: Domain-specific data, complex relationships
Pros:
  • Full SQL control
  • Complex relationships
  • Migrations versioned
Cons:
  • Requires manual migrations
  • Not auto-integrated with collections

4. Middleware

Best for: Request/response processing, logging, custom auth
Pros:
  • Runs on every request
  • Can modify requests/responses
  • Good for cross-cutting concerns
Cons:
  • Adds latency to all requests
  • Must be carefully designed

5. Custom Services

Best for: Reusable business logic, external integrations
Pros:
  • Encapsulates logic
  • Reusable across endpoints
  • Testable in isolation
Cons:
  • More initial code

Choosing the Right Approach

Decision Tree

Comparison Matrix

Modifying core files will cause conflicts when updating SnackBase. Always use extension methods instead.

Extension Points

1. Database Layer

Extend the data layer:

2. Service Layer

Add business logic services:

3. API Layer

Extend the API:

4. Authentication Layer

Extend authentication:

Architecture Considerations

Clean Architecture Principles

When extending SnackBase, follow Clean Architecture:

Dependency Direction

Separation of Concerns

Keep extensions organized:

Deployment Considerations

Surviving Updates

Extension Isolation

Keep extensions isolated to avoid conflicts:

Configuration

Use configuration for extension behavior:

Examples

Example 1: Analytics Dashboard

Add custom analytics:

Example 2: Slack Integration

Add Slack notifications:

Example 3: Custom Validation

Add field validation:

Example 4: Custom Endpoint with Permissions

Add protected endpoint:

Summary