Skip to content

zierocode/FormDee

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

35 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

FormDee v1.3.0

πŸš€ Production-Ready Dynamic Form Builder with AI & Google Sheets

A comprehensive form building platform with AI-powered generation, Google Sheets integration, Supabase backend, file uploads to Cloudflare R2, and enterprise-grade testing infrastructure.

Version TypeScript Tests Coverage License

πŸŽ‰ New in v1.3.0

  • πŸ€– 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

✨ Core Features

Form Builder

  • 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

Backend & Storage

  • 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

Authentication & Security

  • 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

Testing & Quality

  • 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

πŸ—οΈ Architecture

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

πŸš€ Quick Start

Prerequisites

  • 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)

Installation

# 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 dev

Environment Variables

Create 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/callback

πŸ“Š Database Schema

Forms Table

CREATE 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()
);

Responses Table

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)
);

Settings Table

CREATE TABLE settings (
  id INTEGER PRIMARY KEY DEFAULT 1,
  api_key TEXT,
  ai_model VARCHAR(50),
  google_credentials JSONB,
  updatedAt TIMESTAMP DEFAULT NOW()
);

πŸ§ͺ Testing

Run Tests

# 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

Test Coverage Areas

  • βœ… 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

🚒 Deployment

Docker Deployment

# 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

Vercel Deployment

# Deploy to Vercel
npm run deploy:vercel

Manual Deployment

# Build for production
npm run build:production

# Start production server
npm start

πŸ“š API Documentation

Authentication

All admin endpoints require either:

  • Cookie-based authentication (via /api/auth/login)
  • API key header: x-admin-key: your-api-key

Core Endpoints

Forms Management

  • GET /api/forms - List all forms or get specific form
  • POST /api/forms - Create or update form
  • DELETE /api/forms - Delete form

Form Submission

  • POST /api/submit - Submit form data
  • POST /api/submit/supabase - Submit with Supabase integration

AI Generation

  • POST /api/ai/generate - Generate form from prompt
    • Supports GPT-4o, GPT-5-mini, GPT-5-nano models
    • Intelligent error handling for token exhaustion

Google Integration

  • GET /api/auth/google - Initiate OAuth flow
  • GET /api/auth/google/callback - OAuth callback
  • POST /api/forms/validate-google-sheet - Validate sheet URL
  • POST /api/forms/export-responses - Export to Google Sheets

File Upload

  • POST /api/upload - Upload files to Cloudflare R2

πŸ” Security Features

  • 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

🀝 Contributing

Please see CONTRIBUTING.md for development guidelines.

πŸ“„ License

MIT License - see LICENSE file for details.

πŸ™ Acknowledgments


FormDee v1.3.0 - Built with ❀️ for developers who need powerful, reliable form solutions.

About

Dynamic Form Builder

Resources

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors