Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

1 Commit
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Form Builder SaaS

A modern, full-featured form builder application built with TanStack Start, React, and Appwrite. Create, share, and manage dynamic forms with an intuitive drag-and-drop interface.

πŸš€ Features

Authentication & Security

  • βœ… Email/password authentication
  • βœ… Protected admin routes
  • βœ… Optional form authentication for participants
  • βœ… Session management with secure cookies

Admin Dashboard

  • βœ… Create, edit, duplicate, and delete forms
  • βœ… Search forms by title
  • βœ… Form list with creation dates and metadata
  • βœ… Share form links with one click

Drag-and-Drop Form Builder

  • βœ… 11 field types:
    • Short Text (single-line input)
    • Long Text (multi-line textarea)
    • Checkbox (multiple choice)
    • Dropdown/Select
    • Radio buttons
    • Date picker
    • Number input
    • File upload
    • Rating (1-5 stars)
    • Email input
    • Section divider
  • βœ… Drag-and-drop reordering with visual feedback
  • βœ… Field customization (label, placeholder, required, options)
  • βœ… Auto-save (500ms debounce)
  • βœ… Real-time preview

Form Sharing & Submissions

  • βœ… Unique form URLs (e.g., /form/{formId})
  • βœ… Public form access with optional authentication
  • βœ… Client-side and server-side validation
  • βœ… Success confirmation page
  • βœ… Responsive mobile-friendly forms

Submission Management

  • βœ… View all submissions in table format
  • βœ… Detailed submission view
  • βœ… Export to CSV
  • βœ… Export to JSON
  • βœ… Delete submissions with confirmation
  • βœ… Submission metadata (timestamp, participant email)

πŸ› οΈ Tech Stack

πŸ“‹ Prerequisites

  • Bun (v1.0+)
  • Appwrite account (or self-hosted instance)

βš™οΈ Installation & Setup

1. Clone the repository

git clone <repository-url>
cd form-builder-saas

2. Install dependencies

bun install

3. Configure environment variables

Copy .env.example to .env:

cp .env.example .env

Fill in your Appwrite credentials in .env:

APPWRITE_ENDPOINT=https://cloud.appwrite.io/v1
APPWRITE_API_KEY=your-api-key
APPWRITE_BUCKET_ID=imagine-project-bucket
APPWRITE_PROJECT_ID=your-project-id
VITE_INSTRUMENTATION_SCRIPT_SRC=  # Optional analytics

4. Deploy Appwrite Schema

The database schema is defined in appwrite.json. Deploy it to your Appwrite project:

# Install Appwrite CLI if you haven't already
npm install -g appwrite-cli

# Login to Appwrite
appwrite login

# Deploy the schema
appwrite deploy collection

This will create:

  • Forms collection (stores form metadata)
  • FormFields collection (stores individual form fields)
  • FormSubmissions collection (stores participant responses)
  • Storage bucket (for file uploads)

5. Start the development server

bun run dev

The app will be available at http://localhost:3000.

πŸ§ͺ Testing

Manual Testing Checklist

Authentication Flow

  • Sign up with valid email/password
  • Sign in with existing account
  • Sign out successfully
  • Protected routes redirect to sign-in when not authenticated
  • After sign-in, user is redirected to dashboard

Admin Dashboard

  • View list of forms
  • Search forms by title
  • Create new form with title, description, and auth toggle
  • Edit form (navigates to form builder)
  • Duplicate form (creates copy with all fields)
  • Delete form (shows confirmation, removes form and data)
  • Copy form link to clipboard

Form Builder

  • Add fields by clicking field types
  • Drag and drop fields to reorder
  • Select field to open settings panel
  • Edit field label, placeholder, required toggle
  • Add/remove options for select/radio/checkbox fields
  • Delete field (shows on hover)
  • Auto-save updates (check by refreshing page)
  • Preview form (opens in new tab)
  • Back to dashboard navigation

Public Form Submission

  • Access form via /form/{formId} URL
  • Form shows authentication prompt if requireAuth is enabled
  • All 11 field types render correctly
  • Required fields show validation errors
  • Form submits successfully
  • Success message displays after submission
  • Form is responsive on mobile devices

Submissions Management

  • View submissions list for a form
  • Click "View" to see submission details
  • Export submissions to CSV
  • Export submissions to JSON
  • Delete submission with confirmation
  • Submission stats display correctly

