xFunnel is a modern web application that integrates Claude AI for intelligent article editing and n8n for workflow automation. Built with Next.js, TypeScript, and Supabase, it provides a seamless editing experience with real-time collaboration features.

- AI-Powered Editing: Integrated Claude AI for intelligent content suggestions and editing
- Real-time Collaboration: Multiple users can view and edit articles with last-editor tracking
- Workflow Automation: n8n webhook integration for automated article processing
- Modern UI: Clean, responsive interface with dark mode support
- Activity Tracking: Monitor user activity and article editing patterns
- Worker Management: Track and manage background workers with real-time statistics
Before you begin, ensure you have the following installed:
- Node.js 18.x or higher
- npm or yarn package manager
- PostgreSQL database (via Supabase)
- Git
You'll also need accounts for:
- Supabase - For database and authentication
- Anthropic - For Claude AI API access
- n8n (optional) - For workflow automation
- Clone the repository:
git clone https://github.com/yourusername/xfunnel.git
cd xfunnel- Install dependencies:
npm install- Create a
.env.localfile in the root directory with the following variables:
# Supabase Configuration (Required)
NEXT_PUBLIC_SUPABASE_URL=your-supabase-project-url
NEXT_PUBLIC_SUPABASE_ANON_KEY=your-supabase-anon-key
SUPABASE_SERVICE_ROLE_KEY=your-supabase-service-role-key
# Claude AI Configuration (Required)
ANTHROPIC_API_KEY=your-anthropic-api-key
# Webhook Configuration (Optional - for n8n integration)
N8N_WEBHOOK_URL=https://your-n8n-instance.com/webhook/article-done
N8N_WEBHOOK_AUTH_HEADER=optional-auth-header
# IMPORTANT: Admin Registration Security (Required)
# Set this to a secure password to prevent unauthorized registrations
# Users will need to provide this password when creating new accounts
API_KEY_SECRET=change-this-to-a-secure-password
# Optional: Production URL (for CORS)
NEXT_PUBLIC_APP_URL=http://localhost:3000
# Optional: MCP Configuration (for local development)
MCP_CONTEXT7_ENABLED=false
MCP_TASKMASTER_ENABLED=false
# Optional: Rate Limiting (if using Upstash Redis)
UPSTASH_REDIS_REST_URL=your-upstash-redis-url
UPSTASH_REDIS_REST_TOKEN=your-upstash-redis-token- Create a new project at app.supabase.com
- Go to Settings > API
- Copy:
Project URL→NEXT_PUBLIC_SUPABASE_URLanon publickey →NEXT_PUBLIC_SUPABASE_ANON_KEYservice_rolekey →SUPABASE_SERVICE_ROLE_KEY
- Sign up at console.anthropic.com
- Create a new API key
- Copy it to
ANTHROPIC_API_KEY
The application uses Supabase (PostgreSQL) for data storage. Run the database setup script:
npm run setup:dbThis will create the following tables:
users- User authentication and profilesarticles- Article content and metadataworkers- Background worker trackingactivity_log- User activity tracking
If the automatic setup fails, you can manually run the migrations:
- Go to your Supabase dashboard
- Navigate to SQL Editor
- Run each file in
supabase/migrations/in order:000_create_articles_table.sql001_create_users_table.sql002_update_articles_table.sql003_create_workers_table.sql004_update_workers_table_activity_tracking.sql005_update_articles_shared_access.sql
- Start the development server:
npm run dev-
Open http://localhost:3000 in your browser
-
Register a new account using the admin password set in
API_KEY_SECRET
npm run dev- Start development servernpm run build- Build for productionnpm run start- Start production servernpm run lint- Run ESLintnpm run setup:db- Setup database tablesnpm run setup:db:node- Alternative database setup using Node.js
- Build the application:
npm run build- Test the production build locally:
npm run start- Install Vercel CLI:
npm i -g vercel- Deploy to Vercel:
vercel-
Configure environment variables in Vercel dashboard:
- Go to your project settings
- Navigate to Environment Variables
- Add all variables from
.env.local
-
Configure database access:
- Ensure your Supabase project allows connections from Vercel IPs
- Update CORS settings if needed
- Set
NODE_ENV=production - Use strong passwords for
API_KEY_SECRET - Enable rate limiting with Upstash Redis
- Configure proper CORS headers
- Set up monitoring and error tracking
- Rich text editing with Claude AI assistance
- Auto-save functionality
- Version history tracking
- Collaborative editing with conflict resolution
- Secure authentication via Supabase Auth
- Role-based access control
- Activity tracking and analytics
- Background task processing
- Real-time status updates
- Performance monitoring
- Webhook endpoints for workflow triggers
- Article status updates
- Automated content processing
-
Database Connection Errors
- Verify Supabase credentials in
.env.local - Check if tables are created properly
- Ensure RLS policies are configured
- Verify Supabase credentials in
-
Authentication Issues
- Confirm
API_KEY_SECRETis set correctly - Check Supabase Auth settings
- Verify JWT secret configuration
- Confirm
-
Claude AI Not Working
- Validate
ANTHROPIC_API_KEY - Check API rate limits
- Monitor error logs for specific issues
- Validate
-
Build Failures
- Clear
.nextfolder and rebuild - Check for TypeScript errors
- Verify all dependencies are installed
- Clear
-
"ai_requests_count column not found" Error
- Run the migration to add missing columns:
-- In Supabase SQL Editor, run: ALTER TABLE workers ADD COLUMN IF NOT EXISTS ai_requests_count INTEGER DEFAULT 0; ALTER TABLE workers ADD COLUMN IF NOT EXISTS manual_edits_count INTEGER DEFAULT 0; ALTER TABLE workers ADD COLUMN IF NOT EXISTS focus_count INTEGER DEFAULT 0; ALTER TABLE workers ADD COLUMN IF NOT EXISTS blur_count INTEGER DEFAULT 0; ALTER TABLE workers ADD COLUMN IF NOT EXISTS read_percentage INTEGER DEFAULT 0; ALTER TABLE workers ADD COLUMN IF NOT EXISTS is_active BOOLEAN DEFAULT true; ALTER TABLE workers ADD COLUMN IF NOT EXISTS last_active TIMESTAMP WITH TIME ZONE DEFAULT TIMEZONE('utc', NOW());
- Or run the migration file:
supabase/migrations/006_fix_workers_columns.sql - Restart your Next.js server after fixing
-
N8N Webhook Not Working
- Ensure
N8N_WEBHOOK_URLis set in.env.local(not.env.example) - Use your actual n8n webhook URL, not the placeholder
- Format:
N8N_WEBHOOK_URL=https://your-n8n.com/webhook/your-webhook-id - Restart Next.js server after changing environment variables
- Ensure
Enable debug logging by setting:
DEBUG=trueCheck browser console and server logs for detailed information.
- Check existing issues on GitHub
- Review error logs in Supabase dashboard
- Monitor Next.js server logs
- Use browser DevTools for client-side debugging
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Built with Next.js
- Database by Supabase
- AI powered by Claude (Anthropic)
- UI components from Radix UI
- Styling with Tailwind CSS