Loading repository dataβ¦
Loading repository dataβ¦
bkharisma / repository
π Form Builder A single-page application for building forms, managing submissions with generating dynamic reports and autofilled form with unique data type feature β all connected to a Laravel backend API.
A single-page application for building forms, managing submissions with generating dynamic reports and autofilled form with unique data type feature β all connected to a Laravel backend API.
Quick Start Β· Features Β· Project Structure Β· Configuration Β· Scripts Β· Troubleshooting
user : builder@kdigital.technology
password : password
| Feature | Description |
|---|---|
| Public Form Submission | Users fill out forms at /form/{slug} β no login required |
| Admin Dashboard | Manage forms, view submissions, generate reports from a single panel |
| Drag-and-Drop Builder | Visual field editor with 13+ field types powered by @dnd-kit |
| Auto-Fill | Automatically populate fields from previous submissions |
| Dynamic Reports | Chart-based analytics with Chart.js β bar, pie, line, and more |
| Export | Download submissions as CSV, Excel (XLSX), or PDF |
| Rich Text Editor | @tiptap powered WYSIWYG field type |
| Signature Capture | react-signature-canvas for handwritten signature fields |
| Responsive | Fully functional on mobile and desktop |
| Bot Protection | Cloudflare Turnstile on login and form submission |
| Tool | Version |
|---|---|
| Node.js | 18+ |
| npm | 9+ |
| PHP | 8.3+ (for backend) |
| Composer | 2.x (for backend) |
| MySQL | 5.7+ / MariaDB 10.3+ |
The frontend is a SPA β all data comes from the Laravel backend API. You must set it up first.
cd ../backend
composer install
cp .env.example .env
php artisan key:generate
Edit backend/.env and configure your database:
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=form_builder
DB_USERNAME=your_user
DB_PASSWORD=your_password
Run migrations and seeders (creates the default admin user and a sample form):
php artisan migrate:fresh --seed
Turnstile is required for bot protection. For development, use Cloudflare's test keys:
# In backend/.env
TURNSTILE_SITE_KEY=1x00000000000000000000AA
TURNSTILE_SECRET_KEY=1x0000000000000000000000000000000AA
For production, get real keys at Cloudflare Turnstile Dashboard.
Start the backend server:
php artisan serve
# API available at http://localhost:8000
cd frontend
npm install
cp .env.example .env
Edit frontend/.env:
# API URL β for local dev, the Vite proxy handles this
# (requests to /api and /storage are proxied to http://localhost:8000)
VITE_API_URL=/api
# Cloudflare Turnstile site key (use test key for development)
VITE_TURNSTILE_SITE_KEY=1x00000000000000000000AA
# App name shown in browser tab
VITE_APP_NAME="Form Builder"
Start the development server:
npm run dev
# Frontend available at http://localhost:5173
Go to http://localhost:5173:
| Field | Value |
|---|---|
admin@dgb.local | |
| Password | password |
The Vite dev server proxies API requests so both frontend and backend run seamlessly in development:
ββββββββββββββββββββ ββββββββββββββββββββββββ ββββββββββββββββββββ
β Browser ββββββββ>β Vite Dev Server ββββββββ>β Laravel API β
β localhost:5173 β<ββββββββ (Proxy) β<ββββββββ localhost:8000 β
ββββββββββββββββββββ ββββββββββββββββββββββββ ββββββββββββββββββββ
/api/* β proxied /api, /storage REST API
/storage/* β proxied forwarded + Storage
Configured in vite.config.ts:
server: {
proxy: {
'/api': { target: 'http://localhost:8000', changeOrigin: true },
'/storage': { target: 'http://localhost:8000', changeOrigin: true },
},
}
For production, set VITE_API_URL to the full backend URL, rebuild, and serve the dist/ folder:
VITE_API_URL=https://your-api-domain.com/api
npm run build # Output goes to dist/
Serve dist/ with any static file server (Nginx, Apache, etc.). Ensure the backend CORS FRONTEND_URL matches your production domain.
frontend/
βββ public/ # Static assets (favicon, etc.)
βββ src/
β βββ components/ # Reusable UI components
β βββ pages/ # Page-level components
β β βββ LandingPage.tsx # Public landing page
β β βββ LoginPage.tsx # Admin login
β β βββ DashboardPage.tsx
β β βββ SubmissionPage.tsx # Public form submission
β β βββ SettingsPage.tsx
β β βββ ProfilePage.tsx
β β βββ AdminUsersPage.tsx
β β βββ FormDashboardPage.tsx
β β βββ form/ # Form-related pages
β β βββ FormBuilderPage.tsx
β β βββ FormSubmissionsPage.tsx
β β βββ FormReportsPage.tsx
β β βββ FormTitlePage.tsx
β β βββ FormDashboardListPage.tsx
β βββ services/ # API service layer (axios)
β βββ hooks/ # Custom React hooks
β βββ types/ # TypeScript type definitions
β βββ utils/ # Utility functions
β βββ config/ # App configuration
β βββ layouts/ # Layout components
β βββ assets/ # Images, fonts, etc.
β βββ test/ # Test setup and utilities
β βββ App.tsx # Root component with routing
β βββ App.css # Global styles
β βββ index.css # TailwindCSS imports
β βββ main.tsx # Entry point
βββ .env # Environment variables
βββ .env.example # Environment template
βββ index.html # HTML entry point
βββ vite.config.ts # Vite + Vitest configuration
βββ tsconfig.json # TypeScript configuration
βββ eslint.config.js # ESLint configuration
βββ package.json # Dependencies and scripts
| Package | Purpose |
|---|---|
| React 19 | UI framework |
| TypeScript | Type safety |
| Vite | Build tool and dev server with HMR |
| TailwindCSS 4 | Utility-first CSS framework |
| react-router-dom | Client-side routing (SPA) |
| axios | HTTP client for API calls |
| @dnd-kit | Drag-and-drop for Form Builder |
| @tiptap | Rich text editor field type |
| Chart.js + react-chartjs-2 | Dynamic report charts |
| jsPDF + autotable + html2canvas | PDF export generation |
| react-signature-canvas | Signature capture field |
| Vitest + Testing Library | Unit and integration tests |
| Variable | Description | Default |
|---|---|---|
VITE_API_URL | Backend API base URL | /api (uses Vite proxy in dev) |
VITE_TURNSTILE_SITE_KEY | Cloudflare Turnstile site key | 1x00000000000000000000AA (test key) |
VITE_APP_NAME | App display name in browser tab | "Kopega Poltekpar Palembang APP" |
backend/.env)| Variable | Description | Default |
|---|---|---|
DB_CONNECTION | Database driver | mysql |
DB_HOST | Database host | 127.0.0.1 |
DB_PORT | Database port | 3306 |
DB_DATABASE | Database name | form_builder |
DB_USERNAME | Database user | β |
DB_PASSWORD | Database password | β |
TURNSTILE_SITE_KEY | Turnstile site key (must match frontend) | β |
TURNSTILE_SECRET_KEY | Turnstile secret key | β |
FRONTEND_URL | Frontend URL for CORS | http://localhost:5173 |
See .env.example for all supported parameters.
| Command | Description |
|---|---|
npm run dev | Start dev server with HMR at localhost:5173 |
npm run build | Type-check and build for production (dist/) |
npm run preview | Preview the production build locally |
npm run lint | Run ESLint checks |
npm run test | Run tests in watch mode |