A comprehensive form building platform with AI-powered generation, Google Sheets integration, Supabase backend, file uploads to Cloudflare R2, and enterprise-grade testing infrastructure.
- π€ Enhanced GPT-5 Model Support: Intelligent handling of reasoning token exhaustion with helpful error messages
- π Google Sheets Integration: Full OAuth flow, validation, and export functionality
- π§ͺ Comprehensive Test Coverage: 70+ API tests including AI and Google Sheets integration
- π Google OAuth Authentication: Secure authentication flow for Google services
- π Improved Error Messages: Clear, actionable error messages for better debugging
- β‘ Performance Optimizations: Enhanced caching and request handling
- AI-Powered Generation - Natural language to form conversion using OpenAI GPT models
- Drag & Drop Builder - Intuitive visual form construction with real-time preview
- Field Types - Text, email, number, date, textarea, select, radio, checkbox, file upload
- Advanced Validation - Pattern matching, min/max values, required fields, custom rules
- Conditional Logic - Show/hide fields based on user input
- Supabase Integration - PostgreSQL database for forms and responses
- Cloudflare R2 - Secure file storage with public URL generation
- Google Sheets Export - Export form responses directly to Google Sheets
- Slack Notifications - Real-time notifications for form submissions
- Cookie-Based Auth - Secure session management for admin access
- Google OAuth 2.0 - Secure authentication for Google services
- API Key Protection - Multiple layers of API security
- Input Sanitization - XSS and SQL injection protection
- Comprehensive Testing - 70+ API tests, 25+ E2E tests
- Smart Test Runner - Intelligent test environment detection
- Automatic Cleanup - Test data cleanup with production safeguards
- Performance Metrics - Request timing and optimization tracking
formdee/
βββ app/ # Next.js 14 App Router
β βββ api/ # API Routes
β β βββ ai/generate/ # AI form generation
β β βββ auth/ # Authentication endpoints
β β β βββ google/ # Google OAuth flow
β β β βββ login/ # Admin login
β β β βββ logout/ # Session management
β β βββ forms/ # Form CRUD operations
β β β βββ export-responses/ # Google Sheets export
β β β βββ test-google-sheet/ # Sheet validation
β β β βββ test-slack/ # Slack webhook testing
β β βββ submit/ # Form submission handlers
β β β βββ supabase/ # Database submission
β β βββ responses/ # Response data retrieval
β β βββ settings/ # Configuration management
β β βββ upload/ # File upload to R2
β βββ builder/ # Form builder interface
β β βββ [refKey]/ # Edit existing forms
β βββ f/[refKey]/ # Public form display
β βββ login/ # Admin authentication
βββ components/ # React Components
β βββ BuilderForm.tsx # Main form builder
β βββ FormRenderer.tsx # Public form display
β βββ FieldEditor.tsx # Field configuration
β βββ FieldList.tsx # Draggable field list
β βββ ui/ # Reusable UI components
βββ lib/ # Core Libraries
β βββ supabase.ts # Database client
β βββ google-auth.ts # Google OAuth handler
β βββ google-sheets.ts # Sheets API integration
β βββ auth-server.ts # Server auth utilities
β βββ types.ts # TypeScript definitions
βββ hooks/ # Custom React Hooks
β βββ use-forms.ts # Form data management
β βββ use-settings.ts # Settings management
β βββ use-auth.ts # Authentication state
βββ tests/ # Test Suites
β βββ api/ # API tests
β βββ e2e/ # End-to-end tests
β βββ utils/ # Test utilities
βββ docs/ # Documentation
- Node.js 18+ and npm
- Supabase account and project
- OpenAI API key (for AI features)
- Cloudflare R2 bucket (for file uploads)
- Google Cloud Console project (for Google Sheets integration)
# Clone the repository
git clone https://github.com/yourusername/formdee.git
cd formdee
# Install dependencies
npm install
# Set up environment variables
cp .env.example .env
# Edit .env with your credentials
# Run database migrations
npm run setup:supabase
# Start development server
npm run devCreate a .env file with the following:
# Admin Authentication
ADMIN_API_KEY=your-secure-api-key-32-chars
ADMIN_UI_KEY=your-secure-ui-key-32-chars
# Base URL
NEXT_PUBLIC_BASE_URL=http://localhost:3000
# Supabase Configuration
SUPABASE_URL=https://your-project.supabase.co
SUPABASE_ANON_KEY=your-anon-key
SUPABASE_SERVICE_ROLE_KEY=your-service-role-key
# Cloudflare R2 Configuration
R2_ACCOUNT_ID=your-account-id
R2_ACCESS_KEY_ID=your-access-key-id
R2_SECRET_ACCESS_KEY=your-secret-access-key
R2_BUCKET_NAME=your-bucket-name
R2_PUBLIC_URL=https://your-r2-public-url.com
NEXT_PUBLIC_R2_PUBLIC_URL=https://your-r2-public-url.com
# Google OAuth (Optional)
GOOGLE_CLIENT_ID=your-google-client-id
GOOGLE_CLIENT_SECRET=your-google-client-secret
GOOGLE_REDIRECT_URI=http://localhost:3000/api/auth/google/callbackCREATE TABLE forms (
id UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
refKey VARCHAR(255) UNIQUE NOT NULL,
title VARCHAR(255) NOT NULL,
description TEXT,
fields JSONB NOT NULL,
slackWebhookUrl TEXT,
googleSheetUrl TEXT,
createdAt TIMESTAMP DEFAULT NOW(),
updatedAt TIMESTAMP DEFAULT NOW()
);CREATE TABLE responses (
id UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
refKey VARCHAR(255) NOT NULL,
formData JSONB NOT NULL,
files JSONB,
ip VARCHAR(45),
userAgent TEXT,
submittedAt TIMESTAMP DEFAULT NOW(),
metadata JSONB,
FOREIGN KEY (refKey) REFERENCES forms(refKey)
);CREATE TABLE settings (
id INTEGER PRIMARY KEY DEFAULT 1,
api_key TEXT,
ai_model VARCHAR(50),
google_credentials JSONB,
updatedAt TIMESTAMP DEFAULT NOW()
);# Run all tests
npm run test:all
# API Tests
npm run test:api:standard # Core API tests (21 tests)
npm run test:api:full # Comprehensive tests (70+ tests)
# E2E Tests
npm run test:e2e:standard # Essential workflows (8 tests)
npm run test:e2e:full # Complete scenarios (25+ tests)
# Quick smoke test
npm run test:quick
# Cleanup test data
npm run test:cleanup- β All API endpoints (100% coverage)
- β Authentication flows
- β Form CRUD operations
- β File upload handling
- β Google Sheets integration
- β AI form generation with GPT-5 handling
- β Error scenarios and edge cases
- β Performance and load testing
# Build and run with Docker
npm run deploy:docker:auto
# Or use Docker Compose
docker-compose up -d
# Check status
npm run docker:status
# View logs
npm run docker:logs# Deploy to Vercel
npm run deploy:vercel# Build for production
npm run build:production
# Start production server
npm startAll admin endpoints require either:
- Cookie-based authentication (via
/api/auth/login) - API key header:
x-admin-key: your-api-key
GET /api/forms- List all forms or get specific formPOST /api/forms- Create or update formDELETE /api/forms- Delete form
POST /api/submit- Submit form dataPOST /api/submit/supabase- Submit with Supabase integration
POST /api/ai/generate- Generate form from prompt- Supports GPT-4o, GPT-5-mini, GPT-5-nano models
- Intelligent error handling for token exhaustion
GET /api/auth/google- Initiate OAuth flowGET /api/auth/google/callback- OAuth callbackPOST /api/forms/validate-google-sheet- Validate sheet URLPOST /api/forms/export-responses- Export to Google Sheets
POST /api/upload- Upload files to Cloudflare R2
- Authentication: Secure cookie-based sessions with HTTP-only cookies
- Authorization: Multi-layer API protection
- Input Validation: Zod schemas for all inputs
- SQL Injection Protection: Parameterized queries via Supabase
- XSS Protection: Input sanitization and CSP headers
- File Upload Security: Type validation, size limits, virus scanning
- Rate Limiting: Request throttling for API endpoints
- CORS Configuration: Strict origin validation
Please see CONTRIBUTING.md for development guidelines.
MIT License - see LICENSE file for details.
- Built with Next.js and TypeScript
- Database by Supabase
- File storage by Cloudflare R2
- AI powered by OpenAI
- UI components from Ant Design
FormDee v1.3.0 - Built with β€οΈ for developers who need powerful, reliable form solutions.