This is a starter template for building AI agents using Mastra and CopilotKit. It provides a modern Next.js application with integrated AI capabilities, multi-tenant organization management, and a themeable UI.
- Node.js 18+
- Any of the following package managers:
- pnpm
Note: This repository ignores lock files (package-lock.json, yarn.lock, pnpm-lock.yaml, bun.lockb) to avoid conflicts between different package managers. Each developer should generate their own lock file using their preferred package manager. After that, make sure to delete it from the .gitignore.
- Multi-tenant Architecture: Support for multiple organizations per user
- Role-Based Access Control: Admin and user roles with granular permissions
- Email Invitations: Invite users via email with configurable expiration
- Member Management: Add, update, and remove organization members
- Invitation Tracking: Monitor pending, accepted, and expired invitations
- Three Built-in Themes:
- Terminal: Dark theme with green accents (default)
- Glass: Modern glassmorphism with purple/blue accents
- Material: Clean Material Design light theme
- Easy Theme Switching: Simple CSS import to change themes
- Tailwind Integration: Theme colors available as utility classes
- Fully Customizable: Create your own themes with CSS variables
- Mastra Agent Integration: Build and deploy AI agents
- CopilotKit UI: Beautiful conversational interfaces
- Cloudflare D1 Storage: Persistent agent memory and data
- Install dependencies using your preferred package manager:
pnpm install- Set up environment variables:
cp .env.example .envEdit .env and add your API keys:
# Required: OpenAI or OpenRouter API key for AI agents
OPENAI_API_KEY=your-key-here
# Required: Resend API key for email invitations
RESEND_API_KEY=re_xxxxx
EMAIL_FROM=noreply@yourdomain.com
# Optional: Customize invitation expiration
INVITE_EXPIRATION_DAYS=7
APP_URL=http://localhost:3000- Set up the database:
# Create D1 database
pnpm wrangler d1 create mastra-db
# Update wrangler.jsonc with the database ID from output
# Run migrations
pnpm wrangler d1 migrations apply mastra-db --local- Start the development server:
pnpm devThis will start the Next.js dev server with hot reload and full D1 access at http://localhost:3000.
The following scripts can be run using your preferred package manager:
dev- Fast development with full D1 access (recommended)dev:debug- Development mode with debug logging enableddev:cf- Production-like testing with Cloudflare Workersmastra:dev- Start Mastra CLI playground for agent testingbuild- Builds the application for productionpreview- Preview production build locallydeploy- Deploy to Cloudflarelint- Runs ESLint for code linting
See CLAUDE.md for detailed development workflow guidance.
- CLAUDE.md - Complete project overview and development guide
- Organization Management - Multi-tenant system guide
- Theming Guide - Theme customization and switching
- Mastra Documentation - Learn more about Mastra and its features
- CopilotKit Documentation - Explore CopilotKit's capabilities
- Next.js Documentation - Learn about Next.js features and API
Feel free to submit issues and enhancement requests!
This project is licensed under the MIT License - see the LICENSE file for details.