Skip to content

A production-ready starter template for building BrainDrive plugins, featuring robust error handling, seamless service integration, React components with error boundaries, TypeScript types, and built-in development/debugging utilities. Designed to help you ship high-quality plugins fast.

License

Notifications You must be signed in to change notification settings

BrainDriveAI/BrainDrive-PluginTemplate

Repository files navigation

BrainDrive Plugin Development Template

This template serves as a starting point for BrainDrive plugin development, providing:

  • Comprehensive error handling patterns and utilities
  • Proper BrainDrive service integration
  • React component architecture with error boundaries
  • TypeScript type definitions and interfaces
  • Development tools and debugging utilities
  • Production-ready code structure and patterns

Use with the Plugin Developer Quickstart Guide to begin developing BrainDrive plugins in 30 minutes or less.

πŸ“Έ Plugin Template Demo

Plugin Template Demo

πŸ“¦ What's Included

Core Components

  1. Main Plugin Component (PluginTemplate.tsx) - Enhanced with comprehensive error handling
  2. Error Boundary (ErrorBoundary.tsx) - React error boundary with recovery mechanisms
  3. Error Display (ErrorDisplay.tsx) - User-friendly error display with actions
  4. Loading Spinner (LoadingSpinner.tsx) - Consistent loading state component
  5. Settings Example (SettingsExample.tsx) - Template for plugin configuration

Error Handling System

  • Custom Error Types - Specific error classes for different scenarios
  • Error Handler Utility - Centralized error management with multiple strategies
  • Service Integration - Error-safe service initialization and usage
  • User Experience - Clear error messages and recovery options

Development Tools

  • TypeScript Definitions - Complete type safety for BrainDrive APIs
  • Utility Functions - Enhanced utilities with error handling
  • Documentation - Comprehensive guides and examples
  • Testing Patterns - Error handling test examples

πŸš€ Getting Started

Prerequisites

  • BrainDrive Platform
  • Node.js 16+ and npm/yarn
  • BrainDrive development environment
  • Basic knowledge of React and TypeScript

Setup

  1. Copy the template to your new plugin directory
  2. Customize the plugin metadata:
    # Update package.json with your plugin details
    # Update lifecycle_manager.py with your plugin information and module definitions
  3. Install dependencies:
    npm install
  4. Build the plugin:
    npm run build

Customization Checklist

  • Update package.json name, description, and version
  • Customize lifecycle_manager.py plugin and module data (see guide)
  • Replace template components with your functionality
  • Update error types and handling for your use cases (see guide)
  • Add your specific service integrations (see examples)
  • Write tests for your plugin functionality

πŸ’‘ Need help? Check our comprehensive documentation or visit community.braindrive.ai

Plugin Structure

src/
β”œβ”€β”€ components/           # React components
β”‚   β”œβ”€β”€ ErrorBoundary.tsx    # Error boundary component
β”‚   β”œβ”€β”€ ErrorDisplay.tsx     # Error display component
β”‚   └── index.ts             # Component exports
β”œβ”€β”€ services/            # Business logic services
β”‚   └── PluginService.ts     # Main service with error handling
β”œβ”€β”€ utils/              # Utility functions
β”‚   β”œβ”€β”€ errorHandling.ts     # Error handling utilities
β”‚   └── utils.ts             # General utilities
β”œβ”€β”€ types.ts            # TypeScript definitions
└── PluginTemplate.tsx  # Main plugin component

πŸŽ“ Learning Resources

Documentation

Lifecycle Manager References

Additional Resources

  • Inline Comments - Extensive code documentation and TODOs

πŸ†˜ Troubleshooting

Common Issues

  • Build errors: Check TypeScript types and imports
  • Service integration: Verify BrainDrive services are available
  • Error handling: Ensure error boundaries are properly configured

Debug Tips

  • Use the enhanced error display for debugging
  • Check browser console for detailed error logs
  • Use the error handler statistics for monitoring
  • Enable development mode for additional debugging info

🀝 Contributing

When contributing to this template:

  1. Maintain backward compatibility
  2. Add comprehensive error handling to new features
  3. Update documentation for any changes
  4. Include tests for new functionality
  5. Follow the established code patterns

Full Project Documentation Index

BrainDrive Documentation Index

Questions?

Post at community.braindrive.ai. We're here to build the future of user-owned AI together.

License

MIT Licensed - BrainDrive is built for your ownership & freedom. Your AI. Your Rules.

About

A production-ready starter template for building BrainDrive plugins, featuring robust error handling, seamless service integration, React components with error boundaries, TypeScript types, and built-in development/debugging utilities. Designed to help you ship high-quality plugins fast.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •