Multi-tenant, cloud-hosted meta-platform where businesses are treated strictly as configuration + data.
- Multi-Tenant Isolation: Organization-level data scoping with Row Level Security (RLS)
- Business Context Switching: Seamless switching between multiple business profiles
- Content Pack Management: Create, edit, and manage content packs with approval workflows
- Approval Workflows: State machine for content pack approval (simple and custom multi-step)
- Budget Enforcement: Monthly caps with real-time tracking and forecasting
- Export System: Multiple export formats with approval gates
- AI-Powered Content Generation: Generate content packs using OpenAI or Anthropic
- Provider Adapters: Pluggable AI provider system with budget tracking
- Automatic Cost Calculation: Real-time token usage and cost tracking
- Content Pack Analytics: Statistics by status, type, approval rates
- Budget Analytics: Current spend, projections, spending trends
- Time-to-Approval Metrics: Track approval efficiency
- Google Docs: Direct export to Google Docs
- PDF: PDF export (placeholder implementation)
- Markdown: Markdown format export
- JSON: Structured data export
-
Database Schema (
supabase/schema.sql)- Multi-tenant isolation with RLS
- Business profiles, content packs, approval workflows
- Budget ledger and transaction tracking
- Custom approval workflow templates
-
Core Business Logic (
lib/core/)- Budget enforcement and tracking
- Approval workflow state machine (simple and custom)
- Content pack orchestration
- AI-powered content generation
- Analytics and forecasting
-
API Routes (
app/api/)- Content packs CRUD and AI generation
- Approval workflow operations (simple and custom)
- Budget checking, management, and forecasting
- Multiple export formats
- Analytics endpoints
-
Dashboard UI (
components/dashboard/)- Business context switching
- Content pack list and filtering
- Content pack review and approval
- AI content generation interface
- Budget management
- Analytics dashboard
-
AI Provider Adapters (
lib/adapters/ai/)- OpenAI adapter with budget tracking
- Anthropic adapter with budget tracking
- Base adapter with approval and budget gates
-
Export Adapters (
lib/exporters/)- Google Docs export
- PDF export
- Markdown export
- JSON export
- Node.js 18+
- Supabase account and project
- (Optional) OpenAI or Anthropic API keys for AI features
- Install dependencies:
npm install- Set up environment variables:
cp .env.example .envEdit .env with your Supabase credentials:
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
# Optional: For AI features
OPENAI_API_KEY=your_openai_api_key
ANTHROPIC_API_KEY=your_anthropic_api_key-
Set up database:
- Run
supabase/schema.sqlin your Supabase SQL editor - Run
supabase/migrations/001_custom_approval_workflows.sqlfor custom workflows - This creates all tables, RLS policies, triggers, and functions
- Run
-
Run development server:
npm run devTo enable AI content generation, configure AI providers in your business profile's config field:
{
"ai_providers": {
"openai": {
"enabled": true,
"apiKey": "your-key",
"model": "gpt-3.5-turbo"
},
"anthropic": {
"enabled": true,
"apiKey": "your-key",
"model": "claude-3-haiku"
}
}
}Create approval workflow templates via the database or API:
INSERT INTO approval_workflow_templates (organization_id, name, steps)
VALUES (
'org-id',
'Two-Step Approval',
'[
{
"stepIndex": 0,
"stepName": "Manager Review",
"approverIds": ["user-id-1"],
"requireAll": false
},
{
"stepIndex": 1,
"stepName": "Director Approval",
"approverIds": ["user-id-2"],
"requireAll": false
}
]'::jsonb
);See docs/architecture.md for detailed system design.
- Multi-Tenant Isolation: Organization-level data scoping with RLS
- Approval Workflows: Simple state machine and custom multi-step workflows
- Budget Enforcement: Monthly caps with real-time tracking and forecasting
- Business Context Switching: Seamless switching between business profiles
- AI Integration: OpenAI and Anthropic adapters with budget tracking
- Export Adapters: Pluggable export system with approval gates
- Analytics: Comprehensive reporting and forecasting
GET /api/content-packs- List content packsPOST /api/content-packs- Create content packPOST /api/content-packs/generate- Generate with AIPATCH /api/content-packs- Update content packDELETE /api/content-packs- Delete content pack
POST /api/approval- Submit/approve/reject (simple workflow)POST /api/approval/workflow- Custom workflow operationsGET /api/approval/workflow- Get workflow step approvals
GET /api/budget- Get budget ledgerPATCH /api/budget- Update monthly capGET /api/budget/forecast- Get budget forecast
POST /api/export- Export content pack (format: google-docs, pdf, markdown, json)
GET /api/analytics- Get business profile analytics
├── app/ # Next.js App Router
│ ├── api/ # API routes
│ ├── auth/ # Authentication pages
│ └── page.tsx # Main dashboard
├── components/ # React components
│ └── dashboard/ # Dashboard components
├── lib/
│ ├── adapters/ # External service adapters
│ │ └── ai/ # AI provider adapters
│ ├── core/ # Core business logic
│ ├── exporters/ # Export adapters
│ └── supabase/ # Supabase clients
├── supabase/
│ ├── schema.sql # Main database schema
│ └── migrations/ # Database migrations
└── docs/ # Documentation
Private - All rights reserved