Accessibility Testing

  • Keyboard navigation works throughout app
  • Focus states are visible
  • Form labels are properly associated
  • Error messages are announced
  • Color contrast meets WCAG 2.1 AA standards

Responsive Design Testing

  • Test on mobile (320px-767px)
  • Test on tablet (768px-1023px)
  • Test on desktop (1024px+)
  • Touch targets are at least 44x44px
  • Text is readable without zooming

πŸš€ Building for Production

Build the application

bun run build

This creates an optimized production build in the dist directory.

Preview the production build

bun run serve

Deploy

The application can be deployed to any Node.js hosting platform:

Vercel / Netlify / Cloudflare Pages

  1. Connect your Git repository
  2. Set environment variables
  3. Deploy (platform will auto-detect TanStack Start)

Docker

docker build -t form-builder .
docker run -p 3000:3000 form-builder

Traditional Node.js Server

bun run build
bun run start

πŸ“ Environment Variables Reference

Variable Description Required
APPWRITE_ENDPOINT Appwrite API endpoint URL Yes
APPWRITE_API_KEY Appwrite API key with full permissions Yes
APPWRITE_BUCKET_ID Storage bucket ID for file uploads Yes
APPWRITE_PROJECT_ID Appwrite project ID Yes
VITE_INSTRUMENTATION_SCRIPT_SRC Analytics script URL (optional) No

πŸ“Š Performance Optimization

Current Optimizations

  • Code Splitting: Routes are lazy-loaded
  • Auto-save Debouncing: Field updates debounced by 500ms
  • Query Caching: TanStack Query caches API responses
  • Optimistic Updates: UI updates immediately for smooth UX

Monitoring

  • Use browser DevTools Performance tab
  • Check Network tab for API response times
  • Monitor bundle size with bun run build --analyze

Tips for Production

  1. Enable Appwrite CDN for faster API responses
  2. Use a CDN for static assets
  3. Enable compression on your hosting platform
  4. Monitor error rates with Sentry or similar
  5. Set up uptime monitoring

πŸ—οΈ Project Structure

src/
β”œβ”€β”€ components/           # Reusable UI components
β”‚   β”œβ”€β”€ ui/              # shadcn/ui components (read-only)
β”‚   β”œβ”€β”€ auth/            # Authentication components
β”‚   β”œβ”€β”€ dashboard/       # Dashboard components
β”‚   β”œβ”€β”€ form-builder/    # Form builder components
β”‚   └── submissions/     # Submission management components
β”œβ”€β”€ hooks/               # Custom React hooks
β”œβ”€β”€ lib/                 # Utilities and helpers
β”‚   β”œβ”€β”€ field-types.ts   # Field type definitions
β”‚   └── utils.ts         # General utilities
β”œβ”€β”€ routes/              # TanStack Router routes
β”‚   β”œβ”€β”€ _public/         # Public routes (home, forms)
β”‚   β”œβ”€β”€ _protected/      # Protected routes (dashboard, builder, submissions)
β”‚   └── _auth/           # Auth routes (sign-in, sign-up, sign-out)
β”œβ”€β”€ server/              # Server-side code
β”‚   β”œβ”€β”€ lib/             # Server utilities
β”‚   β”‚   β”œβ”€β”€ appwrite.ts  # Appwrite client setup
β”‚   β”‚   β”œβ”€β”€ db.ts        # Database helpers
β”‚   β”‚   └── appwrite.types.ts  # TypeScript types
β”‚   └── functions/       # Server functions
β”‚       β”œβ”€β”€ auth.ts      # Authentication logic
β”‚       β”œβ”€β”€ forms.ts     # Form CRUD operations
β”‚       β”œβ”€β”€ formFields.ts  # Field CRUD operations
β”‚       └── submissions.ts  # Submission handling
└── styles.css           # Global styles (Tailwind)

πŸ”’ Security Best Practices

  1. Never expose API keys: Environment variables are server-only
  2. Ownership verification: All CRUD operations verify user ownership
  3. Input validation: Zod schemas validate all user input
  4. SQL injection protection: Appwrite handles parameterized queries
  5. XSS protection: React auto-escapes rendered content
  6. CSRF protection: Session cookies use httpOnly and secure flags

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

πŸ“„ License

This project is licensed under the MIT License.

πŸ™ Acknowledgments

πŸ“ž Support

For issues and questions:

  • Open an issue on GitHub
  • Check existing issues for solutions
  • Review the documentation

Built with ❀️ using modern web technologies

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages